babylon.module.d.ts 5.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  466. * @param convertedColor defines the Color3 object where to store the linear space version
  467. * @returns the unmodified Color3
  468. */
  469. toLinearSpaceToRef(convertedColor: Color3): Color3;
  470. /**
  471. * Computes a new Color3 converted from the current one to gamma space
  472. * @returns a new Color3 object
  473. */
  474. toGammaSpace(): Color3;
  475. /**
  476. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  477. * @param convertedColor defines the Color3 object where to store the gamma space version
  478. * @returns the unmodified Color3
  479. */
  480. toGammaSpaceToRef(convertedColor: Color3): Color3;
  481. private static _BlackReadOnly;
  482. /**
  483. * Creates a new Color3 from the string containing valid hexadecimal values
  484. * @param hex defines a string containing valid hexadecimal values
  485. * @returns a new Color3 object
  486. */
  487. static FromHexString(hex: string): Color3;
  488. /**
  489. * Creates a new Color3 from the starting index of the given array
  490. * @param array defines the source array
  491. * @param offset defines an offset in the source array
  492. * @returns a new Color3 object
  493. */
  494. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  495. /**
  496. * Creates a new Color3 from integer values (< 256)
  497. * @param r defines the red component to read from (value between 0 and 255)
  498. * @param g defines the green component to read from (value between 0 and 255)
  499. * @param b defines the blue component to read from (value between 0 and 255)
  500. * @returns a new Color3 object
  501. */
  502. static FromInts(r: number, g: number, b: number): Color3;
  503. /**
  504. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  505. * @param start defines the start Color3 value
  506. * @param end defines the end Color3 value
  507. * @param amount defines the gradient value between start and end
  508. * @returns a new Color3 object
  509. */
  510. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  511. /**
  512. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  513. * @param left defines the start value
  514. * @param right defines the end value
  515. * @param amount defines the gradient factor
  516. * @param result defines the Color3 object where to store the result
  517. */
  518. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  519. /**
  520. * Returns a Color3 value containing a red color
  521. * @returns a new Color3 object
  522. */
  523. static Red(): Color3;
  524. /**
  525. * Returns a Color3 value containing a green color
  526. * @returns a new Color3 object
  527. */
  528. static Green(): Color3;
  529. /**
  530. * Returns a Color3 value containing a blue color
  531. * @returns a new Color3 object
  532. */
  533. static Blue(): Color3;
  534. /**
  535. * Returns a Color3 value containing a black color
  536. * @returns a new Color3 object
  537. */
  538. static Black(): Color3;
  539. /**
  540. * Gets a Color3 value containing a black color that must not be updated
  541. */
  542. static readonly BlackReadOnly: DeepImmutable<Color3>;
  543. /**
  544. * Returns a Color3 value containing a white color
  545. * @returns a new Color3 object
  546. */
  547. static White(): Color3;
  548. /**
  549. * Returns a Color3 value containing a purple color
  550. * @returns a new Color3 object
  551. */
  552. static Purple(): Color3;
  553. /**
  554. * Returns a Color3 value containing a magenta color
  555. * @returns a new Color3 object
  556. */
  557. static Magenta(): Color3;
  558. /**
  559. * Returns a Color3 value containing a yellow color
  560. * @returns a new Color3 object
  561. */
  562. static Yellow(): Color3;
  563. /**
  564. * Returns a Color3 value containing a gray color
  565. * @returns a new Color3 object
  566. */
  567. static Gray(): Color3;
  568. /**
  569. * Returns a Color3 value containing a teal color
  570. * @returns a new Color3 object
  571. */
  572. static Teal(): Color3;
  573. /**
  574. * Returns a Color3 value containing a random color
  575. * @returns a new Color3 object
  576. */
  577. static Random(): Color3;
  578. }
  579. /**
  580. * Class used to hold a RBGA color
  581. */
  582. export class Color4 {
  583. /**
  584. * Defines the red component (between 0 and 1, default is 0)
  585. */
  586. r: number;
  587. /**
  588. * Defines the green component (between 0 and 1, default is 0)
  589. */
  590. g: number;
  591. /**
  592. * Defines the blue component (between 0 and 1, default is 0)
  593. */
  594. b: number;
  595. /**
  596. * Defines the alpha component (between 0 and 1, default is 1)
  597. */
  598. a: number;
  599. /**
  600. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  601. * @param r defines the red component (between 0 and 1, default is 0)
  602. * @param g defines the green component (between 0 and 1, default is 0)
  603. * @param b defines the blue component (between 0 and 1, default is 0)
  604. * @param a defines the alpha component (between 0 and 1, default is 1)
  605. */
  606. constructor(
  607. /**
  608. * Defines the red component (between 0 and 1, default is 0)
  609. */
  610. r?: number,
  611. /**
  612. * Defines the green component (between 0 and 1, default is 0)
  613. */
  614. g?: number,
  615. /**
  616. * Defines the blue component (between 0 and 1, default is 0)
  617. */
  618. b?: number,
  619. /**
  620. * Defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. a?: number);
  623. /**
  624. * Adds in place the given Color4 values to the current Color4 object
  625. * @param right defines the second operand
  626. * @returns the current updated Color4 object
  627. */
  628. addInPlace(right: DeepImmutable<Color4>): Color4;
  629. /**
  630. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  631. * @returns the new array
  632. */
  633. asArray(): number[];
  634. /**
  635. * Stores from the starting index in the given array the Color4 successive values
  636. * @param array defines the array where to store the r,g,b components
  637. * @param index defines an optional index in the target array to define where to start storing values
  638. * @returns the current Color4 object
  639. */
  640. toArray(array: number[], index?: number): Color4;
  641. /**
  642. * Determines equality between Color4 objects
  643. * @param otherColor defines the second operand
  644. * @returns true if the rgba values are equal to the given ones
  645. */
  646. equals(otherColor: DeepImmutable<Color4>): boolean;
  647. /**
  648. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  649. * @param right defines the second operand
  650. * @returns a new Color4 object
  651. */
  652. add(right: DeepImmutable<Color4>): Color4;
  653. /**
  654. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  655. * @param right defines the second operand
  656. * @returns a new Color4 object
  657. */
  658. subtract(right: DeepImmutable<Color4>): Color4;
  659. /**
  660. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  661. * @param right defines the second operand
  662. * @param result defines the Color4 object where to store the result
  663. * @returns the current Color4 object
  664. */
  665. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  666. /**
  667. * Creates a new Color4 with the current Color4 values multiplied by scale
  668. * @param scale defines the scaling factor to apply
  669. * @returns a new Color4 object
  670. */
  671. scale(scale: number): Color4;
  672. /**
  673. * Multiplies the current Color4 values by scale and stores the result in "result"
  674. * @param scale defines the scaling factor to apply
  675. * @param result defines the Color4 object where to store the result
  676. * @returns the current unmodified Color4
  677. */
  678. scaleToRef(scale: number, result: Color4): Color4;
  679. /**
  680. * Scale the current Color4 values by a factor and add the result to a given Color4
  681. * @param scale defines the scale factor
  682. * @param result defines the Color4 object where to store the result
  683. * @returns the unmodified current Color4
  684. */
  685. scaleAndAddToRef(scale: number, result: Color4): Color4;
  686. /**
  687. * Clamps the rgb values by the min and max values and stores the result into "result"
  688. * @param min defines minimum clamping value (default is 0)
  689. * @param max defines maximum clamping value (default is 1)
  690. * @param result defines color to store the result into.
  691. * @returns the cuurent Color4
  692. */
  693. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  694. /**
  695. * Multipy an Color4 value by another and return a new Color4 object
  696. * @param color defines the Color4 value to multiply by
  697. * @returns a new Color4 object
  698. */
  699. multiply(color: Color4): Color4;
  700. /**
  701. * Multipy a Color4 value by another and push the result in a reference value
  702. * @param color defines the Color4 value to multiply by
  703. * @param result defines the Color4 to fill the result in
  704. * @returns the result Color4
  705. */
  706. multiplyToRef(color: Color4, result: Color4): Color4;
  707. /**
  708. * Creates a string with the Color4 current values
  709. * @returns the string representation of the Color4 object
  710. */
  711. toString(): string;
  712. /**
  713. * Returns the string "Color4"
  714. * @returns "Color4"
  715. */
  716. getClassName(): string;
  717. /**
  718. * Compute the Color4 hash code
  719. * @returns an unique number that can be used to hash Color4 objects
  720. */
  721. getHashCode(): number;
  722. /**
  723. * Creates a new Color4 copied from the current one
  724. * @returns a new Color4 object
  725. */
  726. clone(): Color4;
  727. /**
  728. * Copies the given Color4 values into the current one
  729. * @param source defines the source Color4 object
  730. * @returns the current updated Color4 object
  731. */
  732. copyFrom(source: Color4): Color4;
  733. /**
  734. * Copies the given float values into the current one
  735. * @param r defines the red component to read from
  736. * @param g defines the green component to read from
  737. * @param b defines the blue component to read from
  738. * @param a defines the alpha component to read from
  739. * @returns the current updated Color4 object
  740. */
  741. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  742. /**
  743. * Copies the given float values into the current one
  744. * @param r defines the red component to read from
  745. * @param g defines the green component to read from
  746. * @param b defines the blue component to read from
  747. * @param a defines the alpha component to read from
  748. * @returns the current updated Color4 object
  749. */
  750. set(r: number, g: number, b: number, a: number): Color4;
  751. /**
  752. * Compute the Color4 hexadecimal code as a string
  753. * @returns a string containing the hexadecimal representation of the Color4 object
  754. */
  755. toHexString(): string;
  756. /**
  757. * Computes a new Color4 converted from the current one to linear space
  758. * @returns a new Color4 object
  759. */
  760. toLinearSpace(): Color4;
  761. /**
  762. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  763. * @param convertedColor defines the Color4 object where to store the linear space version
  764. * @returns the unmodified Color4
  765. */
  766. toLinearSpaceToRef(convertedColor: Color4): Color4;
  767. /**
  768. * Computes a new Color4 converted from the current one to gamma space
  769. * @returns a new Color4 object
  770. */
  771. toGammaSpace(): Color4;
  772. /**
  773. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  774. * @param convertedColor defines the Color4 object where to store the gamma space version
  775. * @returns the unmodified Color4
  776. */
  777. toGammaSpaceToRef(convertedColor: Color4): Color4;
  778. /**
  779. * Creates a new Color4 from the string containing valid hexadecimal values
  780. * @param hex defines a string containing valid hexadecimal values
  781. * @returns a new Color4 object
  782. */
  783. static FromHexString(hex: string): Color4;
  784. /**
  785. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  786. * @param left defines the start value
  787. * @param right defines the end value
  788. * @param amount defines the gradient factor
  789. * @returns a new Color4 object
  790. */
  791. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  792. /**
  793. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  794. * @param left defines the start value
  795. * @param right defines the end value
  796. * @param amount defines the gradient factor
  797. * @param result defines the Color4 object where to store data
  798. */
  799. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  800. /**
  801. * Creates a new Color4 from a Color3 and an alpha value
  802. * @param color3 defines the source Color3 to read from
  803. * @param alpha defines the alpha component (1.0 by default)
  804. * @returns a new Color4 object
  805. */
  806. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  807. /**
  808. * Creates a new Color4 from the starting index element of the given array
  809. * @param array defines the source array to read from
  810. * @param offset defines the offset in the source array
  811. * @returns a new Color4 object
  812. */
  813. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  814. /**
  815. * Creates a new Color3 from integer values (< 256)
  816. * @param r defines the red component to read from (value between 0 and 255)
  817. * @param g defines the green component to read from (value between 0 and 255)
  818. * @param b defines the blue component to read from (value between 0 and 255)
  819. * @param a defines the alpha component to read from (value between 0 and 255)
  820. * @returns a new Color3 object
  821. */
  822. static FromInts(r: number, g: number, b: number, a: number): Color4;
  823. /**
  824. * Check the content of a given array and convert it to an array containing RGBA data
  825. * If the original array was already containing count * 4 values then it is returned directly
  826. * @param colors defines the array to check
  827. * @param count defines the number of RGBA data to expect
  828. * @returns an array containing count * 4 values (RGBA)
  829. */
  830. static CheckColors4(colors: number[], count: number): number[];
  831. }
  832. /**
  833. * Class representing a vector containing 2 coordinates
  834. */
  835. export class Vector2 {
  836. /** defines the first coordinate */
  837. x: number;
  838. /** defines the second coordinate */
  839. y: number;
  840. /**
  841. * Creates a new Vector2 from the given x and y coordinates
  842. * @param x defines the first coordinate
  843. * @param y defines the second coordinate
  844. */
  845. constructor(
  846. /** defines the first coordinate */
  847. x?: number,
  848. /** defines the second coordinate */
  849. y?: number);
  850. /**
  851. * Gets a string with the Vector2 coordinates
  852. * @returns a string with the Vector2 coordinates
  853. */
  854. toString(): string;
  855. /**
  856. * Gets class name
  857. * @returns the string "Vector2"
  858. */
  859. getClassName(): string;
  860. /**
  861. * Gets current vector hash code
  862. * @returns the Vector2 hash code as a number
  863. */
  864. getHashCode(): number;
  865. /**
  866. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  867. * @param array defines the source array
  868. * @param index defines the offset in source array
  869. * @returns the current Vector2
  870. */
  871. toArray(array: FloatArray, index?: number): Vector2;
  872. /**
  873. * Copy the current vector to an array
  874. * @returns a new array with 2 elements: the Vector2 coordinates.
  875. */
  876. asArray(): number[];
  877. /**
  878. * Sets the Vector2 coordinates with the given Vector2 coordinates
  879. * @param source defines the source Vector2
  880. * @returns the current updated Vector2
  881. */
  882. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  883. /**
  884. * Sets the Vector2 coordinates with the given floats
  885. * @param x defines the first coordinate
  886. * @param y defines the second coordinate
  887. * @returns the current updated Vector2
  888. */
  889. copyFromFloats(x: number, y: number): Vector2;
  890. /**
  891. * Sets the Vector2 coordinates with the given floats
  892. * @param x defines the first coordinate
  893. * @param y defines the second coordinate
  894. * @returns the current updated Vector2
  895. */
  896. set(x: number, y: number): Vector2;
  897. /**
  898. * Add another vector with the current one
  899. * @param otherVector defines the other vector
  900. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  901. */
  902. add(otherVector: DeepImmutable<Vector2>): Vector2;
  903. /**
  904. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  905. * @param otherVector defines the other vector
  906. * @param result defines the target vector
  907. * @returns the unmodified current Vector2
  908. */
  909. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  910. /**
  911. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  912. * @param otherVector defines the other vector
  913. * @returns the current updated Vector2
  914. */
  915. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  916. /**
  917. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  918. * @param otherVector defines the other vector
  919. * @returns a new Vector2
  920. */
  921. addVector3(otherVector: Vector3): Vector2;
  922. /**
  923. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  924. * @param otherVector defines the other vector
  925. * @returns a new Vector2
  926. */
  927. subtract(otherVector: Vector2): Vector2;
  928. /**
  929. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  930. * @param otherVector defines the other vector
  931. * @param result defines the target vector
  932. * @returns the unmodified current Vector2
  933. */
  934. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  935. /**
  936. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  937. * @param otherVector defines the other vector
  938. * @returns the current updated Vector2
  939. */
  940. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  941. /**
  942. * Multiplies in place the current Vector2 coordinates by the given ones
  943. * @param otherVector defines the other vector
  944. * @returns the current updated Vector2
  945. */
  946. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  947. /**
  948. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  949. * @param otherVector defines the other vector
  950. * @returns a new Vector2
  951. */
  952. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  953. /**
  954. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @param result defines the target vector
  957. * @returns the unmodified current Vector2
  958. */
  959. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  960. /**
  961. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  962. * @param x defines the first coordinate
  963. * @param y defines the second coordinate
  964. * @returns a new Vector2
  965. */
  966. multiplyByFloats(x: number, y: number): Vector2;
  967. /**
  968. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  969. * @param otherVector defines the other vector
  970. * @returns a new Vector2
  971. */
  972. divide(otherVector: Vector2): Vector2;
  973. /**
  974. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  975. * @param otherVector defines the other vector
  976. * @param result defines the target vector
  977. * @returns the unmodified current Vector2
  978. */
  979. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  980. /**
  981. * Divides the current Vector2 coordinates by the given ones
  982. * @param otherVector defines the other vector
  983. * @returns the current updated Vector2
  984. */
  985. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  986. /**
  987. * Gets a new Vector2 with current Vector2 negated coordinates
  988. * @returns a new Vector2
  989. */
  990. negate(): Vector2;
  991. /**
  992. * Multiply the Vector2 coordinates by scale
  993. * @param scale defines the scaling factor
  994. * @returns the current updated Vector2
  995. */
  996. scaleInPlace(scale: number): Vector2;
  997. /**
  998. * Returns a new Vector2 scaled by "scale" from the current Vector2
  999. * @param scale defines the scaling factor
  1000. * @returns a new Vector2
  1001. */
  1002. scale(scale: number): Vector2;
  1003. /**
  1004. * Scale the current Vector2 values by a factor to a given Vector2
  1005. * @param scale defines the scale factor
  1006. * @param result defines the Vector2 object where to store the result
  1007. * @returns the unmodified current Vector2
  1008. */
  1009. scaleToRef(scale: number, result: Vector2): Vector2;
  1010. /**
  1011. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1012. * @param scale defines the scale factor
  1013. * @param result defines the Vector2 object where to store the result
  1014. * @returns the unmodified current Vector2
  1015. */
  1016. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1017. /**
  1018. * Gets a boolean if two vectors are equals
  1019. * @param otherVector defines the other vector
  1020. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1021. */
  1022. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1023. /**
  1024. * Gets a boolean if two vectors are equals (using an epsilon value)
  1025. * @param otherVector defines the other vector
  1026. * @param epsilon defines the minimal distance to consider equality
  1027. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1028. */
  1029. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1030. /**
  1031. * Gets a new Vector2 from current Vector2 floored values
  1032. * @returns a new Vector2
  1033. */
  1034. floor(): Vector2;
  1035. /**
  1036. * Gets a new Vector2 from current Vector2 floored values
  1037. * @returns a new Vector2
  1038. */
  1039. fract(): Vector2;
  1040. /**
  1041. * Gets the length of the vector
  1042. * @returns the vector length (float)
  1043. */
  1044. length(): number;
  1045. /**
  1046. * Gets the vector squared length
  1047. * @returns the vector squared length (float)
  1048. */
  1049. lengthSquared(): number;
  1050. /**
  1051. * Normalize the vector
  1052. * @returns the current updated Vector2
  1053. */
  1054. normalize(): Vector2;
  1055. /**
  1056. * Gets a new Vector2 copied from the Vector2
  1057. * @returns a new Vector2
  1058. */
  1059. clone(): Vector2;
  1060. /**
  1061. * Gets a new Vector2(0, 0)
  1062. * @returns a new Vector2
  1063. */
  1064. static Zero(): Vector2;
  1065. /**
  1066. * Gets a new Vector2(1, 1)
  1067. * @returns a new Vector2
  1068. */
  1069. static One(): Vector2;
  1070. /**
  1071. * Gets a new Vector2 set from the given index element of the given array
  1072. * @param array defines the data source
  1073. * @param offset defines the offset in the data source
  1074. * @returns a new Vector2
  1075. */
  1076. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1077. /**
  1078. * Sets "result" from the given index element of the given array
  1079. * @param array defines the data source
  1080. * @param offset defines the offset in the data source
  1081. * @param result defines the target vector
  1082. */
  1083. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1084. /**
  1085. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1086. * @param value1 defines 1st point of control
  1087. * @param value2 defines 2nd point of control
  1088. * @param value3 defines 3rd point of control
  1089. * @param value4 defines 4th point of control
  1090. * @param amount defines the interpolation factor
  1091. * @returns a new Vector2
  1092. */
  1093. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1094. /**
  1095. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1096. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1097. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1098. * @param value defines the value to clamp
  1099. * @param min defines the lower limit
  1100. * @param max defines the upper limit
  1101. * @returns a new Vector2
  1102. */
  1103. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1104. /**
  1105. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1106. * @param value1 defines the 1st control point
  1107. * @param tangent1 defines the outgoing tangent
  1108. * @param value2 defines the 2nd control point
  1109. * @param tangent2 defines the incoming tangent
  1110. * @param amount defines the interpolation factor
  1111. * @returns a new Vector2
  1112. */
  1113. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1114. /**
  1115. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1116. * @param start defines the start vector
  1117. * @param end defines the end vector
  1118. * @param amount defines the interpolation factor
  1119. * @returns a new Vector2
  1120. */
  1121. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1122. /**
  1123. * Gets the dot product of the vector "left" and the vector "right"
  1124. * @param left defines first vector
  1125. * @param right defines second vector
  1126. * @returns the dot product (float)
  1127. */
  1128. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1129. /**
  1130. * Returns a new Vector2 equal to the normalized given vector
  1131. * @param vector defines the vector to normalize
  1132. * @returns a new Vector2
  1133. */
  1134. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1135. /**
  1136. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1137. * @param left defines 1st vector
  1138. * @param right defines 2nd vector
  1139. * @returns a new Vector2
  1140. */
  1141. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1142. /**
  1143. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1144. * @param left defines 1st vector
  1145. * @param right defines 2nd vector
  1146. * @returns a new Vector2
  1147. */
  1148. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1149. /**
  1150. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1151. * @param vector defines the vector to transform
  1152. * @param transformation defines the matrix to apply
  1153. * @returns a new Vector2
  1154. */
  1155. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1156. /**
  1157. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1158. * @param vector defines the vector to transform
  1159. * @param transformation defines the matrix to apply
  1160. * @param result defines the target vector
  1161. */
  1162. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1163. /**
  1164. * Determines if a given vector is included in a triangle
  1165. * @param p defines the vector to test
  1166. * @param p0 defines 1st triangle point
  1167. * @param p1 defines 2nd triangle point
  1168. * @param p2 defines 3rd triangle point
  1169. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1170. */
  1171. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1172. /**
  1173. * Gets the distance between the vectors "value1" and "value2"
  1174. * @param value1 defines first vector
  1175. * @param value2 defines second vector
  1176. * @returns the distance between vectors
  1177. */
  1178. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1179. /**
  1180. * Returns the squared distance between the vectors "value1" and "value2"
  1181. * @param value1 defines first vector
  1182. * @param value2 defines second vector
  1183. * @returns the squared distance between vectors
  1184. */
  1185. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1186. /**
  1187. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1188. * @param value1 defines first vector
  1189. * @param value2 defines second vector
  1190. * @returns a new Vector2
  1191. */
  1192. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1193. /**
  1194. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1195. * @param p defines the middle point
  1196. * @param segA defines one point of the segment
  1197. * @param segB defines the other point of the segment
  1198. * @returns the shortest distance
  1199. */
  1200. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1201. }
  1202. /**
  1203. * Classed used to store (x,y,z) vector representation
  1204. * A Vector3 is the main object used in 3D geometry
  1205. * It can represent etiher the coordinates of a point the space, either a direction
  1206. * Reminder: js uses a left handed forward facing system
  1207. */
  1208. export class Vector3 {
  1209. /**
  1210. * Defines the first coordinates (on X axis)
  1211. */
  1212. x: number;
  1213. /**
  1214. * Defines the second coordinates (on Y axis)
  1215. */
  1216. y: number;
  1217. /**
  1218. * Defines the third coordinates (on Z axis)
  1219. */
  1220. z: number;
  1221. private static _UpReadOnly;
  1222. /**
  1223. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1224. * @param x defines the first coordinates (on X axis)
  1225. * @param y defines the second coordinates (on Y axis)
  1226. * @param z defines the third coordinates (on Z axis)
  1227. */
  1228. constructor(
  1229. /**
  1230. * Defines the first coordinates (on X axis)
  1231. */
  1232. x?: number,
  1233. /**
  1234. * Defines the second coordinates (on Y axis)
  1235. */
  1236. y?: number,
  1237. /**
  1238. * Defines the third coordinates (on Z axis)
  1239. */
  1240. z?: number);
  1241. /**
  1242. * Creates a string representation of the Vector3
  1243. * @returns a string with the Vector3 coordinates.
  1244. */
  1245. toString(): string;
  1246. /**
  1247. * Gets the class name
  1248. * @returns the string "Vector3"
  1249. */
  1250. getClassName(): string;
  1251. /**
  1252. * Creates the Vector3 hash code
  1253. * @returns a number which tends to be unique between Vector3 instances
  1254. */
  1255. getHashCode(): number;
  1256. /**
  1257. * Creates an array containing three elements : the coordinates of the Vector3
  1258. * @returns a new array of numbers
  1259. */
  1260. asArray(): number[];
  1261. /**
  1262. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1263. * @param array defines the destination array
  1264. * @param index defines the offset in the destination array
  1265. * @returns the current Vector3
  1266. */
  1267. toArray(array: FloatArray, index?: number): Vector3;
  1268. /**
  1269. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1270. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1271. */
  1272. toQuaternion(): Quaternion;
  1273. /**
  1274. * Adds the given vector to the current Vector3
  1275. * @param otherVector defines the second operand
  1276. * @returns the current updated Vector3
  1277. */
  1278. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1279. /**
  1280. * Adds the given coordinates to the current Vector3
  1281. * @param x defines the x coordinate of the operand
  1282. * @param y defines the y coordinate of the operand
  1283. * @param z defines the z coordinate of the operand
  1284. * @returns the current updated Vector3
  1285. */
  1286. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1287. /**
  1288. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1289. * @param otherVector defines the second operand
  1290. * @returns the resulting Vector3
  1291. */
  1292. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1293. /**
  1294. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1295. * @param otherVector defines the second operand
  1296. * @param result defines the Vector3 object where to store the result
  1297. * @returns the current Vector3
  1298. */
  1299. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1300. /**
  1301. * Subtract the given vector from the current Vector3
  1302. * @param otherVector defines the second operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1306. /**
  1307. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1321. * @param x defines the x coordinate of the operand
  1322. * @param y defines the y coordinate of the operand
  1323. * @param z defines the z coordinate of the operand
  1324. * @returns the resulting Vector3
  1325. */
  1326. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1327. /**
  1328. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1329. * @param x defines the x coordinate of the operand
  1330. * @param y defines the y coordinate of the operand
  1331. * @param z defines the z coordinate of the operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1336. /**
  1337. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1338. * @returns a new Vector3
  1339. */
  1340. negate(): Vector3;
  1341. /**
  1342. * Multiplies the Vector3 coordinates by the float "scale"
  1343. * @param scale defines the multiplier factor
  1344. * @returns the current updated Vector3
  1345. */
  1346. scaleInPlace(scale: number): Vector3;
  1347. /**
  1348. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1349. * @param scale defines the multiplier factor
  1350. * @returns a new Vector3
  1351. */
  1352. scale(scale: number): Vector3;
  1353. /**
  1354. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1355. * @param scale defines the multiplier factor
  1356. * @param result defines the Vector3 object where to store the result
  1357. * @returns the current Vector3
  1358. */
  1359. scaleToRef(scale: number, result: Vector3): Vector3;
  1360. /**
  1361. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1362. * @param scale defines the scale factor
  1363. * @param result defines the Vector3 object where to store the result
  1364. * @returns the unmodified current Vector3
  1365. */
  1366. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1367. /**
  1368. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1369. * @param otherVector defines the second operand
  1370. * @returns true if both vectors are equals
  1371. */
  1372. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1373. /**
  1374. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1375. * @param otherVector defines the second operand
  1376. * @param epsilon defines the minimal distance to define values as equals
  1377. * @returns true if both vectors are distant less than epsilon
  1378. */
  1379. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1380. /**
  1381. * Returns true if the current Vector3 coordinates equals the given floats
  1382. * @param x defines the x coordinate of the operand
  1383. * @param y defines the y coordinate of the operand
  1384. * @param z defines the z coordinate of the operand
  1385. * @returns true if both vectors are equals
  1386. */
  1387. equalsToFloats(x: number, y: number, z: number): boolean;
  1388. /**
  1389. * Multiplies the current Vector3 coordinates by the given ones
  1390. * @param otherVector defines the second operand
  1391. * @returns the current updated Vector3
  1392. */
  1393. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1394. /**
  1395. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1396. * @param otherVector defines the second operand
  1397. * @returns the new Vector3
  1398. */
  1399. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1400. /**
  1401. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1402. * @param otherVector defines the second operand
  1403. * @param result defines the Vector3 object where to store the result
  1404. * @returns the current Vector3
  1405. */
  1406. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1407. /**
  1408. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1409. * @param x defines the x coordinate of the operand
  1410. * @param y defines the y coordinate of the operand
  1411. * @param z defines the z coordinate of the operand
  1412. * @returns the new Vector3
  1413. */
  1414. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1415. /**
  1416. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1417. * @param otherVector defines the second operand
  1418. * @returns the new Vector3
  1419. */
  1420. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1421. /**
  1422. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1423. * @param otherVector defines the second operand
  1424. * @param result defines the Vector3 object where to store the result
  1425. * @returns the current Vector3
  1426. */
  1427. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1428. /**
  1429. * Divides the current Vector3 coordinates by the given ones.
  1430. * @param otherVector defines the second operand
  1431. * @returns the current updated Vector3
  1432. */
  1433. divideInPlace(otherVector: Vector3): Vector3;
  1434. /**
  1435. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1436. * @param other defines the second operand
  1437. * @returns the current updated Vector3
  1438. */
  1439. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1442. * @param other defines the second operand
  1443. * @returns the current updated Vector3
  1444. */
  1445. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1446. /**
  1447. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1448. * @param x defines the x coordinate of the operand
  1449. * @param y defines the y coordinate of the operand
  1450. * @param z defines the z coordinate of the operand
  1451. * @returns the current updated Vector3
  1452. */
  1453. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1454. /**
  1455. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1456. * @param x defines the x coordinate of the operand
  1457. * @param y defines the y coordinate of the operand
  1458. * @param z defines the z coordinate of the operand
  1459. * @returns the current updated Vector3
  1460. */
  1461. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1462. /**
  1463. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1464. * Check if is non uniform within a certain amount of decimal places to account for this
  1465. * @param epsilon the amount the values can differ
  1466. * @returns if the the vector is non uniform to a certain number of decimal places
  1467. */
  1468. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1469. /**
  1470. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1471. */
  1472. readonly isNonUniform: boolean;
  1473. /**
  1474. * Gets a new Vector3 from current Vector3 floored values
  1475. * @returns a new Vector3
  1476. */
  1477. floor(): Vector3;
  1478. /**
  1479. * Gets a new Vector3 from current Vector3 floored values
  1480. * @returns a new Vector3
  1481. */
  1482. fract(): Vector3;
  1483. /**
  1484. * Gets the length of the Vector3
  1485. * @returns the length of the Vecto3
  1486. */
  1487. length(): number;
  1488. /**
  1489. * Gets the squared length of the Vector3
  1490. * @returns squared length of the Vector3
  1491. */
  1492. lengthSquared(): number;
  1493. /**
  1494. * Normalize the current Vector3.
  1495. * Please note that this is an in place operation.
  1496. * @returns the current updated Vector3
  1497. */
  1498. normalize(): Vector3;
  1499. /**
  1500. * Reorders the x y z properties of the vector in place
  1501. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1502. * @returns the current updated vector
  1503. */
  1504. reorderInPlace(order: string): this;
  1505. /**
  1506. * Rotates the vector around 0,0,0 by a quaternion
  1507. * @param quaternion the rotation quaternion
  1508. * @param result vector to store the result
  1509. * @returns the resulting vector
  1510. */
  1511. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1512. /**
  1513. * Rotates a vector around a given point
  1514. * @param quaternion the rotation quaternion
  1515. * @param point the point to rotate around
  1516. * @param result vector to store the result
  1517. * @returns the resulting vector
  1518. */
  1519. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1520. /**
  1521. * Normalize the current Vector3 with the given input length.
  1522. * Please note that this is an in place operation.
  1523. * @param len the length of the vector
  1524. * @returns the current updated Vector3
  1525. */
  1526. normalizeFromLength(len: number): Vector3;
  1527. /**
  1528. * Normalize the current Vector3 to a new vector
  1529. * @returns the new Vector3
  1530. */
  1531. normalizeToNew(): Vector3;
  1532. /**
  1533. * Normalize the current Vector3 to the reference
  1534. * @param reference define the Vector3 to update
  1535. * @returns the updated Vector3
  1536. */
  1537. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1538. /**
  1539. * Creates a new Vector3 copied from the current Vector3
  1540. * @returns the new Vector3
  1541. */
  1542. clone(): Vector3;
  1543. /**
  1544. * Copies the given vector coordinates to the current Vector3 ones
  1545. * @param source defines the source Vector3
  1546. * @returns the current updated Vector3
  1547. */
  1548. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1549. /**
  1550. * Copies the given floats to the current Vector3 coordinates
  1551. * @param x defines the x coordinate of the operand
  1552. * @param y defines the y coordinate of the operand
  1553. * @param z defines the z coordinate of the operand
  1554. * @returns the current updated Vector3
  1555. */
  1556. copyFromFloats(x: number, y: number, z: number): Vector3;
  1557. /**
  1558. * Copies the given floats to the current Vector3 coordinates
  1559. * @param x defines the x coordinate of the operand
  1560. * @param y defines the y coordinate of the operand
  1561. * @param z defines the z coordinate of the operand
  1562. * @returns the current updated Vector3
  1563. */
  1564. set(x: number, y: number, z: number): Vector3;
  1565. /**
  1566. * Copies the given float to the current Vector3 coordinates
  1567. * @param v defines the x, y and z coordinates of the operand
  1568. * @returns the current updated Vector3
  1569. */
  1570. setAll(v: number): Vector3;
  1571. /**
  1572. * Get the clip factor between two vectors
  1573. * @param vector0 defines the first operand
  1574. * @param vector1 defines the second operand
  1575. * @param axis defines the axis to use
  1576. * @param size defines the size along the axis
  1577. * @returns the clip factor
  1578. */
  1579. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1580. /**
  1581. * Get angle between two vectors
  1582. * @param vector0 angle between vector0 and vector1
  1583. * @param vector1 angle between vector0 and vector1
  1584. * @param normal direction of the normal
  1585. * @return the angle between vector0 and vector1
  1586. */
  1587. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1588. /**
  1589. * Returns a new Vector3 set from the index "offset" of the given array
  1590. * @param array defines the source array
  1591. * @param offset defines the offset in the source array
  1592. * @returns the new Vector3
  1593. */
  1594. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1595. /**
  1596. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1597. * This function is deprecated. Use FromArray instead
  1598. * @param array defines the source array
  1599. * @param offset defines the offset in the source array
  1600. * @returns the new Vector3
  1601. */
  1602. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1603. /**
  1604. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1605. * @param array defines the source array
  1606. * @param offset defines the offset in the source array
  1607. * @param result defines the Vector3 where to store the result
  1608. */
  1609. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1610. /**
  1611. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1612. * This function is deprecated. Use FromArrayToRef instead.
  1613. * @param array defines the source array
  1614. * @param offset defines the offset in the source array
  1615. * @param result defines the Vector3 where to store the result
  1616. */
  1617. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1618. /**
  1619. * Sets the given vector "result" with the given floats.
  1620. * @param x defines the x coordinate of the source
  1621. * @param y defines the y coordinate of the source
  1622. * @param z defines the z coordinate of the source
  1623. * @param result defines the Vector3 where to store the result
  1624. */
  1625. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1626. /**
  1627. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1628. * @returns a new empty Vector3
  1629. */
  1630. static Zero(): Vector3;
  1631. /**
  1632. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1633. * @returns a new unit Vector3
  1634. */
  1635. static One(): Vector3;
  1636. /**
  1637. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1638. * @returns a new up Vector3
  1639. */
  1640. static Up(): Vector3;
  1641. /**
  1642. * Gets a up Vector3 that must not be updated
  1643. */
  1644. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1647. * @returns a new down Vector3
  1648. */
  1649. static Down(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1652. * @returns a new forward Vector3
  1653. */
  1654. static Forward(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1657. * @returns a new forward Vector3
  1658. */
  1659. static Backward(): Vector3;
  1660. /**
  1661. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1662. * @returns a new right Vector3
  1663. */
  1664. static Right(): Vector3;
  1665. /**
  1666. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1667. * @returns a new left Vector3
  1668. */
  1669. static Left(): Vector3;
  1670. /**
  1671. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1672. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1673. * @param vector defines the Vector3 to transform
  1674. * @param transformation defines the transformation matrix
  1675. * @returns the transformed Vector3
  1676. */
  1677. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1678. /**
  1679. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1680. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1681. * @param vector defines the Vector3 to transform
  1682. * @param transformation defines the transformation matrix
  1683. * @param result defines the Vector3 where to store the result
  1684. */
  1685. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1686. /**
  1687. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1688. * This method computes tranformed coordinates only, not transformed direction vectors
  1689. * @param x define the x coordinate of the source vector
  1690. * @param y define the y coordinate of the source vector
  1691. * @param z define the z coordinate of the source vector
  1692. * @param transformation defines the transformation matrix
  1693. * @param result defines the Vector3 where to store the result
  1694. */
  1695. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1696. /**
  1697. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1698. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1699. * @param vector defines the Vector3 to transform
  1700. * @param transformation defines the transformation matrix
  1701. * @returns the new Vector3
  1702. */
  1703. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1704. /**
  1705. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1706. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1707. * @param vector defines the Vector3 to transform
  1708. * @param transformation defines the transformation matrix
  1709. * @param result defines the Vector3 where to store the result
  1710. */
  1711. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1712. /**
  1713. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1714. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1715. * @param x define the x coordinate of the source vector
  1716. * @param y define the y coordinate of the source vector
  1717. * @param z define the z coordinate of the source vector
  1718. * @param transformation defines the transformation matrix
  1719. * @param result defines the Vector3 where to store the result
  1720. */
  1721. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1722. /**
  1723. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1724. * @param value1 defines the first control point
  1725. * @param value2 defines the second control point
  1726. * @param value3 defines the third control point
  1727. * @param value4 defines the fourth control point
  1728. * @param amount defines the amount on the spline to use
  1729. * @returns the new Vector3
  1730. */
  1731. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1732. /**
  1733. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1734. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1735. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1736. * @param value defines the current value
  1737. * @param min defines the lower range value
  1738. * @param max defines the upper range value
  1739. * @returns the new Vector3
  1740. */
  1741. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1742. /**
  1743. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1744. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1745. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1746. * @param value defines the current value
  1747. * @param min defines the lower range value
  1748. * @param max defines the upper range value
  1749. * @param result defines the Vector3 where to store the result
  1750. */
  1751. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1752. /**
  1753. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1754. * @param value1 defines the first control point
  1755. * @param tangent1 defines the first tangent vector
  1756. * @param value2 defines the second control point
  1757. * @param tangent2 defines the second tangent vector
  1758. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1759. * @returns the new Vector3
  1760. */
  1761. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1762. /**
  1763. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1764. * @param start defines the start value
  1765. * @param end defines the end value
  1766. * @param amount max defines amount between both (between 0 and 1)
  1767. * @returns the new Vector3
  1768. */
  1769. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1770. /**
  1771. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1772. * @param start defines the start value
  1773. * @param end defines the end value
  1774. * @param amount max defines amount between both (between 0 and 1)
  1775. * @param result defines the Vector3 where to store the result
  1776. */
  1777. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1778. /**
  1779. * Returns the dot product (float) between the vectors "left" and "right"
  1780. * @param left defines the left operand
  1781. * @param right defines the right operand
  1782. * @returns the dot product
  1783. */
  1784. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1785. /**
  1786. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1787. * The cross product is then orthogonal to both "left" and "right"
  1788. * @param left defines the left operand
  1789. * @param right defines the right operand
  1790. * @returns the cross product
  1791. */
  1792. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the cross product of "left" and "right"
  1795. * The cross product is then orthogonal to both "left" and "right"
  1796. * @param left defines the left operand
  1797. * @param right defines the right operand
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1801. /**
  1802. * Returns a new Vector3 as the normalization of the given vector
  1803. * @param vector defines the Vector3 to normalize
  1804. * @returns the new Vector3
  1805. */
  1806. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1807. /**
  1808. * Sets the given vector "result" with the normalization of the given first vector
  1809. * @param vector defines the Vector3 to normalize
  1810. * @param result defines the Vector3 where to store the result
  1811. */
  1812. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1813. /**
  1814. * Project a Vector3 onto screen space
  1815. * @param vector defines the Vector3 to project
  1816. * @param world defines the world matrix to use
  1817. * @param transform defines the transform (view x projection) matrix to use
  1818. * @param viewport defines the screen viewport to use
  1819. * @returns the new Vector3
  1820. */
  1821. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1822. /** @hidden */
  1823. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1824. /**
  1825. * Unproject from screen space to object space
  1826. * @param source defines the screen space Vector3 to use
  1827. * @param viewportWidth defines the current width of the viewport
  1828. * @param viewportHeight defines the current height of the viewport
  1829. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1830. * @param transform defines the transform (view x projection) matrix to use
  1831. * @returns the new Vector3
  1832. */
  1833. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1834. /**
  1835. * Unproject from screen space to object space
  1836. * @param source defines the screen space Vector3 to use
  1837. * @param viewportWidth defines the current width of the viewport
  1838. * @param viewportHeight defines the current height of the viewport
  1839. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1840. * @param view defines the view matrix to use
  1841. * @param projection defines the projection matrix to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param view defines the view matrix to use
  1852. * @param projection defines the projection matrix to use
  1853. * @param result defines the Vector3 where to store the result
  1854. */
  1855. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1856. /**
  1857. * Unproject from screen space to object space
  1858. * @param sourceX defines the screen space x coordinate to use
  1859. * @param sourceY defines the screen space y coordinate to use
  1860. * @param sourceZ defines the screen space z coordinate to use
  1861. * @param viewportWidth defines the current width of the viewport
  1862. * @param viewportHeight defines the current height of the viewport
  1863. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1864. * @param view defines the view matrix to use
  1865. * @param projection defines the projection matrix to use
  1866. * @param result defines the Vector3 where to store the result
  1867. */
  1868. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1869. /**
  1870. * Gets the minimal coordinate values between two Vector3
  1871. * @param left defines the first operand
  1872. * @param right defines the second operand
  1873. * @returns the new Vector3
  1874. */
  1875. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1876. /**
  1877. * Gets the maximal coordinate values between two Vector3
  1878. * @param left defines the first operand
  1879. * @param right defines the second operand
  1880. * @returns the new Vector3
  1881. */
  1882. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1883. /**
  1884. * Returns the distance between the vectors "value1" and "value2"
  1885. * @param value1 defines the first operand
  1886. * @param value2 defines the second operand
  1887. * @returns the distance
  1888. */
  1889. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1890. /**
  1891. * Returns the squared distance between the vectors "value1" and "value2"
  1892. * @param value1 defines the first operand
  1893. * @param value2 defines the second operand
  1894. * @returns the squared distance
  1895. */
  1896. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1897. /**
  1898. * Returns a new Vector3 located at the center between "value1" and "value2"
  1899. * @param value1 defines the first operand
  1900. * @param value2 defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1906. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1907. * to something in order to rotate it from its local system to the given target system
  1908. * Note: axis1, axis2 and axis3 are normalized during this operation
  1909. * @param axis1 defines the first axis
  1910. * @param axis2 defines the second axis
  1911. * @param axis3 defines the third axis
  1912. * @returns a new Vector3
  1913. */
  1914. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1915. /**
  1916. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1917. * @param axis1 defines the first axis
  1918. * @param axis2 defines the second axis
  1919. * @param axis3 defines the third axis
  1920. * @param ref defines the Vector3 where to store the result
  1921. */
  1922. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1923. }
  1924. /**
  1925. * Vector4 class created for EulerAngle class conversion to Quaternion
  1926. */
  1927. export class Vector4 {
  1928. /** x value of the vector */
  1929. x: number;
  1930. /** y value of the vector */
  1931. y: number;
  1932. /** z value of the vector */
  1933. z: number;
  1934. /** w value of the vector */
  1935. w: number;
  1936. /**
  1937. * Creates a Vector4 object from the given floats.
  1938. * @param x x value of the vector
  1939. * @param y y value of the vector
  1940. * @param z z value of the vector
  1941. * @param w w value of the vector
  1942. */
  1943. constructor(
  1944. /** x value of the vector */
  1945. x: number,
  1946. /** y value of the vector */
  1947. y: number,
  1948. /** z value of the vector */
  1949. z: number,
  1950. /** w value of the vector */
  1951. w: number);
  1952. /**
  1953. * Returns the string with the Vector4 coordinates.
  1954. * @returns a string containing all the vector values
  1955. */
  1956. toString(): string;
  1957. /**
  1958. * Returns the string "Vector4".
  1959. * @returns "Vector4"
  1960. */
  1961. getClassName(): string;
  1962. /**
  1963. * Returns the Vector4 hash code.
  1964. * @returns a unique hash code
  1965. */
  1966. getHashCode(): number;
  1967. /**
  1968. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1969. * @returns the resulting array
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Populates the given array from the given index with the Vector4 coordinates.
  1974. * @param array array to populate
  1975. * @param index index of the array to start at (default: 0)
  1976. * @returns the Vector4.
  1977. */
  1978. toArray(array: FloatArray, index?: number): Vector4;
  1979. /**
  1980. * Adds the given vector to the current Vector4.
  1981. * @param otherVector the vector to add
  1982. * @returns the updated Vector4.
  1983. */
  1984. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1985. /**
  1986. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1987. * @param otherVector the vector to add
  1988. * @returns the resulting vector
  1989. */
  1990. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1991. /**
  1992. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1993. * @param otherVector the vector to add
  1994. * @param result the vector to store the result
  1995. * @returns the current Vector4.
  1996. */
  1997. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1998. /**
  1999. * Subtract in place the given vector from the current Vector4.
  2000. * @param otherVector the vector to subtract
  2001. * @returns the updated Vector4.
  2002. */
  2003. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2004. /**
  2005. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2006. * @param otherVector the vector to add
  2007. * @returns the new vector with the result
  2008. */
  2009. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2010. /**
  2011. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2012. * @param otherVector the vector to subtract
  2013. * @param result the vector to store the result
  2014. * @returns the current Vector4.
  2015. */
  2016. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. */
  2020. /**
  2021. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2022. * @param x value to subtract
  2023. * @param y value to subtract
  2024. * @param z value to subtract
  2025. * @param w value to subtract
  2026. * @returns new vector containing the result
  2027. */
  2028. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2029. /**
  2030. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2031. * @param x value to subtract
  2032. * @param y value to subtract
  2033. * @param z value to subtract
  2034. * @param w value to subtract
  2035. * @param result the vector to store the result in
  2036. * @returns the current Vector4.
  2037. */
  2038. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2039. /**
  2040. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2041. * @returns a new vector with the negated values
  2042. */
  2043. negate(): Vector4;
  2044. /**
  2045. * Multiplies the current Vector4 coordinates by scale (float).
  2046. * @param scale the number to scale with
  2047. * @returns the updated Vector4.
  2048. */
  2049. scaleInPlace(scale: number): Vector4;
  2050. /**
  2051. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2052. * @param scale the number to scale with
  2053. * @returns a new vector with the result
  2054. */
  2055. scale(scale: number): Vector4;
  2056. /**
  2057. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2058. * @param scale the number to scale with
  2059. * @param result a vector to store the result in
  2060. * @returns the current Vector4.
  2061. */
  2062. scaleToRef(scale: number, result: Vector4): Vector4;
  2063. /**
  2064. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2065. * @param scale defines the scale factor
  2066. * @param result defines the Vector4 object where to store the result
  2067. * @returns the unmodified current Vector4
  2068. */
  2069. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2070. /**
  2071. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2072. * @param otherVector the vector to compare against
  2073. * @returns true if they are equal
  2074. */
  2075. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2076. /**
  2077. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2078. * @param otherVector vector to compare against
  2079. * @param epsilon (Default: very small number)
  2080. * @returns true if they are equal
  2081. */
  2082. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2083. /**
  2084. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2085. * @param x x value to compare against
  2086. * @param y y value to compare against
  2087. * @param z z value to compare against
  2088. * @param w w value to compare against
  2089. * @returns true if equal
  2090. */
  2091. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2092. /**
  2093. * Multiplies in place the current Vector4 by the given one.
  2094. * @param otherVector vector to multiple with
  2095. * @returns the updated Vector4.
  2096. */
  2097. multiplyInPlace(otherVector: Vector4): Vector4;
  2098. /**
  2099. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2100. * @param otherVector vector to multiple with
  2101. * @returns resulting new vector
  2102. */
  2103. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2104. /**
  2105. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2106. * @param otherVector vector to multiple with
  2107. * @param result vector to store the result
  2108. * @returns the current Vector4.
  2109. */
  2110. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2111. /**
  2112. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2113. * @param x x value multiply with
  2114. * @param y y value multiply with
  2115. * @param z z value multiply with
  2116. * @param w w value multiply with
  2117. * @returns resulting new vector
  2118. */
  2119. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2120. /**
  2121. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2122. * @param otherVector vector to devide with
  2123. * @returns resulting new vector
  2124. */
  2125. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2126. /**
  2127. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2128. * @param otherVector vector to devide with
  2129. * @param result vector to store the result
  2130. * @returns the current Vector4.
  2131. */
  2132. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2133. /**
  2134. * Divides the current Vector3 coordinates by the given ones.
  2135. * @param otherVector vector to devide with
  2136. * @returns the updated Vector3.
  2137. */
  2138. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2139. /**
  2140. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2141. * @param other defines the second operand
  2142. * @returns the current updated Vector4
  2143. */
  2144. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2145. /**
  2146. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2147. * @param other defines the second operand
  2148. * @returns the current updated Vector4
  2149. */
  2150. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2151. /**
  2152. * Gets a new Vector4 from current Vector4 floored values
  2153. * @returns a new Vector4
  2154. */
  2155. floor(): Vector4;
  2156. /**
  2157. * Gets a new Vector4 from current Vector3 floored values
  2158. * @returns a new Vector4
  2159. */
  2160. fract(): Vector4;
  2161. /**
  2162. * Returns the Vector4 length (float).
  2163. * @returns the length
  2164. */
  2165. length(): number;
  2166. /**
  2167. * Returns the Vector4 squared length (float).
  2168. * @returns the length squared
  2169. */
  2170. lengthSquared(): number;
  2171. /**
  2172. * Normalizes in place the Vector4.
  2173. * @returns the updated Vector4.
  2174. */
  2175. normalize(): Vector4;
  2176. /**
  2177. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2178. * @returns this converted to a new vector3
  2179. */
  2180. toVector3(): Vector3;
  2181. /**
  2182. * Returns a new Vector4 copied from the current one.
  2183. * @returns the new cloned vector
  2184. */
  2185. clone(): Vector4;
  2186. /**
  2187. * Updates the current Vector4 with the given one coordinates.
  2188. * @param source the source vector to copy from
  2189. * @returns the updated Vector4.
  2190. */
  2191. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2192. /**
  2193. * Updates the current Vector4 coordinates with the given floats.
  2194. * @param x float to copy from
  2195. * @param y float to copy from
  2196. * @param z float to copy from
  2197. * @param w float to copy from
  2198. * @returns the updated Vector4.
  2199. */
  2200. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2201. /**
  2202. * Updates the current Vector4 coordinates with the given floats.
  2203. * @param x float to set from
  2204. * @param y float to set from
  2205. * @param z float to set from
  2206. * @param w float to set from
  2207. * @returns the updated Vector4.
  2208. */
  2209. set(x: number, y: number, z: number, w: number): Vector4;
  2210. /**
  2211. * Copies the given float to the current Vector3 coordinates
  2212. * @param v defines the x, y, z and w coordinates of the operand
  2213. * @returns the current updated Vector3
  2214. */
  2215. setAll(v: number): Vector4;
  2216. /**
  2217. * Returns a new Vector4 set from the starting index of the given array.
  2218. * @param array the array to pull values from
  2219. * @param offset the offset into the array to start at
  2220. * @returns the new vector
  2221. */
  2222. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2223. /**
  2224. * Updates the given vector "result" from the starting index of the given array.
  2225. * @param array the array to pull values from
  2226. * @param offset the offset into the array to start at
  2227. * @param result the vector to store the result in
  2228. */
  2229. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2230. /**
  2231. * Updates the given vector "result" from the starting index of the given Float32Array.
  2232. * @param array the array to pull values from
  2233. * @param offset the offset into the array to start at
  2234. * @param result the vector to store the result in
  2235. */
  2236. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2237. /**
  2238. * Updates the given vector "result" coordinates from the given floats.
  2239. * @param x float to set from
  2240. * @param y float to set from
  2241. * @param z float to set from
  2242. * @param w float to set from
  2243. * @param result the vector to the floats in
  2244. */
  2245. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2246. /**
  2247. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2248. * @returns the new vector
  2249. */
  2250. static Zero(): Vector4;
  2251. /**
  2252. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2253. * @returns the new vector
  2254. */
  2255. static One(): Vector4;
  2256. /**
  2257. * Returns a new normalized Vector4 from the given one.
  2258. * @param vector the vector to normalize
  2259. * @returns the vector
  2260. */
  2261. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2262. /**
  2263. * Updates the given vector "result" from the normalization of the given one.
  2264. * @param vector the vector to normalize
  2265. * @param result the vector to store the result in
  2266. */
  2267. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2268. /**
  2269. * Returns a vector with the minimum values from the left and right vectors
  2270. * @param left left vector to minimize
  2271. * @param right right vector to minimize
  2272. * @returns a new vector with the minimum of the left and right vector values
  2273. */
  2274. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2275. /**
  2276. * Returns a vector with the maximum values from the left and right vectors
  2277. * @param left left vector to maximize
  2278. * @param right right vector to maximize
  2279. * @returns a new vector with the maximum of the left and right vector values
  2280. */
  2281. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2282. /**
  2283. * Returns the distance (float) between the vectors "value1" and "value2".
  2284. * @param value1 value to calulate the distance between
  2285. * @param value2 value to calulate the distance between
  2286. * @return the distance between the two vectors
  2287. */
  2288. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2289. /**
  2290. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2291. * @param value1 value to calulate the distance between
  2292. * @param value2 value to calulate the distance between
  2293. * @return the distance between the two vectors squared
  2294. */
  2295. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2296. /**
  2297. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2298. * @param value1 value to calulate the center between
  2299. * @param value2 value to calulate the center between
  2300. * @return the center between the two vectors
  2301. */
  2302. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2305. * This methods computes transformed normalized direction vectors only.
  2306. * @param vector the vector to transform
  2307. * @param transformation the transformation matrix to apply
  2308. * @returns the new vector
  2309. */
  2310. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2311. /**
  2312. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2313. * This methods computes transformed normalized direction vectors only.
  2314. * @param vector the vector to transform
  2315. * @param transformation the transformation matrix to apply
  2316. * @param result the vector to store the result in
  2317. */
  2318. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2319. /**
  2320. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2321. * This methods computes transformed normalized direction vectors only.
  2322. * @param x value to transform
  2323. * @param y value to transform
  2324. * @param z value to transform
  2325. * @param w value to transform
  2326. * @param transformation the transformation matrix to apply
  2327. * @param result the vector to store the results in
  2328. */
  2329. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2330. /**
  2331. * Creates a new Vector4 from a Vector3
  2332. * @param source defines the source data
  2333. * @param w defines the 4th component (default is 0)
  2334. * @returns a new Vector4
  2335. */
  2336. static FromVector3(source: Vector3, w?: number): Vector4;
  2337. }
  2338. /**
  2339. * Interface for the size containing width and height
  2340. */
  2341. export interface ISize {
  2342. /**
  2343. * Width
  2344. */
  2345. width: number;
  2346. /**
  2347. * Heighht
  2348. */
  2349. height: number;
  2350. }
  2351. /**
  2352. * Size containing widht and height
  2353. */
  2354. export class Size implements ISize {
  2355. /**
  2356. * Width
  2357. */
  2358. width: number;
  2359. /**
  2360. * Height
  2361. */
  2362. height: number;
  2363. /**
  2364. * Creates a Size object from the given width and height (floats).
  2365. * @param width width of the new size
  2366. * @param height height of the new size
  2367. */
  2368. constructor(width: number, height: number);
  2369. /**
  2370. * Returns a string with the Size width and height
  2371. * @returns a string with the Size width and height
  2372. */
  2373. toString(): string;
  2374. /**
  2375. * "Size"
  2376. * @returns the string "Size"
  2377. */
  2378. getClassName(): string;
  2379. /**
  2380. * Returns the Size hash code.
  2381. * @returns a hash code for a unique width and height
  2382. */
  2383. getHashCode(): number;
  2384. /**
  2385. * Updates the current size from the given one.
  2386. * @param src the given size
  2387. */
  2388. copyFrom(src: Size): void;
  2389. /**
  2390. * Updates in place the current Size from the given floats.
  2391. * @param width width of the new size
  2392. * @param height height of the new size
  2393. * @returns the updated Size.
  2394. */
  2395. copyFromFloats(width: number, height: number): Size;
  2396. /**
  2397. * Updates in place the current Size from the given floats.
  2398. * @param width width to set
  2399. * @param height height to set
  2400. * @returns the updated Size.
  2401. */
  2402. set(width: number, height: number): Size;
  2403. /**
  2404. * Multiplies the width and height by numbers
  2405. * @param w factor to multiple the width by
  2406. * @param h factor to multiple the height by
  2407. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2408. */
  2409. multiplyByFloats(w: number, h: number): Size;
  2410. /**
  2411. * Clones the size
  2412. * @returns a new Size copied from the given one.
  2413. */
  2414. clone(): Size;
  2415. /**
  2416. * True if the current Size and the given one width and height are strictly equal.
  2417. * @param other the other size to compare against
  2418. * @returns True if the current Size and the given one width and height are strictly equal.
  2419. */
  2420. equals(other: Size): boolean;
  2421. /**
  2422. * The surface of the Size : width * height (float).
  2423. */
  2424. readonly surface: number;
  2425. /**
  2426. * Create a new size of zero
  2427. * @returns a new Size set to (0.0, 0.0)
  2428. */
  2429. static Zero(): Size;
  2430. /**
  2431. * Sums the width and height of two sizes
  2432. * @param otherSize size to add to this size
  2433. * @returns a new Size set as the addition result of the current Size and the given one.
  2434. */
  2435. add(otherSize: Size): Size;
  2436. /**
  2437. * Subtracts the width and height of two
  2438. * @param otherSize size to subtract to this size
  2439. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2440. */
  2441. subtract(otherSize: Size): Size;
  2442. /**
  2443. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2444. * @param start starting size to lerp between
  2445. * @param end end size to lerp between
  2446. * @param amount amount to lerp between the start and end values
  2447. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2448. */
  2449. static Lerp(start: Size, end: Size, amount: number): Size;
  2450. }
  2451. /**
  2452. * Class used to store quaternion data
  2453. * @see https://en.wikipedia.org/wiki/Quaternion
  2454. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2455. */
  2456. export class Quaternion {
  2457. /** defines the first component (0 by default) */
  2458. x: number;
  2459. /** defines the second component (0 by default) */
  2460. y: number;
  2461. /** defines the third component (0 by default) */
  2462. z: number;
  2463. /** defines the fourth component (1.0 by default) */
  2464. w: number;
  2465. /**
  2466. * Creates a new Quaternion from the given floats
  2467. * @param x defines the first component (0 by default)
  2468. * @param y defines the second component (0 by default)
  2469. * @param z defines the third component (0 by default)
  2470. * @param w defines the fourth component (1.0 by default)
  2471. */
  2472. constructor(
  2473. /** defines the first component (0 by default) */
  2474. x?: number,
  2475. /** defines the second component (0 by default) */
  2476. y?: number,
  2477. /** defines the third component (0 by default) */
  2478. z?: number,
  2479. /** defines the fourth component (1.0 by default) */
  2480. w?: number);
  2481. /**
  2482. * Gets a string representation for the current quaternion
  2483. * @returns a string with the Quaternion coordinates
  2484. */
  2485. toString(): string;
  2486. /**
  2487. * Gets the class name of the quaternion
  2488. * @returns the string "Quaternion"
  2489. */
  2490. getClassName(): string;
  2491. /**
  2492. * Gets a hash code for this quaternion
  2493. * @returns the quaternion hash code
  2494. */
  2495. getHashCode(): number;
  2496. /**
  2497. * Copy the quaternion to an array
  2498. * @returns a new array populated with 4 elements from the quaternion coordinates
  2499. */
  2500. asArray(): number[];
  2501. /**
  2502. * Check if two quaternions are equals
  2503. * @param otherQuaternion defines the second operand
  2504. * @return true if the current quaternion and the given one coordinates are strictly equals
  2505. */
  2506. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2507. /**
  2508. * Clone the current quaternion
  2509. * @returns a new quaternion copied from the current one
  2510. */
  2511. clone(): Quaternion;
  2512. /**
  2513. * Copy a quaternion to the current one
  2514. * @param other defines the other quaternion
  2515. * @returns the updated current quaternion
  2516. */
  2517. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2518. /**
  2519. * Updates the current quaternion with the given float coordinates
  2520. * @param x defines the x coordinate
  2521. * @param y defines the y coordinate
  2522. * @param z defines the z coordinate
  2523. * @param w defines the w coordinate
  2524. * @returns the updated current quaternion
  2525. */
  2526. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2527. /**
  2528. * Updates the current quaternion from the given float coordinates
  2529. * @param x defines the x coordinate
  2530. * @param y defines the y coordinate
  2531. * @param z defines the z coordinate
  2532. * @param w defines the w coordinate
  2533. * @returns the updated current quaternion
  2534. */
  2535. set(x: number, y: number, z: number, w: number): Quaternion;
  2536. /**
  2537. * Adds two quaternions
  2538. * @param other defines the second operand
  2539. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2540. */
  2541. add(other: DeepImmutable<Quaternion>): Quaternion;
  2542. /**
  2543. * Add a quaternion to the current one
  2544. * @param other defines the quaternion to add
  2545. * @returns the current quaternion
  2546. */
  2547. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2548. /**
  2549. * Subtract two quaternions
  2550. * @param other defines the second operand
  2551. * @returns a new quaternion as the subtraction result of the given one from the current one
  2552. */
  2553. subtract(other: Quaternion): Quaternion;
  2554. /**
  2555. * Multiplies the current quaternion by a scale factor
  2556. * @param value defines the scale factor
  2557. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2558. */
  2559. scale(value: number): Quaternion;
  2560. /**
  2561. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2562. * @param scale defines the scale factor
  2563. * @param result defines the Quaternion object where to store the result
  2564. * @returns the unmodified current quaternion
  2565. */
  2566. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2567. /**
  2568. * Multiplies in place the current quaternion by a scale factor
  2569. * @param value defines the scale factor
  2570. * @returns the current modified quaternion
  2571. */
  2572. scaleInPlace(value: number): Quaternion;
  2573. /**
  2574. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2575. * @param scale defines the scale factor
  2576. * @param result defines the Quaternion object where to store the result
  2577. * @returns the unmodified current quaternion
  2578. */
  2579. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2580. /**
  2581. * Multiplies two quaternions
  2582. * @param q1 defines the second operand
  2583. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2584. */
  2585. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2586. /**
  2587. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2588. * @param q1 defines the second operand
  2589. * @param result defines the target quaternion
  2590. * @returns the current quaternion
  2591. */
  2592. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2593. /**
  2594. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2595. * @param q1 defines the second operand
  2596. * @returns the currentupdated quaternion
  2597. */
  2598. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2599. /**
  2600. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2601. * @param ref defines the target quaternion
  2602. * @returns the current quaternion
  2603. */
  2604. conjugateToRef(ref: Quaternion): Quaternion;
  2605. /**
  2606. * Conjugates in place (1-q) the current quaternion
  2607. * @returns the current updated quaternion
  2608. */
  2609. conjugateInPlace(): Quaternion;
  2610. /**
  2611. * Conjugates in place (1-q) the current quaternion
  2612. * @returns a new quaternion
  2613. */
  2614. conjugate(): Quaternion;
  2615. /**
  2616. * Gets length of current quaternion
  2617. * @returns the quaternion length (float)
  2618. */
  2619. length(): number;
  2620. /**
  2621. * Normalize in place the current quaternion
  2622. * @returns the current updated quaternion
  2623. */
  2624. normalize(): Quaternion;
  2625. /**
  2626. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2627. * @param order is a reserved parameter and is ignore for now
  2628. * @returns a new Vector3 containing the Euler angles
  2629. */
  2630. toEulerAngles(order?: string): Vector3;
  2631. /**
  2632. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2633. * @param result defines the vector which will be filled with the Euler angles
  2634. * @param order is a reserved parameter and is ignore for now
  2635. * @returns the current unchanged quaternion
  2636. */
  2637. toEulerAnglesToRef(result: Vector3): Quaternion;
  2638. /**
  2639. * Updates the given rotation matrix with the current quaternion values
  2640. * @param result defines the target matrix
  2641. * @returns the current unchanged quaternion
  2642. */
  2643. toRotationMatrix(result: Matrix): Quaternion;
  2644. /**
  2645. * Updates the current quaternion from the given rotation matrix values
  2646. * @param matrix defines the source matrix
  2647. * @returns the current updated quaternion
  2648. */
  2649. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2650. /**
  2651. * Creates a new quaternion from a rotation matrix
  2652. * @param matrix defines the source matrix
  2653. * @returns a new quaternion created from the given rotation matrix values
  2654. */
  2655. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2656. /**
  2657. * Updates the given quaternion with the given rotation matrix values
  2658. * @param matrix defines the source matrix
  2659. * @param result defines the target quaternion
  2660. */
  2661. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2662. /**
  2663. * Returns the dot product (float) between the quaternions "left" and "right"
  2664. * @param left defines the left operand
  2665. * @param right defines the right operand
  2666. * @returns the dot product
  2667. */
  2668. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2669. /**
  2670. * Checks if the two quaternions are close to each other
  2671. * @param quat0 defines the first quaternion to check
  2672. * @param quat1 defines the second quaternion to check
  2673. * @returns true if the two quaternions are close to each other
  2674. */
  2675. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2676. /**
  2677. * Creates an empty quaternion
  2678. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2679. */
  2680. static Zero(): Quaternion;
  2681. /**
  2682. * Inverse a given quaternion
  2683. * @param q defines the source quaternion
  2684. * @returns a new quaternion as the inverted current quaternion
  2685. */
  2686. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2687. /**
  2688. * Inverse a given quaternion
  2689. * @param q defines the source quaternion
  2690. * @param result the quaternion the result will be stored in
  2691. * @returns the result quaternion
  2692. */
  2693. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2694. /**
  2695. * Creates an identity quaternion
  2696. * @returns the identity quaternion
  2697. */
  2698. static Identity(): Quaternion;
  2699. /**
  2700. * Gets a boolean indicating if the given quaternion is identity
  2701. * @param quaternion defines the quaternion to check
  2702. * @returns true if the quaternion is identity
  2703. */
  2704. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2705. /**
  2706. * Creates a quaternion from a rotation around an axis
  2707. * @param axis defines the axis to use
  2708. * @param angle defines the angle to use
  2709. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2710. */
  2711. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2712. /**
  2713. * Creates a rotation around an axis and stores it into the given quaternion
  2714. * @param axis defines the axis to use
  2715. * @param angle defines the angle to use
  2716. * @param result defines the target quaternion
  2717. * @returns the target quaternion
  2718. */
  2719. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2720. /**
  2721. * Creates a new quaternion from data stored into an array
  2722. * @param array defines the data source
  2723. * @param offset defines the offset in the source array where the data starts
  2724. * @returns a new quaternion
  2725. */
  2726. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2727. /**
  2728. * Create a quaternion from Euler rotation angles
  2729. * @param x Pitch
  2730. * @param y Yaw
  2731. * @param z Roll
  2732. * @returns the new Quaternion
  2733. */
  2734. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2735. /**
  2736. * Updates a quaternion from Euler rotation angles
  2737. * @param x Pitch
  2738. * @param y Yaw
  2739. * @param z Roll
  2740. * @param result the quaternion to store the result
  2741. * @returns the updated quaternion
  2742. */
  2743. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2744. /**
  2745. * Create a quaternion from Euler rotation vector
  2746. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2747. * @returns the new Quaternion
  2748. */
  2749. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2750. /**
  2751. * Updates a quaternion from Euler rotation vector
  2752. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2753. * @param result the quaternion to store the result
  2754. * @returns the updated quaternion
  2755. */
  2756. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2757. /**
  2758. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2759. * @param yaw defines the rotation around Y axis
  2760. * @param pitch defines the rotation around X axis
  2761. * @param roll defines the rotation around Z axis
  2762. * @returns the new quaternion
  2763. */
  2764. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2765. /**
  2766. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2767. * @param yaw defines the rotation around Y axis
  2768. * @param pitch defines the rotation around X axis
  2769. * @param roll defines the rotation around Z axis
  2770. * @param result defines the target quaternion
  2771. */
  2772. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2773. /**
  2774. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2775. * @param alpha defines the rotation around first axis
  2776. * @param beta defines the rotation around second axis
  2777. * @param gamma defines the rotation around third axis
  2778. * @returns the new quaternion
  2779. */
  2780. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2781. /**
  2782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2783. * @param alpha defines the rotation around first axis
  2784. * @param beta defines the rotation around second axis
  2785. * @param gamma defines the rotation around third axis
  2786. * @param result defines the target quaternion
  2787. */
  2788. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2789. /**
  2790. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2791. * @param axis1 defines the first axis
  2792. * @param axis2 defines the second axis
  2793. * @param axis3 defines the third axis
  2794. * @returns the new quaternion
  2795. */
  2796. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2797. /**
  2798. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2799. * @param axis1 defines the first axis
  2800. * @param axis2 defines the second axis
  2801. * @param axis3 defines the third axis
  2802. * @param ref defines the target quaternion
  2803. */
  2804. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2805. /**
  2806. * Interpolates between two quaternions
  2807. * @param left defines first quaternion
  2808. * @param right defines second quaternion
  2809. * @param amount defines the gradient to use
  2810. * @returns the new interpolated quaternion
  2811. */
  2812. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2813. /**
  2814. * Interpolates between two quaternions and stores it into a target quaternion
  2815. * @param left defines first quaternion
  2816. * @param right defines second quaternion
  2817. * @param amount defines the gradient to use
  2818. * @param result defines the target quaternion
  2819. */
  2820. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2821. /**
  2822. * Interpolate between two quaternions using Hermite interpolation
  2823. * @param value1 defines first quaternion
  2824. * @param tangent1 defines the incoming tangent
  2825. * @param value2 defines second quaternion
  2826. * @param tangent2 defines the outgoing tangent
  2827. * @param amount defines the target quaternion
  2828. * @returns the new interpolated quaternion
  2829. */
  2830. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2831. }
  2832. /**
  2833. * Class used to store matrix data (4x4)
  2834. */
  2835. export class Matrix {
  2836. private static _updateFlagSeed;
  2837. private static _identityReadOnly;
  2838. private _isIdentity;
  2839. private _isIdentityDirty;
  2840. private _isIdentity3x2;
  2841. private _isIdentity3x2Dirty;
  2842. /**
  2843. * Gets the update flag of the matrix which is an unique number for the matrix.
  2844. * It will be incremented every time the matrix data change.
  2845. * You can use it to speed the comparison between two versions of the same matrix.
  2846. */
  2847. updateFlag: number;
  2848. private readonly _m;
  2849. /**
  2850. * Gets the internal data of the matrix
  2851. */
  2852. readonly m: DeepImmutable<Float32Array>;
  2853. /** @hidden */
  2854. _markAsUpdated(): void;
  2855. /** @hidden */
  2856. private _updateIdentityStatus;
  2857. /**
  2858. * Creates an empty matrix (filled with zeros)
  2859. */
  2860. constructor();
  2861. /**
  2862. * Check if the current matrix is identity
  2863. * @returns true is the matrix is the identity matrix
  2864. */
  2865. isIdentity(): boolean;
  2866. /**
  2867. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2868. * @returns true is the matrix is the identity matrix
  2869. */
  2870. isIdentityAs3x2(): boolean;
  2871. /**
  2872. * Gets the determinant of the matrix
  2873. * @returns the matrix determinant
  2874. */
  2875. determinant(): number;
  2876. /**
  2877. * Returns the matrix as a Float32Array
  2878. * @returns the matrix underlying array
  2879. */
  2880. toArray(): DeepImmutable<Float32Array>;
  2881. /**
  2882. * Returns the matrix as a Float32Array
  2883. * @returns the matrix underlying array.
  2884. */
  2885. asArray(): DeepImmutable<Float32Array>;
  2886. /**
  2887. * Inverts the current matrix in place
  2888. * @returns the current inverted matrix
  2889. */
  2890. invert(): Matrix;
  2891. /**
  2892. * Sets all the matrix elements to zero
  2893. * @returns the current matrix
  2894. */
  2895. reset(): Matrix;
  2896. /**
  2897. * Adds the current matrix with a second one
  2898. * @param other defines the matrix to add
  2899. * @returns a new matrix as the addition of the current matrix and the given one
  2900. */
  2901. add(other: DeepImmutable<Matrix>): Matrix;
  2902. /**
  2903. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2904. * @param other defines the matrix to add
  2905. * @param result defines the target matrix
  2906. * @returns the current matrix
  2907. */
  2908. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2909. /**
  2910. * Adds in place the given matrix to the current matrix
  2911. * @param other defines the second operand
  2912. * @returns the current updated matrix
  2913. */
  2914. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2915. /**
  2916. * Sets the given matrix to the current inverted Matrix
  2917. * @param other defines the target matrix
  2918. * @returns the unmodified current matrix
  2919. */
  2920. invertToRef(other: Matrix): Matrix;
  2921. /**
  2922. * add a value at the specified position in the current Matrix
  2923. * @param index the index of the value within the matrix. between 0 and 15.
  2924. * @param value the value to be added
  2925. * @returns the current updated matrix
  2926. */
  2927. addAtIndex(index: number, value: number): Matrix;
  2928. /**
  2929. * mutiply the specified position in the current Matrix by a value
  2930. * @param index the index of the value within the matrix. between 0 and 15.
  2931. * @param value the value to be added
  2932. * @returns the current updated matrix
  2933. */
  2934. multiplyAtIndex(index: number, value: number): Matrix;
  2935. /**
  2936. * Inserts the translation vector (using 3 floats) in the current matrix
  2937. * @param x defines the 1st component of the translation
  2938. * @param y defines the 2nd component of the translation
  2939. * @param z defines the 3rd component of the translation
  2940. * @returns the current updated matrix
  2941. */
  2942. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2943. /**
  2944. * Adds the translation vector (using 3 floats) in the current matrix
  2945. * @param x defines the 1st component of the translation
  2946. * @param y defines the 2nd component of the translation
  2947. * @param z defines the 3rd component of the translation
  2948. * @returns the current updated matrix
  2949. */
  2950. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2951. /**
  2952. * Inserts the translation vector in the current matrix
  2953. * @param vector3 defines the translation to insert
  2954. * @returns the current updated matrix
  2955. */
  2956. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2957. /**
  2958. * Gets the translation value of the current matrix
  2959. * @returns a new Vector3 as the extracted translation from the matrix
  2960. */
  2961. getTranslation(): Vector3;
  2962. /**
  2963. * Fill a Vector3 with the extracted translation from the matrix
  2964. * @param result defines the Vector3 where to store the translation
  2965. * @returns the current matrix
  2966. */
  2967. getTranslationToRef(result: Vector3): Matrix;
  2968. /**
  2969. * Remove rotation and scaling part from the matrix
  2970. * @returns the updated matrix
  2971. */
  2972. removeRotationAndScaling(): Matrix;
  2973. /**
  2974. * Multiply two matrices
  2975. * @param other defines the second operand
  2976. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2977. */
  2978. multiply(other: DeepImmutable<Matrix>): Matrix;
  2979. /**
  2980. * Copy the current matrix from the given one
  2981. * @param other defines the source matrix
  2982. * @returns the current updated matrix
  2983. */
  2984. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2985. /**
  2986. * Populates the given array from the starting index with the current matrix values
  2987. * @param array defines the target array
  2988. * @param offset defines the offset in the target array where to start storing values
  2989. * @returns the current matrix
  2990. */
  2991. copyToArray(array: Float32Array, offset?: number): Matrix;
  2992. /**
  2993. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2994. * @param other defines the second operand
  2995. * @param result defines the matrix where to store the multiplication
  2996. * @returns the current matrix
  2997. */
  2998. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2999. /**
  3000. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3001. * @param other defines the second operand
  3002. * @param result defines the array where to store the multiplication
  3003. * @param offset defines the offset in the target array where to start storing values
  3004. * @returns the current matrix
  3005. */
  3006. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3007. /**
  3008. * Check equality between this matrix and a second one
  3009. * @param value defines the second matrix to compare
  3010. * @returns true is the current matrix and the given one values are strictly equal
  3011. */
  3012. equals(value: DeepImmutable<Matrix>): boolean;
  3013. /**
  3014. * Clone the current matrix
  3015. * @returns a new matrix from the current matrix
  3016. */
  3017. clone(): Matrix;
  3018. /**
  3019. * Returns the name of the current matrix class
  3020. * @returns the string "Matrix"
  3021. */
  3022. getClassName(): string;
  3023. /**
  3024. * Gets the hash code of the current matrix
  3025. * @returns the hash code
  3026. */
  3027. getHashCode(): number;
  3028. /**
  3029. * Decomposes the current Matrix into a translation, rotation and scaling components
  3030. * @param scale defines the scale vector3 given as a reference to update
  3031. * @param rotation defines the rotation quaternion given as a reference to update
  3032. * @param translation defines the translation vector3 given as a reference to update
  3033. * @returns true if operation was successful
  3034. */
  3035. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3036. /**
  3037. * Gets specific row of the matrix
  3038. * @param index defines the number of the row to get
  3039. * @returns the index-th row of the current matrix as a new Vector4
  3040. */
  3041. getRow(index: number): Nullable<Vector4>;
  3042. /**
  3043. * Sets the index-th row of the current matrix to the vector4 values
  3044. * @param index defines the number of the row to set
  3045. * @param row defines the target vector4
  3046. * @returns the updated current matrix
  3047. */
  3048. setRow(index: number, row: Vector4): Matrix;
  3049. /**
  3050. * Compute the transpose of the matrix
  3051. * @returns the new transposed matrix
  3052. */
  3053. transpose(): Matrix;
  3054. /**
  3055. * Compute the transpose of the matrix and store it in a given matrix
  3056. * @param result defines the target matrix
  3057. * @returns the current matrix
  3058. */
  3059. transposeToRef(result: Matrix): Matrix;
  3060. /**
  3061. * Sets the index-th row of the current matrix with the given 4 x float values
  3062. * @param index defines the row index
  3063. * @param x defines the x component to set
  3064. * @param y defines the y component to set
  3065. * @param z defines the z component to set
  3066. * @param w defines the w component to set
  3067. * @returns the updated current matrix
  3068. */
  3069. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3070. /**
  3071. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3072. * @param scale defines the scale factor
  3073. * @returns a new matrix
  3074. */
  3075. scale(scale: number): Matrix;
  3076. /**
  3077. * Scale the current matrix values by a factor to a given result matrix
  3078. * @param scale defines the scale factor
  3079. * @param result defines the matrix to store the result
  3080. * @returns the current matrix
  3081. */
  3082. scaleToRef(scale: number, result: Matrix): Matrix;
  3083. /**
  3084. * Scale the current matrix values by a factor and add the result to a given matrix
  3085. * @param scale defines the scale factor
  3086. * @param result defines the Matrix to store the result
  3087. * @returns the current matrix
  3088. */
  3089. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3090. /**
  3091. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3092. * @param ref matrix to store the result
  3093. */
  3094. toNormalMatrix(ref: Matrix): void;
  3095. /**
  3096. * Gets only rotation part of the current matrix
  3097. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3098. */
  3099. getRotationMatrix(): Matrix;
  3100. /**
  3101. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3102. * @param result defines the target matrix to store data to
  3103. * @returns the current matrix
  3104. */
  3105. getRotationMatrixToRef(result: Matrix): Matrix;
  3106. /**
  3107. * Toggles model matrix from being right handed to left handed in place and vice versa
  3108. */
  3109. toggleModelMatrixHandInPlace(): void;
  3110. /**
  3111. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3112. */
  3113. toggleProjectionMatrixHandInPlace(): void;
  3114. /**
  3115. * Creates a matrix from an array
  3116. * @param array defines the source array
  3117. * @param offset defines an offset in the source array
  3118. * @returns a new Matrix set from the starting index of the given array
  3119. */
  3120. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3121. /**
  3122. * Copy the content of an array into a given matrix
  3123. * @param array defines the source array
  3124. * @param offset defines an offset in the source array
  3125. * @param result defines the target matrix
  3126. */
  3127. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3128. /**
  3129. * Stores an array into a matrix after having multiplied each component by a given factor
  3130. * @param array defines the source array
  3131. * @param offset defines the offset in the source array
  3132. * @param scale defines the scaling factor
  3133. * @param result defines the target matrix
  3134. */
  3135. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3136. /**
  3137. * Gets an identity matrix that must not be updated
  3138. */
  3139. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3140. /**
  3141. * Stores a list of values (16) inside a given matrix
  3142. * @param initialM11 defines 1st value of 1st row
  3143. * @param initialM12 defines 2nd value of 1st row
  3144. * @param initialM13 defines 3rd value of 1st row
  3145. * @param initialM14 defines 4th value of 1st row
  3146. * @param initialM21 defines 1st value of 2nd row
  3147. * @param initialM22 defines 2nd value of 2nd row
  3148. * @param initialM23 defines 3rd value of 2nd row
  3149. * @param initialM24 defines 4th value of 2nd row
  3150. * @param initialM31 defines 1st value of 3rd row
  3151. * @param initialM32 defines 2nd value of 3rd row
  3152. * @param initialM33 defines 3rd value of 3rd row
  3153. * @param initialM34 defines 4th value of 3rd row
  3154. * @param initialM41 defines 1st value of 4th row
  3155. * @param initialM42 defines 2nd value of 4th row
  3156. * @param initialM43 defines 3rd value of 4th row
  3157. * @param initialM44 defines 4th value of 4th row
  3158. * @param result defines the target matrix
  3159. */
  3160. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3161. /**
  3162. * Creates new matrix from a list of values (16)
  3163. * @param initialM11 defines 1st value of 1st row
  3164. * @param initialM12 defines 2nd value of 1st row
  3165. * @param initialM13 defines 3rd value of 1st row
  3166. * @param initialM14 defines 4th value of 1st row
  3167. * @param initialM21 defines 1st value of 2nd row
  3168. * @param initialM22 defines 2nd value of 2nd row
  3169. * @param initialM23 defines 3rd value of 2nd row
  3170. * @param initialM24 defines 4th value of 2nd row
  3171. * @param initialM31 defines 1st value of 3rd row
  3172. * @param initialM32 defines 2nd value of 3rd row
  3173. * @param initialM33 defines 3rd value of 3rd row
  3174. * @param initialM34 defines 4th value of 3rd row
  3175. * @param initialM41 defines 1st value of 4th row
  3176. * @param initialM42 defines 2nd value of 4th row
  3177. * @param initialM43 defines 3rd value of 4th row
  3178. * @param initialM44 defines 4th value of 4th row
  3179. * @returns the new matrix
  3180. */
  3181. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3182. /**
  3183. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3184. * @param scale defines the scale vector3
  3185. * @param rotation defines the rotation quaternion
  3186. * @param translation defines the translation vector3
  3187. * @returns a new matrix
  3188. */
  3189. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3190. /**
  3191. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3192. * @param scale defines the scale vector3
  3193. * @param rotation defines the rotation quaternion
  3194. * @param translation defines the translation vector3
  3195. * @param result defines the target matrix
  3196. */
  3197. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3198. /**
  3199. * Creates a new identity matrix
  3200. * @returns a new identity matrix
  3201. */
  3202. static Identity(): Matrix;
  3203. /**
  3204. * Creates a new identity matrix and stores the result in a given matrix
  3205. * @param result defines the target matrix
  3206. */
  3207. static IdentityToRef(result: Matrix): void;
  3208. /**
  3209. * Creates a new zero matrix
  3210. * @returns a new zero matrix
  3211. */
  3212. static Zero(): Matrix;
  3213. /**
  3214. * Creates a new rotation matrix for "angle" radians around the X axis
  3215. * @param angle defines the angle (in radians) to use
  3216. * @return the new matrix
  3217. */
  3218. static RotationX(angle: number): Matrix;
  3219. /**
  3220. * Creates a new matrix as the invert of a given matrix
  3221. * @param source defines the source matrix
  3222. * @returns the new matrix
  3223. */
  3224. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3225. /**
  3226. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3227. * @param angle defines the angle (in radians) to use
  3228. * @param result defines the target matrix
  3229. */
  3230. static RotationXToRef(angle: number, result: Matrix): void;
  3231. /**
  3232. * Creates a new rotation matrix for "angle" radians around the Y axis
  3233. * @param angle defines the angle (in radians) to use
  3234. * @return the new matrix
  3235. */
  3236. static RotationY(angle: number): Matrix;
  3237. /**
  3238. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3239. * @param angle defines the angle (in radians) to use
  3240. * @param result defines the target matrix
  3241. */
  3242. static RotationYToRef(angle: number, result: Matrix): void;
  3243. /**
  3244. * Creates a new rotation matrix for "angle" radians around the Z axis
  3245. * @param angle defines the angle (in radians) to use
  3246. * @return the new matrix
  3247. */
  3248. static RotationZ(angle: number): Matrix;
  3249. /**
  3250. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3251. * @param angle defines the angle (in radians) to use
  3252. * @param result defines the target matrix
  3253. */
  3254. static RotationZToRef(angle: number, result: Matrix): void;
  3255. /**
  3256. * Creates a new rotation matrix for "angle" radians around the given axis
  3257. * @param axis defines the axis to use
  3258. * @param angle defines the angle (in radians) to use
  3259. * @return the new matrix
  3260. */
  3261. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3262. /**
  3263. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3264. * @param axis defines the axis to use
  3265. * @param angle defines the angle (in radians) to use
  3266. * @param result defines the target matrix
  3267. */
  3268. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3269. /**
  3270. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3271. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3272. * @param from defines the vector to align
  3273. * @param to defines the vector to align to
  3274. * @param result defines the target matrix
  3275. */
  3276. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3277. /**
  3278. * Creates a rotation matrix
  3279. * @param yaw defines the yaw angle in radians (Y axis)
  3280. * @param pitch defines the pitch angle in radians (X axis)
  3281. * @param roll defines the roll angle in radians (X axis)
  3282. * @returns the new rotation matrix
  3283. */
  3284. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3285. /**
  3286. * Creates a rotation matrix and stores it in a given matrix
  3287. * @param yaw defines the yaw angle in radians (Y axis)
  3288. * @param pitch defines the pitch angle in radians (X axis)
  3289. * @param roll defines the roll angle in radians (X axis)
  3290. * @param result defines the target matrix
  3291. */
  3292. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3293. /**
  3294. * Creates a scaling matrix
  3295. * @param x defines the scale factor on X axis
  3296. * @param y defines the scale factor on Y axis
  3297. * @param z defines the scale factor on Z axis
  3298. * @returns the new matrix
  3299. */
  3300. static Scaling(x: number, y: number, z: number): Matrix;
  3301. /**
  3302. * Creates a scaling matrix and stores it in a given matrix
  3303. * @param x defines the scale factor on X axis
  3304. * @param y defines the scale factor on Y axis
  3305. * @param z defines the scale factor on Z axis
  3306. * @param result defines the target matrix
  3307. */
  3308. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3309. /**
  3310. * Creates a translation matrix
  3311. * @param x defines the translation on X axis
  3312. * @param y defines the translation on Y axis
  3313. * @param z defines the translationon Z axis
  3314. * @returns the new matrix
  3315. */
  3316. static Translation(x: number, y: number, z: number): Matrix;
  3317. /**
  3318. * Creates a translation matrix and stores it in a given matrix
  3319. * @param x defines the translation on X axis
  3320. * @param y defines the translation on Y axis
  3321. * @param z defines the translationon Z axis
  3322. * @param result defines the target matrix
  3323. */
  3324. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3325. /**
  3326. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3327. * @param startValue defines the start value
  3328. * @param endValue defines the end value
  3329. * @param gradient defines the gradient factor
  3330. * @returns the new matrix
  3331. */
  3332. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3333. /**
  3334. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3335. * @param startValue defines the start value
  3336. * @param endValue defines the end value
  3337. * @param gradient defines the gradient factor
  3338. * @param result defines the Matrix object where to store data
  3339. */
  3340. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3341. /**
  3342. * Builds a new matrix whose values are computed by:
  3343. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3344. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3345. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3346. * @param startValue defines the first matrix
  3347. * @param endValue defines the second matrix
  3348. * @param gradient defines the gradient between the two matrices
  3349. * @returns the new matrix
  3350. */
  3351. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3352. /**
  3353. * Update a matrix to values which are computed by:
  3354. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3355. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3356. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3357. * @param startValue defines the first matrix
  3358. * @param endValue defines the second matrix
  3359. * @param gradient defines the gradient between the two matrices
  3360. * @param result defines the target matrix
  3361. */
  3362. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3363. /**
  3364. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3365. * This function works in left handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3374. * This function works in left handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3383. * This function works in right handed mode
  3384. * @param eye defines the final position of the entity
  3385. * @param target defines where the entity should look at
  3386. * @param up defines the up vector for the entity
  3387. * @returns the new matrix
  3388. */
  3389. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3390. /**
  3391. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3392. * This function works in right handed mode
  3393. * @param eye defines the final position of the entity
  3394. * @param target defines where the entity should look at
  3395. * @param up defines the up vector for the entity
  3396. * @param result defines the target matrix
  3397. */
  3398. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param width defines the viewport width
  3402. * @param height defines the viewport height
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a left-handed orthographic projection matrix
  3406. */
  3407. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Store a left-handed orthographic projection to a given matrix
  3410. * @param width defines the viewport width
  3411. * @param height defines the viewport height
  3412. * @param znear defines the near clip plane
  3413. * @param zfar defines the far clip plane
  3414. * @param result defines the target matrix
  3415. */
  3416. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3417. /**
  3418. * Create a left-handed orthographic projection matrix
  3419. * @param left defines the viewport left coordinate
  3420. * @param right defines the viewport right coordinate
  3421. * @param bottom defines the viewport bottom coordinate
  3422. * @param top defines the viewport top coordinate
  3423. * @param znear defines the near clip plane
  3424. * @param zfar defines the far clip plane
  3425. * @returns a new matrix as a left-handed orthographic projection matrix
  3426. */
  3427. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3428. /**
  3429. * Stores a left-handed orthographic projection into a given matrix
  3430. * @param left defines the viewport left coordinate
  3431. * @param right defines the viewport right coordinate
  3432. * @param bottom defines the viewport bottom coordinate
  3433. * @param top defines the viewport top coordinate
  3434. * @param znear defines the near clip plane
  3435. * @param zfar defines the far clip plane
  3436. * @param result defines the target matrix
  3437. */
  3438. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3439. /**
  3440. * Creates a right-handed orthographic projection matrix
  3441. * @param left defines the viewport left coordinate
  3442. * @param right defines the viewport right coordinate
  3443. * @param bottom defines the viewport bottom coordinate
  3444. * @param top defines the viewport top coordinate
  3445. * @param znear defines the near clip plane
  3446. * @param zfar defines the far clip plane
  3447. * @returns a new matrix as a right-handed orthographic projection matrix
  3448. */
  3449. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3450. /**
  3451. * Stores a right-handed orthographic projection into a given matrix
  3452. * @param left defines the viewport left coordinate
  3453. * @param right defines the viewport right coordinate
  3454. * @param bottom defines the viewport bottom coordinate
  3455. * @param top defines the viewport top coordinate
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @param result defines the target matrix
  3459. */
  3460. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3461. /**
  3462. * Creates a left-handed perspective projection matrix
  3463. * @param width defines the viewport width
  3464. * @param height defines the viewport height
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @returns a new matrix as a left-handed perspective projection matrix
  3468. */
  3469. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3470. /**
  3471. * Creates a left-handed perspective projection matrix
  3472. * @param fov defines the horizontal field of view
  3473. * @param aspect defines the aspect ratio
  3474. * @param znear defines the near clip plane
  3475. * @param zfar defines the far clip plane
  3476. * @returns a new matrix as a left-handed perspective projection matrix
  3477. */
  3478. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3479. /**
  3480. * Stores a left-handed perspective projection into a given matrix
  3481. * @param fov defines the horizontal field of view
  3482. * @param aspect defines the aspect ratio
  3483. * @param znear defines the near clip plane
  3484. * @param zfar defines the far clip plane
  3485. * @param result defines the target matrix
  3486. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3487. */
  3488. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3489. /**
  3490. * Creates a right-handed perspective projection matrix
  3491. * @param fov defines the horizontal field of view
  3492. * @param aspect defines the aspect ratio
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @returns a new matrix as a right-handed perspective projection matrix
  3496. */
  3497. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3498. /**
  3499. * Stores a right-handed perspective projection into a given matrix
  3500. * @param fov defines the horizontal field of view
  3501. * @param aspect defines the aspect ratio
  3502. * @param znear defines the near clip plane
  3503. * @param zfar defines the far clip plane
  3504. * @param result defines the target matrix
  3505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3506. */
  3507. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3508. /**
  3509. * Stores a perspective projection for WebVR info a given matrix
  3510. * @param fov defines the field of view
  3511. * @param znear defines the near clip plane
  3512. * @param zfar defines the far clip plane
  3513. * @param result defines the target matrix
  3514. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3515. */
  3516. static PerspectiveFovWebVRToRef(fov: {
  3517. upDegrees: number;
  3518. downDegrees: number;
  3519. leftDegrees: number;
  3520. rightDegrees: number;
  3521. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3522. /**
  3523. * Computes a complete transformation matrix
  3524. * @param viewport defines the viewport to use
  3525. * @param world defines the world matrix
  3526. * @param view defines the view matrix
  3527. * @param projection defines the projection matrix
  3528. * @param zmin defines the near clip plane
  3529. * @param zmax defines the far clip plane
  3530. * @returns the transformation matrix
  3531. */
  3532. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3533. /**
  3534. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3535. * @param matrix defines the matrix to use
  3536. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3537. */
  3538. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3539. /**
  3540. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3541. * @param matrix defines the matrix to use
  3542. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3543. */
  3544. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3545. /**
  3546. * Compute the transpose of a given matrix
  3547. * @param matrix defines the matrix to transpose
  3548. * @returns the new matrix
  3549. */
  3550. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3551. /**
  3552. * Compute the transpose of a matrix and store it in a target matrix
  3553. * @param matrix defines the matrix to transpose
  3554. * @param result defines the target matrix
  3555. */
  3556. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3557. /**
  3558. * Computes a reflection matrix from a plane
  3559. * @param plane defines the reflection plane
  3560. * @returns a new matrix
  3561. */
  3562. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3563. /**
  3564. * Computes a reflection matrix from a plane
  3565. * @param plane defines the reflection plane
  3566. * @param result defines the target matrix
  3567. */
  3568. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3569. /**
  3570. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3571. * @param xaxis defines the value of the 1st axis
  3572. * @param yaxis defines the value of the 2nd axis
  3573. * @param zaxis defines the value of the 3rd axis
  3574. * @param result defines the target matrix
  3575. */
  3576. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3577. /**
  3578. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3579. * @param quat defines the quaternion to use
  3580. * @param result defines the target matrix
  3581. */
  3582. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3583. }
  3584. /**
  3585. * Represens a plane by the equation ax + by + cz + d = 0
  3586. */
  3587. export class Plane {
  3588. /**
  3589. * Normal of the plane (a,b,c)
  3590. */
  3591. normal: Vector3;
  3592. /**
  3593. * d component of the plane
  3594. */
  3595. d: number;
  3596. /**
  3597. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3598. * @param a a component of the plane
  3599. * @param b b component of the plane
  3600. * @param c c component of the plane
  3601. * @param d d component of the plane
  3602. */
  3603. constructor(a: number, b: number, c: number, d: number);
  3604. /**
  3605. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3606. */
  3607. asArray(): number[];
  3608. /**
  3609. * @returns a new plane copied from the current Plane.
  3610. */
  3611. clone(): Plane;
  3612. /**
  3613. * @returns the string "Plane".
  3614. */
  3615. getClassName(): string;
  3616. /**
  3617. * @returns the Plane hash code.
  3618. */
  3619. getHashCode(): number;
  3620. /**
  3621. * Normalize the current Plane in place.
  3622. * @returns the updated Plane.
  3623. */
  3624. normalize(): Plane;
  3625. /**
  3626. * Applies a transformation the plane and returns the result
  3627. * @param transformation the transformation matrix to be applied to the plane
  3628. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3629. */
  3630. transform(transformation: DeepImmutable<Matrix>): Plane;
  3631. /**
  3632. * Calcualtte the dot product between the point and the plane normal
  3633. * @param point point to calculate the dot product with
  3634. * @returns the dot product (float) of the point coordinates and the plane normal.
  3635. */
  3636. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3637. /**
  3638. * Updates the current Plane from the plane defined by the three given points.
  3639. * @param point1 one of the points used to contruct the plane
  3640. * @param point2 one of the points used to contruct the plane
  3641. * @param point3 one of the points used to contruct the plane
  3642. * @returns the updated Plane.
  3643. */
  3644. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3645. /**
  3646. * Checks if the plane is facing a given direction
  3647. * @param direction the direction to check if the plane is facing
  3648. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3649. * @returns True is the vector "direction" is the same side than the plane normal.
  3650. */
  3651. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3652. /**
  3653. * Calculates the distance to a point
  3654. * @param point point to calculate distance to
  3655. * @returns the signed distance (float) from the given point to the Plane.
  3656. */
  3657. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3658. /**
  3659. * Creates a plane from an array
  3660. * @param array the array to create a plane from
  3661. * @returns a new Plane from the given array.
  3662. */
  3663. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3664. /**
  3665. * Creates a plane from three points
  3666. * @param point1 point used to create the plane
  3667. * @param point2 point used to create the plane
  3668. * @param point3 point used to create the plane
  3669. * @returns a new Plane defined by the three given points.
  3670. */
  3671. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3672. /**
  3673. * Creates a plane from an origin point and a normal
  3674. * @param origin origin of the plane to be constructed
  3675. * @param normal normal of the plane to be constructed
  3676. * @returns a new Plane the normal vector to this plane at the given origin point.
  3677. * Note : the vector "normal" is updated because normalized.
  3678. */
  3679. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3680. /**
  3681. * Calculates the distance from a plane and a point
  3682. * @param origin origin of the plane to be constructed
  3683. * @param normal normal of the plane to be constructed
  3684. * @param point point to calculate distance to
  3685. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3686. */
  3687. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3688. }
  3689. /**
  3690. * Class used to represent a viewport on screen
  3691. */
  3692. export class Viewport {
  3693. /** viewport left coordinate */
  3694. x: number;
  3695. /** viewport top coordinate */
  3696. y: number;
  3697. /**viewport width */
  3698. width: number;
  3699. /** viewport height */
  3700. height: number;
  3701. /**
  3702. * Creates a Viewport object located at (x, y) and sized (width, height)
  3703. * @param x defines viewport left coordinate
  3704. * @param y defines viewport top coordinate
  3705. * @param width defines the viewport width
  3706. * @param height defines the viewport height
  3707. */
  3708. constructor(
  3709. /** viewport left coordinate */
  3710. x: number,
  3711. /** viewport top coordinate */
  3712. y: number,
  3713. /**viewport width */
  3714. width: number,
  3715. /** viewport height */
  3716. height: number);
  3717. /**
  3718. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3719. * @param renderWidth defines the rendering width
  3720. * @param renderHeight defines the rendering height
  3721. * @returns a new Viewport
  3722. */
  3723. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3724. /**
  3725. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3726. * @param renderWidth defines the rendering width
  3727. * @param renderHeight defines the rendering height
  3728. * @param ref defines the target viewport
  3729. * @returns the current viewport
  3730. */
  3731. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3732. /**
  3733. * Returns a new Viewport copied from the current one
  3734. * @returns a new Viewport
  3735. */
  3736. clone(): Viewport;
  3737. }
  3738. /**
  3739. * Reprasents a camera frustum
  3740. */
  3741. export class Frustum {
  3742. /**
  3743. * Gets the planes representing the frustum
  3744. * @param transform matrix to be applied to the returned planes
  3745. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3746. */
  3747. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3748. /**
  3749. * Gets the near frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the far frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the left frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Gets the right frustum plane transformed by the transform matrix
  3768. * @param transform transformation matrix to be applied to the resulting frustum plane
  3769. * @param frustumPlane the resuling frustum plane
  3770. */
  3771. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3772. /**
  3773. * Gets the top frustum plane transformed by the transform matrix
  3774. * @param transform transformation matrix to be applied to the resulting frustum plane
  3775. * @param frustumPlane the resuling frustum plane
  3776. */
  3777. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3778. /**
  3779. * Gets the bottom frustum plane transformed by the transform matrix
  3780. * @param transform transformation matrix to be applied to the resulting frustum plane
  3781. * @param frustumPlane the resuling frustum plane
  3782. */
  3783. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3784. /**
  3785. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3786. * @param transform transformation matrix to be applied to the resulting frustum planes
  3787. * @param frustumPlanes the resuling frustum planes
  3788. */
  3789. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3790. }
  3791. /** Defines supported spaces */
  3792. export enum Space {
  3793. /** Local (object) space */
  3794. LOCAL = 0,
  3795. /** World space */
  3796. WORLD = 1,
  3797. /** Bone space */
  3798. BONE = 2
  3799. }
  3800. /** Defines the 3 main axes */
  3801. export class Axis {
  3802. /** X axis */
  3803. static X: Vector3;
  3804. /** Y axis */
  3805. static Y: Vector3;
  3806. /** Z axis */
  3807. static Z: Vector3;
  3808. }
  3809. /** Class used to represent a Bezier curve */
  3810. export class BezierCurve {
  3811. /**
  3812. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3813. * @param t defines the time
  3814. * @param x1 defines the left coordinate on X axis
  3815. * @param y1 defines the left coordinate on Y axis
  3816. * @param x2 defines the right coordinate on X axis
  3817. * @param y2 defines the right coordinate on Y axis
  3818. * @returns the interpolated value
  3819. */
  3820. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3821. }
  3822. /**
  3823. * Defines potential orientation for back face culling
  3824. */
  3825. export enum Orientation {
  3826. /**
  3827. * Clockwise
  3828. */
  3829. CW = 0,
  3830. /** Counter clockwise */
  3831. CCW = 1
  3832. }
  3833. /**
  3834. * Defines angle representation
  3835. */
  3836. export class Angle {
  3837. private _radians;
  3838. /**
  3839. * Creates an Angle object of "radians" radians (float).
  3840. * @param radians the angle in radians
  3841. */
  3842. constructor(radians: number);
  3843. /**
  3844. * Get value in degrees
  3845. * @returns the Angle value in degrees (float)
  3846. */
  3847. degrees(): number;
  3848. /**
  3849. * Get value in radians
  3850. * @returns the Angle value in radians (float)
  3851. */
  3852. radians(): number;
  3853. /**
  3854. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3855. * @param a defines first vector
  3856. * @param b defines second vector
  3857. * @returns a new Angle
  3858. */
  3859. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3860. /**
  3861. * Gets a new Angle object from the given float in radians
  3862. * @param radians defines the angle value in radians
  3863. * @returns a new Angle
  3864. */
  3865. static FromRadians(radians: number): Angle;
  3866. /**
  3867. * Gets a new Angle object from the given float in degrees
  3868. * @param degrees defines the angle value in degrees
  3869. * @returns a new Angle
  3870. */
  3871. static FromDegrees(degrees: number): Angle;
  3872. }
  3873. /**
  3874. * This represents an arc in a 2d space.
  3875. */
  3876. export class Arc2 {
  3877. /** Defines the start point of the arc */
  3878. startPoint: Vector2;
  3879. /** Defines the mid point of the arc */
  3880. midPoint: Vector2;
  3881. /** Defines the end point of the arc */
  3882. endPoint: Vector2;
  3883. /**
  3884. * Defines the center point of the arc.
  3885. */
  3886. centerPoint: Vector2;
  3887. /**
  3888. * Defines the radius of the arc.
  3889. */
  3890. radius: number;
  3891. /**
  3892. * Defines the angle of the arc (from mid point to end point).
  3893. */
  3894. angle: Angle;
  3895. /**
  3896. * Defines the start angle of the arc (from start point to middle point).
  3897. */
  3898. startAngle: Angle;
  3899. /**
  3900. * Defines the orientation of the arc (clock wise/counter clock wise).
  3901. */
  3902. orientation: Orientation;
  3903. /**
  3904. * Creates an Arc object from the three given points : start, middle and end.
  3905. * @param startPoint Defines the start point of the arc
  3906. * @param midPoint Defines the midlle point of the arc
  3907. * @param endPoint Defines the end point of the arc
  3908. */
  3909. constructor(
  3910. /** Defines the start point of the arc */
  3911. startPoint: Vector2,
  3912. /** Defines the mid point of the arc */
  3913. midPoint: Vector2,
  3914. /** Defines the end point of the arc */
  3915. endPoint: Vector2);
  3916. }
  3917. /**
  3918. * Represents a 2D path made up of multiple 2D points
  3919. */
  3920. export class Path2 {
  3921. private _points;
  3922. private _length;
  3923. /**
  3924. * If the path start and end point are the same
  3925. */
  3926. closed: boolean;
  3927. /**
  3928. * Creates a Path2 object from the starting 2D coordinates x and y.
  3929. * @param x the starting points x value
  3930. * @param y the starting points y value
  3931. */
  3932. constructor(x: number, y: number);
  3933. /**
  3934. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3935. * @param x the added points x value
  3936. * @param y the added points y value
  3937. * @returns the updated Path2.
  3938. */
  3939. addLineTo(x: number, y: number): Path2;
  3940. /**
  3941. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3942. * @param midX middle point x value
  3943. * @param midY middle point y value
  3944. * @param endX end point x value
  3945. * @param endY end point y value
  3946. * @param numberOfSegments (default: 36)
  3947. * @returns the updated Path2.
  3948. */
  3949. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3950. /**
  3951. * Closes the Path2.
  3952. * @returns the Path2.
  3953. */
  3954. close(): Path2;
  3955. /**
  3956. * Gets the sum of the distance between each sequential point in the path
  3957. * @returns the Path2 total length (float).
  3958. */
  3959. length(): number;
  3960. /**
  3961. * Gets the points which construct the path
  3962. * @returns the Path2 internal array of points.
  3963. */
  3964. getPoints(): Vector2[];
  3965. /**
  3966. * Retreives the point at the distance aways from the starting point
  3967. * @param normalizedLengthPosition the length along the path to retreive the point from
  3968. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3969. */
  3970. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3971. /**
  3972. * Creates a new path starting from an x and y position
  3973. * @param x starting x value
  3974. * @param y starting y value
  3975. * @returns a new Path2 starting at the coordinates (x, y).
  3976. */
  3977. static StartingAt(x: number, y: number): Path2;
  3978. }
  3979. /**
  3980. * Represents a 3D path made up of multiple 3D points
  3981. */
  3982. export class Path3D {
  3983. /**
  3984. * an array of Vector3, the curve axis of the Path3D
  3985. */
  3986. path: Vector3[];
  3987. private _curve;
  3988. private _distances;
  3989. private _tangents;
  3990. private _normals;
  3991. private _binormals;
  3992. private _raw;
  3993. /**
  3994. * new Path3D(path, normal, raw)
  3995. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3996. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3997. * @param path an array of Vector3, the curve axis of the Path3D
  3998. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3999. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4000. */
  4001. constructor(
  4002. /**
  4003. * an array of Vector3, the curve axis of the Path3D
  4004. */
  4005. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4006. /**
  4007. * Returns the Path3D array of successive Vector3 designing its curve.
  4008. * @returns the Path3D array of successive Vector3 designing its curve.
  4009. */
  4010. getCurve(): Vector3[];
  4011. /**
  4012. * Returns an array populated with tangent vectors on each Path3D curve point.
  4013. * @returns an array populated with tangent vectors on each Path3D curve point.
  4014. */
  4015. getTangents(): Vector3[];
  4016. /**
  4017. * Returns an array populated with normal vectors on each Path3D curve point.
  4018. * @returns an array populated with normal vectors on each Path3D curve point.
  4019. */
  4020. getNormals(): Vector3[];
  4021. /**
  4022. * Returns an array populated with binormal vectors on each Path3D curve point.
  4023. * @returns an array populated with binormal vectors on each Path3D curve point.
  4024. */
  4025. getBinormals(): Vector3[];
  4026. /**
  4027. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4028. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4029. */
  4030. getDistances(): number[];
  4031. /**
  4032. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4033. * @param path path which all values are copied into the curves points
  4034. * @param firstNormal which should be projected onto the curve
  4035. * @returns the same object updated.
  4036. */
  4037. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4038. private _compute;
  4039. private _getFirstNonNullVector;
  4040. private _getLastNonNullVector;
  4041. private _normalVector;
  4042. }
  4043. /**
  4044. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4045. * A Curve3 is designed from a series of successive Vector3.
  4046. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4047. */
  4048. export class Curve3 {
  4049. private _points;
  4050. private _length;
  4051. /**
  4052. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4053. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4054. * @param v1 (Vector3) the control point
  4055. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4056. * @param nbPoints (integer) the wanted number of points in the curve
  4057. * @returns the created Curve3
  4058. */
  4059. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4060. /**
  4061. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4062. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4063. * @param v1 (Vector3) the first control point
  4064. * @param v2 (Vector3) the second control point
  4065. * @param v3 (Vector3) the end point of the Cubic Bezier
  4066. * @param nbPoints (integer) the wanted number of points in the curve
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4070. /**
  4071. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4072. * @param p1 (Vector3) the origin point of the Hermite Spline
  4073. * @param t1 (Vector3) the tangent vector at the origin point
  4074. * @param p2 (Vector3) the end point of the Hermite Spline
  4075. * @param t2 (Vector3) the tangent vector at the end point
  4076. * @param nbPoints (integer) the wanted number of points in the curve
  4077. * @returns the created Curve3
  4078. */
  4079. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4080. /**
  4081. * Returns a Curve3 object along a CatmullRom Spline curve :
  4082. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4083. * @param nbPoints (integer) the wanted number of points between each curve control points
  4084. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4085. * @returns the created Curve3
  4086. */
  4087. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4088. /**
  4089. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4090. * A Curve3 is designed from a series of successive Vector3.
  4091. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4092. * @param points points which make up the curve
  4093. */
  4094. constructor(points: Vector3[]);
  4095. /**
  4096. * @returns the Curve3 stored array of successive Vector3
  4097. */
  4098. getPoints(): Vector3[];
  4099. /**
  4100. * @returns the computed length (float) of the curve.
  4101. */
  4102. length(): number;
  4103. /**
  4104. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4105. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4106. * curveA and curveB keep unchanged.
  4107. * @param curve the curve to continue from this curve
  4108. * @returns the newly constructed curve
  4109. */
  4110. continue(curve: DeepImmutable<Curve3>): Curve3;
  4111. private _computeLength;
  4112. }
  4113. /**
  4114. * Contains position and normal vectors for a vertex
  4115. */
  4116. export class PositionNormalVertex {
  4117. /** the position of the vertex (defaut: 0,0,0) */
  4118. position: Vector3;
  4119. /** the normal of the vertex (defaut: 0,1,0) */
  4120. normal: Vector3;
  4121. /**
  4122. * Creates a PositionNormalVertex
  4123. * @param position the position of the vertex (defaut: 0,0,0)
  4124. * @param normal the normal of the vertex (defaut: 0,1,0)
  4125. */
  4126. constructor(
  4127. /** the position of the vertex (defaut: 0,0,0) */
  4128. position?: Vector3,
  4129. /** the normal of the vertex (defaut: 0,1,0) */
  4130. normal?: Vector3);
  4131. /**
  4132. * Clones the PositionNormalVertex
  4133. * @returns the cloned PositionNormalVertex
  4134. */
  4135. clone(): PositionNormalVertex;
  4136. }
  4137. /**
  4138. * Contains position, normal and uv vectors for a vertex
  4139. */
  4140. export class PositionNormalTextureVertex {
  4141. /** the position of the vertex (defaut: 0,0,0) */
  4142. position: Vector3;
  4143. /** the normal of the vertex (defaut: 0,1,0) */
  4144. normal: Vector3;
  4145. /** the uv of the vertex (default: 0,0) */
  4146. uv: Vector2;
  4147. /**
  4148. * Creates a PositionNormalTextureVertex
  4149. * @param position the position of the vertex (defaut: 0,0,0)
  4150. * @param normal the normal of the vertex (defaut: 0,1,0)
  4151. * @param uv the uv of the vertex (default: 0,0)
  4152. */
  4153. constructor(
  4154. /** the position of the vertex (defaut: 0,0,0) */
  4155. position?: Vector3,
  4156. /** the normal of the vertex (defaut: 0,1,0) */
  4157. normal?: Vector3,
  4158. /** the uv of the vertex (default: 0,0) */
  4159. uv?: Vector2);
  4160. /**
  4161. * Clones the PositionNormalTextureVertex
  4162. * @returns the cloned PositionNormalTextureVertex
  4163. */
  4164. clone(): PositionNormalTextureVertex;
  4165. }
  4166. /**
  4167. * @hidden
  4168. */
  4169. export class Tmp {
  4170. static Color3: Color3[];
  4171. static Color4: Color4[];
  4172. static Vector2: Vector2[];
  4173. static Vector3: Vector3[];
  4174. static Vector4: Vector4[];
  4175. static Quaternion: Quaternion[];
  4176. static Matrix: Matrix[];
  4177. }
  4178. }
  4179. declare module "babylonjs/Offline/IOfflineProvider" {
  4180. /**
  4181. * Class used to enable access to offline support
  4182. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4183. */
  4184. export interface IOfflineProvider {
  4185. /**
  4186. * Gets a boolean indicating if scene must be saved in the database
  4187. */
  4188. enableSceneOffline: boolean;
  4189. /**
  4190. * Gets a boolean indicating if textures must be saved in the database
  4191. */
  4192. enableTexturesOffline: boolean;
  4193. /**
  4194. * Open the offline support and make it available
  4195. * @param successCallback defines the callback to call on success
  4196. * @param errorCallback defines the callback to call on error
  4197. */
  4198. open(successCallback: () => void, errorCallback: () => void): void;
  4199. /**
  4200. * Loads an image from the offline support
  4201. * @param url defines the url to load from
  4202. * @param image defines the target DOM image
  4203. */
  4204. loadImage(url: string, image: HTMLImageElement): void;
  4205. /**
  4206. * Loads a file from offline support
  4207. * @param url defines the URL to load from
  4208. * @param sceneLoaded defines a callback to call on success
  4209. * @param progressCallBack defines a callback to call when progress changed
  4210. * @param errorCallback defines a callback to call on error
  4211. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4212. */
  4213. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4214. }
  4215. }
  4216. declare module "babylonjs/Misc/observable" {
  4217. import { Nullable } from "babylonjs/types";
  4218. /**
  4219. * A class serves as a medium between the observable and its observers
  4220. */
  4221. export class EventState {
  4222. /**
  4223. * Create a new EventState
  4224. * @param mask defines the mask associated with this state
  4225. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4226. * @param target defines the original target of the state
  4227. * @param currentTarget defines the current target of the state
  4228. */
  4229. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4230. /**
  4231. * Initialize the current event state
  4232. * @param mask defines the mask associated with this state
  4233. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4234. * @param target defines the original target of the state
  4235. * @param currentTarget defines the current target of the state
  4236. * @returns the current event state
  4237. */
  4238. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4239. /**
  4240. * An Observer can set this property to true to prevent subsequent observers of being notified
  4241. */
  4242. skipNextObservers: boolean;
  4243. /**
  4244. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4245. */
  4246. mask: number;
  4247. /**
  4248. * The object that originally notified the event
  4249. */
  4250. target?: any;
  4251. /**
  4252. * The current object in the bubbling phase
  4253. */
  4254. currentTarget?: any;
  4255. /**
  4256. * This will be populated with the return value of the last function that was executed.
  4257. * If it is the first function in the callback chain it will be the event data.
  4258. */
  4259. lastReturnValue?: any;
  4260. }
  4261. /**
  4262. * Represent an Observer registered to a given Observable object.
  4263. */
  4264. export class Observer<T> {
  4265. /**
  4266. * Defines the callback to call when the observer is notified
  4267. */
  4268. callback: (eventData: T, eventState: EventState) => void;
  4269. /**
  4270. * Defines the mask of the observer (used to filter notifications)
  4271. */
  4272. mask: number;
  4273. /**
  4274. * Defines the current scope used to restore the JS context
  4275. */
  4276. scope: any;
  4277. /** @hidden */
  4278. _willBeUnregistered: boolean;
  4279. /**
  4280. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4281. */
  4282. unregisterOnNextCall: boolean;
  4283. /**
  4284. * Creates a new observer
  4285. * @param callback defines the callback to call when the observer is notified
  4286. * @param mask defines the mask of the observer (used to filter notifications)
  4287. * @param scope defines the current scope used to restore the JS context
  4288. */
  4289. constructor(
  4290. /**
  4291. * Defines the callback to call when the observer is notified
  4292. */
  4293. callback: (eventData: T, eventState: EventState) => void,
  4294. /**
  4295. * Defines the mask of the observer (used to filter notifications)
  4296. */
  4297. mask: number,
  4298. /**
  4299. * Defines the current scope used to restore the JS context
  4300. */
  4301. scope?: any);
  4302. }
  4303. /**
  4304. * Represent a list of observers registered to multiple Observables object.
  4305. */
  4306. export class MultiObserver<T> {
  4307. private _observers;
  4308. private _observables;
  4309. /**
  4310. * Release associated resources
  4311. */
  4312. dispose(): void;
  4313. /**
  4314. * Raise a callback when one of the observable will notify
  4315. * @param observables defines a list of observables to watch
  4316. * @param callback defines the callback to call on notification
  4317. * @param mask defines the mask used to filter notifications
  4318. * @param scope defines the current scope used to restore the JS context
  4319. * @returns the new MultiObserver
  4320. */
  4321. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4322. }
  4323. /**
  4324. * The Observable class is a simple implementation of the Observable pattern.
  4325. *
  4326. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4327. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4328. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4329. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4330. */
  4331. export class Observable<T> {
  4332. private _observers;
  4333. private _eventState;
  4334. private _onObserverAdded;
  4335. /**
  4336. * Creates a new observable
  4337. * @param onObserverAdded defines a callback to call when a new observer is added
  4338. */
  4339. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4340. /**
  4341. * Create a new Observer with the specified callback
  4342. * @param callback the callback that will be executed for that Observer
  4343. * @param mask the mask used to filter observers
  4344. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4345. * @param scope optional scope for the callback to be called from
  4346. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4347. * @returns the new observer created for the callback
  4348. */
  4349. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4350. /**
  4351. * Create a new Observer with the specified callback and unregisters after the next notification
  4352. * @param callback the callback that will be executed for that Observer
  4353. * @returns the new observer created for the callback
  4354. */
  4355. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4356. /**
  4357. * Remove an Observer from the Observable object
  4358. * @param observer the instance of the Observer to remove
  4359. * @returns false if it doesn't belong to this Observable
  4360. */
  4361. remove(observer: Nullable<Observer<T>>): boolean;
  4362. /**
  4363. * Remove a callback from the Observable object
  4364. * @param callback the callback to remove
  4365. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4366. * @returns false if it doesn't belong to this Observable
  4367. */
  4368. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4369. private _deferUnregister;
  4370. private _remove;
  4371. /**
  4372. * Moves the observable to the top of the observer list making it get called first when notified
  4373. * @param observer the observer to move
  4374. */
  4375. makeObserverTopPriority(observer: Observer<T>): void;
  4376. /**
  4377. * Moves the observable to the bottom of the observer list making it get called last when notified
  4378. * @param observer the observer to move
  4379. */
  4380. makeObserverBottomPriority(observer: Observer<T>): void;
  4381. /**
  4382. * Notify all Observers by calling their respective callback with the given data
  4383. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4384. * @param eventData defines the data to send to all observers
  4385. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4386. * @param target defines the original target of the state
  4387. * @param currentTarget defines the current target of the state
  4388. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4389. */
  4390. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4391. /**
  4392. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4393. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4394. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4395. * and it is crucial that all callbacks will be executed.
  4396. * The order of the callbacks is kept, callbacks are not executed parallel.
  4397. *
  4398. * @param eventData The data to be sent to each callback
  4399. * @param mask is used to filter observers defaults to -1
  4400. * @param target defines the callback target (see EventState)
  4401. * @param currentTarget defines he current object in the bubbling phase
  4402. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4403. */
  4404. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4405. /**
  4406. * Notify a specific observer
  4407. * @param observer defines the observer to notify
  4408. * @param eventData defines the data to be sent to each callback
  4409. * @param mask is used to filter observers defaults to -1
  4410. */
  4411. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4412. /**
  4413. * Gets a boolean indicating if the observable has at least one observer
  4414. * @returns true is the Observable has at least one Observer registered
  4415. */
  4416. hasObservers(): boolean;
  4417. /**
  4418. * Clear the list of observers
  4419. */
  4420. clear(): void;
  4421. /**
  4422. * Clone the current observable
  4423. * @returns a new observable
  4424. */
  4425. clone(): Observable<T>;
  4426. /**
  4427. * Does this observable handles observer registered with a given mask
  4428. * @param mask defines the mask to be tested
  4429. * @return whether or not one observer registered with the given mask is handeled
  4430. **/
  4431. hasSpecificMask(mask?: number): boolean;
  4432. }
  4433. }
  4434. declare module "babylonjs/Misc/filesInputStore" {
  4435. /**
  4436. * Class used to help managing file picking and drag'n'drop
  4437. * File Storage
  4438. */
  4439. export class FilesInputStore {
  4440. /**
  4441. * List of files ready to be loaded
  4442. */
  4443. static FilesToLoad: {
  4444. [key: string]: File;
  4445. };
  4446. }
  4447. }
  4448. declare module "babylonjs/Engines/constants" {
  4449. /** Defines the cross module used constants to avoid circular dependncies */
  4450. export class Constants {
  4451. /** Defines that alpha blending is disabled */
  4452. static readonly ALPHA_DISABLE: number;
  4453. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4454. static readonly ALPHA_ADD: number;
  4455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4456. static readonly ALPHA_COMBINE: number;
  4457. /** Defines that alpha blending to DEST - SRC * DEST */
  4458. static readonly ALPHA_SUBTRACT: number;
  4459. /** Defines that alpha blending to SRC * DEST */
  4460. static readonly ALPHA_MULTIPLY: number;
  4461. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4462. static readonly ALPHA_MAXIMIZED: number;
  4463. /** Defines that alpha blending to SRC + DEST */
  4464. static readonly ALPHA_ONEONE: number;
  4465. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4466. static readonly ALPHA_PREMULTIPLIED: number;
  4467. /**
  4468. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4469. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4470. */
  4471. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4472. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4473. static readonly ALPHA_INTERPOLATE: number;
  4474. /**
  4475. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4476. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4477. */
  4478. static readonly ALPHA_SCREENMODE: number;
  4479. /** Defines that the ressource is not delayed*/
  4480. static readonly DELAYLOADSTATE_NONE: number;
  4481. /** Defines that the ressource was successfully delay loaded */
  4482. static readonly DELAYLOADSTATE_LOADED: number;
  4483. /** Defines that the ressource is currently delay loading */
  4484. static readonly DELAYLOADSTATE_LOADING: number;
  4485. /** Defines that the ressource is delayed and has not started loading */
  4486. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4488. static readonly NEVER: number;
  4489. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4490. static readonly ALWAYS: number;
  4491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4492. static readonly LESS: number;
  4493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4494. static readonly EQUAL: number;
  4495. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4496. static readonly LEQUAL: number;
  4497. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4498. static readonly GREATER: number;
  4499. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4500. static readonly GEQUAL: number;
  4501. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4502. static readonly NOTEQUAL: number;
  4503. /** Passed to stencilOperation to specify that stencil value must be kept */
  4504. static readonly KEEP: number;
  4505. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4506. static readonly REPLACE: number;
  4507. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4508. static readonly INCR: number;
  4509. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4510. static readonly DECR: number;
  4511. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4512. static readonly INVERT: number;
  4513. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4514. static readonly INCR_WRAP: number;
  4515. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4516. static readonly DECR_WRAP: number;
  4517. /** Texture is not repeating outside of 0..1 UVs */
  4518. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4519. /** Texture is repeating outside of 0..1 UVs */
  4520. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4521. /** Texture is repeating and mirrored */
  4522. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4523. /** ALPHA */
  4524. static readonly TEXTUREFORMAT_ALPHA: number;
  4525. /** LUMINANCE */
  4526. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4527. /** LUMINANCE_ALPHA */
  4528. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4529. /** RGB */
  4530. static readonly TEXTUREFORMAT_RGB: number;
  4531. /** RGBA */
  4532. static readonly TEXTUREFORMAT_RGBA: number;
  4533. /** RED */
  4534. static readonly TEXTUREFORMAT_RED: number;
  4535. /** RED (2nd reference) */
  4536. static readonly TEXTUREFORMAT_R: number;
  4537. /** RG */
  4538. static readonly TEXTUREFORMAT_RG: number;
  4539. /** RED_INTEGER */
  4540. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4541. /** RED_INTEGER (2nd reference) */
  4542. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4543. /** RG_INTEGER */
  4544. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4545. /** RGB_INTEGER */
  4546. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4547. /** RGBA_INTEGER */
  4548. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4549. /** UNSIGNED_BYTE */
  4550. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4551. /** UNSIGNED_BYTE (2nd reference) */
  4552. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4553. /** FLOAT */
  4554. static readonly TEXTURETYPE_FLOAT: number;
  4555. /** HALF_FLOAT */
  4556. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4557. /** BYTE */
  4558. static readonly TEXTURETYPE_BYTE: number;
  4559. /** SHORT */
  4560. static readonly TEXTURETYPE_SHORT: number;
  4561. /** UNSIGNED_SHORT */
  4562. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4563. /** INT */
  4564. static readonly TEXTURETYPE_INT: number;
  4565. /** UNSIGNED_INT */
  4566. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4567. /** UNSIGNED_SHORT_4_4_4_4 */
  4568. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4569. /** UNSIGNED_SHORT_5_5_5_1 */
  4570. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4571. /** UNSIGNED_SHORT_5_6_5 */
  4572. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4573. /** UNSIGNED_INT_2_10_10_10_REV */
  4574. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4575. /** UNSIGNED_INT_24_8 */
  4576. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4577. /** UNSIGNED_INT_10F_11F_11F_REV */
  4578. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4579. /** UNSIGNED_INT_5_9_9_9_REV */
  4580. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4581. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4582. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4583. /** nearest is mag = nearest and min = nearest and mip = linear */
  4584. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4586. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4587. /** Trilinear is mag = linear and min = linear and mip = linear */
  4588. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4589. /** nearest is mag = nearest and min = nearest and mip = linear */
  4590. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4591. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4592. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4593. /** Trilinear is mag = linear and min = linear and mip = linear */
  4594. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4595. /** mag = nearest and min = nearest and mip = nearest */
  4596. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4597. /** mag = nearest and min = linear and mip = nearest */
  4598. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4599. /** mag = nearest and min = linear and mip = linear */
  4600. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4601. /** mag = nearest and min = linear and mip = none */
  4602. static readonly TEXTURE_NEAREST_LINEAR: number;
  4603. /** mag = nearest and min = nearest and mip = none */
  4604. static readonly TEXTURE_NEAREST_NEAREST: number;
  4605. /** mag = linear and min = nearest and mip = nearest */
  4606. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4607. /** mag = linear and min = nearest and mip = linear */
  4608. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4609. /** mag = linear and min = linear and mip = none */
  4610. static readonly TEXTURE_LINEAR_LINEAR: number;
  4611. /** mag = linear and min = nearest and mip = none */
  4612. static readonly TEXTURE_LINEAR_NEAREST: number;
  4613. /** Explicit coordinates mode */
  4614. static readonly TEXTURE_EXPLICIT_MODE: number;
  4615. /** Spherical coordinates mode */
  4616. static readonly TEXTURE_SPHERICAL_MODE: number;
  4617. /** Planar coordinates mode */
  4618. static readonly TEXTURE_PLANAR_MODE: number;
  4619. /** Cubic coordinates mode */
  4620. static readonly TEXTURE_CUBIC_MODE: number;
  4621. /** Projection coordinates mode */
  4622. static readonly TEXTURE_PROJECTION_MODE: number;
  4623. /** Skybox coordinates mode */
  4624. static readonly TEXTURE_SKYBOX_MODE: number;
  4625. /** Inverse Cubic coordinates mode */
  4626. static readonly TEXTURE_INVCUBIC_MODE: number;
  4627. /** Equirectangular coordinates mode */
  4628. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4629. /** Equirectangular Fixed coordinates mode */
  4630. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4631. /** Equirectangular Fixed Mirrored coordinates mode */
  4632. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4633. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4634. static readonly SCALEMODE_FLOOR: number;
  4635. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4636. static readonly SCALEMODE_NEAREST: number;
  4637. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4638. static readonly SCALEMODE_CEILING: number;
  4639. /**
  4640. * The dirty texture flag value
  4641. */
  4642. static readonly MATERIAL_TextureDirtyFlag: number;
  4643. /**
  4644. * The dirty light flag value
  4645. */
  4646. static readonly MATERIAL_LightDirtyFlag: number;
  4647. /**
  4648. * The dirty fresnel flag value
  4649. */
  4650. static readonly MATERIAL_FresnelDirtyFlag: number;
  4651. /**
  4652. * The dirty attribute flag value
  4653. */
  4654. static readonly MATERIAL_AttributesDirtyFlag: number;
  4655. /**
  4656. * The dirty misc flag value
  4657. */
  4658. static readonly MATERIAL_MiscDirtyFlag: number;
  4659. /**
  4660. * The all dirty flag value
  4661. */
  4662. static readonly MATERIAL_AllDirtyFlag: number;
  4663. /**
  4664. * Returns the triangle fill mode
  4665. */
  4666. static readonly MATERIAL_TriangleFillMode: number;
  4667. /**
  4668. * Returns the wireframe mode
  4669. */
  4670. static readonly MATERIAL_WireFrameFillMode: number;
  4671. /**
  4672. * Returns the point fill mode
  4673. */
  4674. static readonly MATERIAL_PointFillMode: number;
  4675. /**
  4676. * Returns the point list draw mode
  4677. */
  4678. static readonly MATERIAL_PointListDrawMode: number;
  4679. /**
  4680. * Returns the line list draw mode
  4681. */
  4682. static readonly MATERIAL_LineListDrawMode: number;
  4683. /**
  4684. * Returns the line loop draw mode
  4685. */
  4686. static readonly MATERIAL_LineLoopDrawMode: number;
  4687. /**
  4688. * Returns the line strip draw mode
  4689. */
  4690. static readonly MATERIAL_LineStripDrawMode: number;
  4691. /**
  4692. * Returns the triangle strip draw mode
  4693. */
  4694. static readonly MATERIAL_TriangleStripDrawMode: number;
  4695. /**
  4696. * Returns the triangle fan draw mode
  4697. */
  4698. static readonly MATERIAL_TriangleFanDrawMode: number;
  4699. /**
  4700. * Stores the clock-wise side orientation
  4701. */
  4702. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4703. /**
  4704. * Stores the counter clock-wise side orientation
  4705. */
  4706. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4707. /**
  4708. * Nothing
  4709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4710. */
  4711. static readonly ACTION_NothingTrigger: number;
  4712. /**
  4713. * On pick
  4714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4715. */
  4716. static readonly ACTION_OnPickTrigger: number;
  4717. /**
  4718. * On left pick
  4719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4720. */
  4721. static readonly ACTION_OnLeftPickTrigger: number;
  4722. /**
  4723. * On right pick
  4724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4725. */
  4726. static readonly ACTION_OnRightPickTrigger: number;
  4727. /**
  4728. * On center pick
  4729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4730. */
  4731. static readonly ACTION_OnCenterPickTrigger: number;
  4732. /**
  4733. * On pick down
  4734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4735. */
  4736. static readonly ACTION_OnPickDownTrigger: number;
  4737. /**
  4738. * On double pick
  4739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4740. */
  4741. static readonly ACTION_OnDoublePickTrigger: number;
  4742. /**
  4743. * On pick up
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnPickUpTrigger: number;
  4747. /**
  4748. * On pick out.
  4749. * This trigger will only be raised if you also declared a OnPickDown
  4750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4751. */
  4752. static readonly ACTION_OnPickOutTrigger: number;
  4753. /**
  4754. * On long press
  4755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4756. */
  4757. static readonly ACTION_OnLongPressTrigger: number;
  4758. /**
  4759. * On pointer over
  4760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4761. */
  4762. static readonly ACTION_OnPointerOverTrigger: number;
  4763. /**
  4764. * On pointer out
  4765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4766. */
  4767. static readonly ACTION_OnPointerOutTrigger: number;
  4768. /**
  4769. * On every frame
  4770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4771. */
  4772. static readonly ACTION_OnEveryFrameTrigger: number;
  4773. /**
  4774. * On intersection enter
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4776. */
  4777. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4778. /**
  4779. * On intersection exit
  4780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4781. */
  4782. static readonly ACTION_OnIntersectionExitTrigger: number;
  4783. /**
  4784. * On key down
  4785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4786. */
  4787. static readonly ACTION_OnKeyDownTrigger: number;
  4788. /**
  4789. * On key up
  4790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4791. */
  4792. static readonly ACTION_OnKeyUpTrigger: number;
  4793. /**
  4794. * Billboard mode will only apply to Y axis
  4795. */
  4796. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4797. /**
  4798. * Billboard mode will apply to all axes
  4799. */
  4800. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4801. /**
  4802. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4803. */
  4804. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4805. /**
  4806. * Gets or sets base Assets URL
  4807. */
  4808. static readonly PARTICLES_BaseAssetsUrl: string;
  4809. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4810. * Test order :
  4811. * Is the bounding sphere outside the frustum ?
  4812. * If not, are the bounding box vertices outside the frustum ?
  4813. * It not, then the cullable object is in the frustum.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4816. /** Culling strategy : Bounding Sphere Only.
  4817. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4818. * It's also less accurate than the standard because some not visible objects can still be selected.
  4819. * Test : is the bounding sphere outside the frustum ?
  4820. * If not, then the cullable object is in the frustum.
  4821. */
  4822. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4823. /** Culling strategy : Optimistic Inclusion.
  4824. * This in an inclusion test first, then the standard exclusion test.
  4825. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4826. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4827. * Anyway, it's as accurate as the standard strategy.
  4828. * Test :
  4829. * Is the cullable object bounding sphere center in the frustum ?
  4830. * If not, apply the default culling strategy.
  4831. */
  4832. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4833. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4834. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4835. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4836. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4837. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4838. * Test :
  4839. * Is the cullable object bounding sphere center in the frustum ?
  4840. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4843. /**
  4844. * No logging while loading
  4845. */
  4846. static readonly SCENELOADER_NO_LOGGING: number;
  4847. /**
  4848. * Minimal logging while loading
  4849. */
  4850. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4851. /**
  4852. * Summary logging while loading
  4853. */
  4854. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4855. /**
  4856. * Detailled logging while loading
  4857. */
  4858. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4859. }
  4860. }
  4861. declare module "babylonjs/Misc/domManagement" {
  4862. /**
  4863. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4864. * Babylon.js
  4865. */
  4866. export class DomManagement {
  4867. /**
  4868. * Checks if the window object exists
  4869. * @returns true if the window object exists
  4870. */
  4871. static IsWindowObjectExist(): boolean;
  4872. /**
  4873. * Extracts text content from a DOM element hierarchy
  4874. * @param element defines the root element
  4875. * @returns a string
  4876. */
  4877. static GetDOMTextContent(element: HTMLElement): string;
  4878. }
  4879. }
  4880. declare module "babylonjs/Misc/logger" {
  4881. /**
  4882. * Logger used througouht the application to allow configuration of
  4883. * the log level required for the messages.
  4884. */
  4885. export class Logger {
  4886. /**
  4887. * No log
  4888. */
  4889. static readonly NoneLogLevel: number;
  4890. /**
  4891. * Only message logs
  4892. */
  4893. static readonly MessageLogLevel: number;
  4894. /**
  4895. * Only warning logs
  4896. */
  4897. static readonly WarningLogLevel: number;
  4898. /**
  4899. * Only error logs
  4900. */
  4901. static readonly ErrorLogLevel: number;
  4902. /**
  4903. * All logs
  4904. */
  4905. static readonly AllLogLevel: number;
  4906. private static _LogCache;
  4907. /**
  4908. * Gets a value indicating the number of loading errors
  4909. * @ignorenaming
  4910. */
  4911. static errorsCount: number;
  4912. /**
  4913. * Callback called when a new log is added
  4914. */
  4915. static OnNewCacheEntry: (entry: string) => void;
  4916. private static _AddLogEntry;
  4917. private static _FormatMessage;
  4918. private static _LogDisabled;
  4919. private static _LogEnabled;
  4920. private static _WarnDisabled;
  4921. private static _WarnEnabled;
  4922. private static _ErrorDisabled;
  4923. private static _ErrorEnabled;
  4924. /**
  4925. * Log a message to the console
  4926. */
  4927. static Log: (message: string) => void;
  4928. /**
  4929. * Write a warning message to the console
  4930. */
  4931. static Warn: (message: string) => void;
  4932. /**
  4933. * Write an error message to the console
  4934. */
  4935. static Error: (message: string) => void;
  4936. /**
  4937. * Gets current log cache (list of logs)
  4938. */
  4939. static readonly LogCache: string;
  4940. /**
  4941. * Clears the log cache
  4942. */
  4943. static ClearLogCache(): void;
  4944. /**
  4945. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4946. */
  4947. static LogLevels: number;
  4948. }
  4949. }
  4950. declare module "babylonjs/Misc/typeStore" {
  4951. /** @hidden */
  4952. export class _TypeStore {
  4953. /** @hidden */
  4954. static RegisteredTypes: {
  4955. [key: string]: Object;
  4956. };
  4957. /** @hidden */
  4958. static GetClass(fqdn: string): any;
  4959. }
  4960. }
  4961. declare module "babylonjs/Misc/deepCopier" {
  4962. /**
  4963. * Class containing a set of static utilities functions for deep copy.
  4964. */
  4965. export class DeepCopier {
  4966. /**
  4967. * Tries to copy an object by duplicating every property
  4968. * @param source defines the source object
  4969. * @param destination defines the target object
  4970. * @param doNotCopyList defines a list of properties to avoid
  4971. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4972. */
  4973. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/precisionDate" {
  4977. /**
  4978. * Class containing a set of static utilities functions for precision date
  4979. */
  4980. export class PrecisionDate {
  4981. /**
  4982. * Gets either window.performance.now() if supported or Date.now() else
  4983. */
  4984. static readonly Now: number;
  4985. }
  4986. }
  4987. declare module "babylonjs/Misc/devTools" {
  4988. /** @hidden */
  4989. export class _DevTools {
  4990. static WarnImport(name: string): string;
  4991. }
  4992. }
  4993. declare module "babylonjs/Misc/webRequest" {
  4994. /**
  4995. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4996. */
  4997. export class WebRequest {
  4998. private _xhr;
  4999. /**
  5000. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5001. * i.e. when loading files, where the server/service expects an Authorization header
  5002. */
  5003. static CustomRequestHeaders: {
  5004. [key: string]: string;
  5005. };
  5006. /**
  5007. * Add callback functions in this array to update all the requests before they get sent to the network
  5008. */
  5009. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5010. private _injectCustomRequestHeaders;
  5011. /**
  5012. * Gets or sets a function to be called when loading progress changes
  5013. */
  5014. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5015. /**
  5016. * Returns client's state
  5017. */
  5018. readonly readyState: number;
  5019. /**
  5020. * Returns client's status
  5021. */
  5022. readonly status: number;
  5023. /**
  5024. * Returns client's status as a text
  5025. */
  5026. readonly statusText: string;
  5027. /**
  5028. * Returns client's response
  5029. */
  5030. readonly response: any;
  5031. /**
  5032. * Returns client's response url
  5033. */
  5034. readonly responseURL: string;
  5035. /**
  5036. * Returns client's response as text
  5037. */
  5038. readonly responseText: string;
  5039. /**
  5040. * Gets or sets the expected response type
  5041. */
  5042. responseType: XMLHttpRequestResponseType;
  5043. /** @hidden */
  5044. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5045. /** @hidden */
  5046. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5047. /**
  5048. * Cancels any network activity
  5049. */
  5050. abort(): void;
  5051. /**
  5052. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5053. * @param body defines an optional request body
  5054. */
  5055. send(body?: Document | BodyInit | null): void;
  5056. /**
  5057. * Sets the request method, request URL
  5058. * @param method defines the method to use (GET, POST, etc..)
  5059. * @param url defines the url to connect with
  5060. */
  5061. open(method: string, url: string): void;
  5062. }
  5063. }
  5064. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5065. /**
  5066. * Class used to evalaute queries containing `and` and `or` operators
  5067. */
  5068. export class AndOrNotEvaluator {
  5069. /**
  5070. * Evaluate a query
  5071. * @param query defines the query to evaluate
  5072. * @param evaluateCallback defines the callback used to filter result
  5073. * @returns true if the query matches
  5074. */
  5075. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5076. private static _HandleParenthesisContent;
  5077. private static _SimplifyNegation;
  5078. }
  5079. }
  5080. declare module "babylonjs/Misc/tags" {
  5081. /**
  5082. * Class used to store custom tags
  5083. */
  5084. export class Tags {
  5085. /**
  5086. * Adds support for tags on the given object
  5087. * @param obj defines the object to use
  5088. */
  5089. static EnableFor(obj: any): void;
  5090. /**
  5091. * Removes tags support
  5092. * @param obj defines the object to use
  5093. */
  5094. static DisableFor(obj: any): void;
  5095. /**
  5096. * Gets a boolean indicating if the given object has tags
  5097. * @param obj defines the object to use
  5098. * @returns a boolean
  5099. */
  5100. static HasTags(obj: any): boolean;
  5101. /**
  5102. * Gets the tags available on a given object
  5103. * @param obj defines the object to use
  5104. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5105. * @returns the tags
  5106. */
  5107. static GetTags(obj: any, asString?: boolean): any;
  5108. /**
  5109. * Adds tags to an object
  5110. * @param obj defines the object to use
  5111. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5112. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5113. */
  5114. static AddTagsTo(obj: any, tagsString: string): void;
  5115. /**
  5116. * @hidden
  5117. */
  5118. static _AddTagTo(obj: any, tag: string): void;
  5119. /**
  5120. * Removes specific tags from a specific object
  5121. * @param obj defines the object to use
  5122. * @param tagsString defines the tags to remove
  5123. */
  5124. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5125. /**
  5126. * @hidden
  5127. */
  5128. static _RemoveTagFrom(obj: any, tag: string): void;
  5129. /**
  5130. * Defines if tags hosted on an object match a given query
  5131. * @param obj defines the object to use
  5132. * @param tagsQuery defines the tag query
  5133. * @returns a boolean
  5134. */
  5135. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5136. }
  5137. }
  5138. declare module "babylonjs/Materials/materialDefines" {
  5139. /**
  5140. * Manages the defines for the Material
  5141. */
  5142. export class MaterialDefines {
  5143. private _keys;
  5144. private _isDirty;
  5145. /** @hidden */
  5146. _renderId: number;
  5147. /** @hidden */
  5148. _areLightsDirty: boolean;
  5149. /** @hidden */
  5150. _areAttributesDirty: boolean;
  5151. /** @hidden */
  5152. _areTexturesDirty: boolean;
  5153. /** @hidden */
  5154. _areFresnelDirty: boolean;
  5155. /** @hidden */
  5156. _areMiscDirty: boolean;
  5157. /** @hidden */
  5158. _areImageProcessingDirty: boolean;
  5159. /** @hidden */
  5160. _normals: boolean;
  5161. /** @hidden */
  5162. _uvs: boolean;
  5163. /** @hidden */
  5164. _needNormals: boolean;
  5165. /** @hidden */
  5166. _needUVs: boolean;
  5167. /**
  5168. * Specifies if the material needs to be re-calculated
  5169. */
  5170. readonly isDirty: boolean;
  5171. /**
  5172. * Marks the material to indicate that it has been re-calculated
  5173. */
  5174. markAsProcessed(): void;
  5175. /**
  5176. * Marks the material to indicate that it needs to be re-calculated
  5177. */
  5178. markAsUnprocessed(): void;
  5179. /**
  5180. * Marks the material to indicate all of its defines need to be re-calculated
  5181. */
  5182. markAllAsDirty(): void;
  5183. /**
  5184. * Marks the material to indicate that image processing needs to be re-calculated
  5185. */
  5186. markAsImageProcessingDirty(): void;
  5187. /**
  5188. * Marks the material to indicate the lights need to be re-calculated
  5189. */
  5190. markAsLightDirty(): void;
  5191. /**
  5192. * Marks the attribute state as changed
  5193. */
  5194. markAsAttributesDirty(): void;
  5195. /**
  5196. * Marks the texture state as changed
  5197. */
  5198. markAsTexturesDirty(): void;
  5199. /**
  5200. * Marks the fresnel state as changed
  5201. */
  5202. markAsFresnelDirty(): void;
  5203. /**
  5204. * Marks the misc state as changed
  5205. */
  5206. markAsMiscDirty(): void;
  5207. /**
  5208. * Rebuilds the material defines
  5209. */
  5210. rebuild(): void;
  5211. /**
  5212. * Specifies if two material defines are equal
  5213. * @param other - A material define instance to compare to
  5214. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5215. */
  5216. isEqual(other: MaterialDefines): boolean;
  5217. /**
  5218. * Clones this instance's defines to another instance
  5219. * @param other - material defines to clone values to
  5220. */
  5221. cloneTo(other: MaterialDefines): void;
  5222. /**
  5223. * Resets the material define values
  5224. */
  5225. reset(): void;
  5226. /**
  5227. * Converts the material define values to a string
  5228. * @returns - String of material define information
  5229. */
  5230. toString(): string;
  5231. }
  5232. }
  5233. declare module "babylonjs/Engines/IPipelineContext" {
  5234. /**
  5235. * Class used to store and describe the pipeline context associated with an effect
  5236. */
  5237. export interface IPipelineContext {
  5238. /**
  5239. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5240. */
  5241. isAsync: boolean;
  5242. /**
  5243. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5244. */
  5245. isReady: boolean;
  5246. /** @hidden */
  5247. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5248. }
  5249. }
  5250. declare module "babylonjs/Meshes/dataBuffer" {
  5251. /**
  5252. * Class used to store gfx data (like WebGLBuffer)
  5253. */
  5254. export class DataBuffer {
  5255. /**
  5256. * Gets or sets the number of objects referencing this buffer
  5257. */
  5258. references: number;
  5259. /** Gets or sets the size of the underlying buffer */
  5260. capacity: number;
  5261. /**
  5262. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5263. */
  5264. is32Bits: boolean;
  5265. /**
  5266. * Gets the underlying buffer
  5267. */
  5268. readonly underlyingResource: any;
  5269. }
  5270. }
  5271. declare module "babylonjs/Misc/performanceMonitor" {
  5272. /**
  5273. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5274. */
  5275. export class PerformanceMonitor {
  5276. private _enabled;
  5277. private _rollingFrameTime;
  5278. private _lastFrameTimeMs;
  5279. /**
  5280. * constructor
  5281. * @param frameSampleSize The number of samples required to saturate the sliding window
  5282. */
  5283. constructor(frameSampleSize?: number);
  5284. /**
  5285. * Samples current frame
  5286. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5287. */
  5288. sampleFrame(timeMs?: number): void;
  5289. /**
  5290. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5291. */
  5292. readonly averageFrameTime: number;
  5293. /**
  5294. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5295. */
  5296. readonly averageFrameTimeVariance: number;
  5297. /**
  5298. * Returns the frame time of the most recent frame
  5299. */
  5300. readonly instantaneousFrameTime: number;
  5301. /**
  5302. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5303. */
  5304. readonly averageFPS: number;
  5305. /**
  5306. * Returns the average framerate in frames per second using the most recent frame time
  5307. */
  5308. readonly instantaneousFPS: number;
  5309. /**
  5310. * Returns true if enough samples have been taken to completely fill the sliding window
  5311. */
  5312. readonly isSaturated: boolean;
  5313. /**
  5314. * Enables contributions to the sliding window sample set
  5315. */
  5316. enable(): void;
  5317. /**
  5318. * Disables contributions to the sliding window sample set
  5319. * Samples will not be interpolated over the disabled period
  5320. */
  5321. disable(): void;
  5322. /**
  5323. * Returns true if sampling is enabled
  5324. */
  5325. readonly isEnabled: boolean;
  5326. /**
  5327. * Resets performance monitor
  5328. */
  5329. reset(): void;
  5330. }
  5331. /**
  5332. * RollingAverage
  5333. *
  5334. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5335. */
  5336. export class RollingAverage {
  5337. /**
  5338. * Current average
  5339. */
  5340. average: number;
  5341. /**
  5342. * Current variance
  5343. */
  5344. variance: number;
  5345. protected _samples: Array<number>;
  5346. protected _sampleCount: number;
  5347. protected _pos: number;
  5348. protected _m2: number;
  5349. /**
  5350. * constructor
  5351. * @param length The number of samples required to saturate the sliding window
  5352. */
  5353. constructor(length: number);
  5354. /**
  5355. * Adds a sample to the sample set
  5356. * @param v The sample value
  5357. */
  5358. add(v: number): void;
  5359. /**
  5360. * Returns previously added values or null if outside of history or outside the sliding window domain
  5361. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5362. * @return Value previously recorded with add() or null if outside of range
  5363. */
  5364. history(i: number): number;
  5365. /**
  5366. * Returns true if enough samples have been taken to completely fill the sliding window
  5367. * @return true if sample-set saturated
  5368. */
  5369. isSaturated(): boolean;
  5370. /**
  5371. * Resets the rolling average (equivalent to 0 samples taken so far)
  5372. */
  5373. reset(): void;
  5374. /**
  5375. * Wraps a value around the sample range boundaries
  5376. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5377. * @return Wrapped position in sample range
  5378. */
  5379. protected _wrapPosition(i: number): number;
  5380. }
  5381. }
  5382. declare module "babylonjs/Misc/stringDictionary" {
  5383. import { Nullable } from "babylonjs/types";
  5384. /**
  5385. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5386. * The underlying implementation relies on an associative array to ensure the best performances.
  5387. * The value can be anything including 'null' but except 'undefined'
  5388. */
  5389. export class StringDictionary<T> {
  5390. /**
  5391. * This will clear this dictionary and copy the content from the 'source' one.
  5392. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5393. * @param source the dictionary to take the content from and copy to this dictionary
  5394. */
  5395. copyFrom(source: StringDictionary<T>): void;
  5396. /**
  5397. * Get a value based from its key
  5398. * @param key the given key to get the matching value from
  5399. * @return the value if found, otherwise undefined is returned
  5400. */
  5401. get(key: string): T | undefined;
  5402. /**
  5403. * Get a value from its key or add it if it doesn't exist.
  5404. * This method will ensure you that a given key/data will be present in the dictionary.
  5405. * @param key the given key to get the matching value from
  5406. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5407. * The factory will only be invoked if there's no data for the given key.
  5408. * @return the value corresponding to the key.
  5409. */
  5410. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5411. /**
  5412. * Get a value from its key if present in the dictionary otherwise add it
  5413. * @param key the key to get the value from
  5414. * @param val if there's no such key/value pair in the dictionary add it with this value
  5415. * @return the value corresponding to the key
  5416. */
  5417. getOrAdd(key: string, val: T): T;
  5418. /**
  5419. * Check if there's a given key in the dictionary
  5420. * @param key the key to check for
  5421. * @return true if the key is present, false otherwise
  5422. */
  5423. contains(key: string): boolean;
  5424. /**
  5425. * Add a new key and its corresponding value
  5426. * @param key the key to add
  5427. * @param value the value corresponding to the key
  5428. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5429. */
  5430. add(key: string, value: T): boolean;
  5431. /**
  5432. * Update a specific value associated to a key
  5433. * @param key defines the key to use
  5434. * @param value defines the value to store
  5435. * @returns true if the value was updated (or false if the key was not found)
  5436. */
  5437. set(key: string, value: T): boolean;
  5438. /**
  5439. * Get the element of the given key and remove it from the dictionary
  5440. * @param key defines the key to search
  5441. * @returns the value associated with the key or null if not found
  5442. */
  5443. getAndRemove(key: string): Nullable<T>;
  5444. /**
  5445. * Remove a key/value from the dictionary.
  5446. * @param key the key to remove
  5447. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5448. */
  5449. remove(key: string): boolean;
  5450. /**
  5451. * Clear the whole content of the dictionary
  5452. */
  5453. clear(): void;
  5454. /**
  5455. * Gets the current count
  5456. */
  5457. readonly count: number;
  5458. /**
  5459. * Execute a callback on each key/val of the dictionary.
  5460. * Note that you can remove any element in this dictionary in the callback implementation
  5461. * @param callback the callback to execute on a given key/value pair
  5462. */
  5463. forEach(callback: (key: string, val: T) => void): void;
  5464. /**
  5465. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5466. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5467. * Note that you can remove any element in this dictionary in the callback implementation
  5468. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5469. * @returns the first item
  5470. */
  5471. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5472. private _count;
  5473. private _data;
  5474. }
  5475. }
  5476. declare module "babylonjs/Misc/promise" {
  5477. /**
  5478. * Helper class that provides a small promise polyfill
  5479. */
  5480. export class PromisePolyfill {
  5481. /**
  5482. * Static function used to check if the polyfill is required
  5483. * If this is the case then the function will inject the polyfill to window.Promise
  5484. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5485. */
  5486. static Apply(force?: boolean): void;
  5487. }
  5488. }
  5489. declare module "babylonjs/Meshes/buffer" {
  5490. import { Nullable, DataArray } from "babylonjs/types";
  5491. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5492. /**
  5493. * Class used to store data that will be store in GPU memory
  5494. */
  5495. export class Buffer {
  5496. private _engine;
  5497. private _buffer;
  5498. /** @hidden */
  5499. _data: Nullable<DataArray>;
  5500. private _updatable;
  5501. private _instanced;
  5502. /**
  5503. * Gets the byte stride.
  5504. */
  5505. readonly byteStride: number;
  5506. /**
  5507. * Constructor
  5508. * @param engine the engine
  5509. * @param data the data to use for this buffer
  5510. * @param updatable whether the data is updatable
  5511. * @param stride the stride (optional)
  5512. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5513. * @param instanced whether the buffer is instanced (optional)
  5514. * @param useBytes set to true if the stride in in bytes (optional)
  5515. */
  5516. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5517. /**
  5518. * Create a new VertexBuffer based on the current buffer
  5519. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5520. * @param offset defines offset in the buffer (0 by default)
  5521. * @param size defines the size in floats of attributes (position is 3 for instance)
  5522. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5523. * @param instanced defines if the vertex buffer contains indexed data
  5524. * @param useBytes defines if the offset and stride are in bytes
  5525. * @returns the new vertex buffer
  5526. */
  5527. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5528. /**
  5529. * Gets a boolean indicating if the Buffer is updatable?
  5530. * @returns true if the buffer is updatable
  5531. */
  5532. isUpdatable(): boolean;
  5533. /**
  5534. * Gets current buffer's data
  5535. * @returns a DataArray or null
  5536. */
  5537. getData(): Nullable<DataArray>;
  5538. /**
  5539. * Gets underlying native buffer
  5540. * @returns underlying native buffer
  5541. */
  5542. getBuffer(): Nullable<DataBuffer>;
  5543. /**
  5544. * Gets the stride in float32 units (i.e. byte stride / 4).
  5545. * May not be an integer if the byte stride is not divisible by 4.
  5546. * DEPRECATED. Use byteStride instead.
  5547. * @returns the stride in float32 units
  5548. */
  5549. getStrideSize(): number;
  5550. /**
  5551. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5552. * @param data defines the data to store
  5553. */
  5554. create(data?: Nullable<DataArray>): void;
  5555. /** @hidden */
  5556. _rebuild(): void;
  5557. /**
  5558. * Update current buffer data
  5559. * @param data defines the data to store
  5560. */
  5561. update(data: DataArray): void;
  5562. /**
  5563. * Updates the data directly.
  5564. * @param data the new data
  5565. * @param offset the new offset
  5566. * @param vertexCount the vertex count (optional)
  5567. * @param useBytes set to true if the offset is in bytes
  5568. */
  5569. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5570. /**
  5571. * Release all resources
  5572. */
  5573. dispose(): void;
  5574. }
  5575. /**
  5576. * Specialized buffer used to store vertex data
  5577. */
  5578. export class VertexBuffer {
  5579. /** @hidden */
  5580. _buffer: Buffer;
  5581. private _kind;
  5582. private _size;
  5583. private _ownsBuffer;
  5584. private _instanced;
  5585. private _instanceDivisor;
  5586. /**
  5587. * The byte type.
  5588. */
  5589. static readonly BYTE: number;
  5590. /**
  5591. * The unsigned byte type.
  5592. */
  5593. static readonly UNSIGNED_BYTE: number;
  5594. /**
  5595. * The short type.
  5596. */
  5597. static readonly SHORT: number;
  5598. /**
  5599. * The unsigned short type.
  5600. */
  5601. static readonly UNSIGNED_SHORT: number;
  5602. /**
  5603. * The integer type.
  5604. */
  5605. static readonly INT: number;
  5606. /**
  5607. * The unsigned integer type.
  5608. */
  5609. static readonly UNSIGNED_INT: number;
  5610. /**
  5611. * The float type.
  5612. */
  5613. static readonly FLOAT: number;
  5614. /**
  5615. * Gets or sets the instance divisor when in instanced mode
  5616. */
  5617. instanceDivisor: number;
  5618. /**
  5619. * Gets the byte stride.
  5620. */
  5621. readonly byteStride: number;
  5622. /**
  5623. * Gets the byte offset.
  5624. */
  5625. readonly byteOffset: number;
  5626. /**
  5627. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5628. */
  5629. readonly normalized: boolean;
  5630. /**
  5631. * Gets the data type of each component in the array.
  5632. */
  5633. readonly type: number;
  5634. /**
  5635. * Constructor
  5636. * @param engine the engine
  5637. * @param data the data to use for this vertex buffer
  5638. * @param kind the vertex buffer kind
  5639. * @param updatable whether the data is updatable
  5640. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5641. * @param stride the stride (optional)
  5642. * @param instanced whether the buffer is instanced (optional)
  5643. * @param offset the offset of the data (optional)
  5644. * @param size the number of components (optional)
  5645. * @param type the type of the component (optional)
  5646. * @param normalized whether the data contains normalized data (optional)
  5647. * @param useBytes set to true if stride and offset are in bytes (optional)
  5648. */
  5649. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5650. /** @hidden */
  5651. _rebuild(): void;
  5652. /**
  5653. * Returns the kind of the VertexBuffer (string)
  5654. * @returns a string
  5655. */
  5656. getKind(): string;
  5657. /**
  5658. * Gets a boolean indicating if the VertexBuffer is updatable?
  5659. * @returns true if the buffer is updatable
  5660. */
  5661. isUpdatable(): boolean;
  5662. /**
  5663. * Gets current buffer's data
  5664. * @returns a DataArray or null
  5665. */
  5666. getData(): Nullable<DataArray>;
  5667. /**
  5668. * Gets underlying native buffer
  5669. * @returns underlying native buffer
  5670. */
  5671. getBuffer(): Nullable<DataBuffer>;
  5672. /**
  5673. * Gets the stride in float32 units (i.e. byte stride / 4).
  5674. * May not be an integer if the byte stride is not divisible by 4.
  5675. * DEPRECATED. Use byteStride instead.
  5676. * @returns the stride in float32 units
  5677. */
  5678. getStrideSize(): number;
  5679. /**
  5680. * Returns the offset as a multiple of the type byte length.
  5681. * DEPRECATED. Use byteOffset instead.
  5682. * @returns the offset in bytes
  5683. */
  5684. getOffset(): number;
  5685. /**
  5686. * Returns the number of components per vertex attribute (integer)
  5687. * @returns the size in float
  5688. */
  5689. getSize(): number;
  5690. /**
  5691. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5692. * @returns true if this buffer is instanced
  5693. */
  5694. getIsInstanced(): boolean;
  5695. /**
  5696. * Returns the instancing divisor, zero for non-instanced (integer).
  5697. * @returns a number
  5698. */
  5699. getInstanceDivisor(): number;
  5700. /**
  5701. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5702. * @param data defines the data to store
  5703. */
  5704. create(data?: DataArray): void;
  5705. /**
  5706. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5707. * This function will create a new buffer if the current one is not updatable
  5708. * @param data defines the data to store
  5709. */
  5710. update(data: DataArray): void;
  5711. /**
  5712. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5713. * Returns the directly updated WebGLBuffer.
  5714. * @param data the new data
  5715. * @param offset the new offset
  5716. * @param useBytes set to true if the offset is in bytes
  5717. */
  5718. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5719. /**
  5720. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5721. */
  5722. dispose(): void;
  5723. /**
  5724. * Enumerates each value of this vertex buffer as numbers.
  5725. * @param count the number of values to enumerate
  5726. * @param callback the callback function called for each value
  5727. */
  5728. forEach(count: number, callback: (value: number, index: number) => void): void;
  5729. /**
  5730. * Positions
  5731. */
  5732. static readonly PositionKind: string;
  5733. /**
  5734. * Normals
  5735. */
  5736. static readonly NormalKind: string;
  5737. /**
  5738. * Tangents
  5739. */
  5740. static readonly TangentKind: string;
  5741. /**
  5742. * Texture coordinates
  5743. */
  5744. static readonly UVKind: string;
  5745. /**
  5746. * Texture coordinates 2
  5747. */
  5748. static readonly UV2Kind: string;
  5749. /**
  5750. * Texture coordinates 3
  5751. */
  5752. static readonly UV3Kind: string;
  5753. /**
  5754. * Texture coordinates 4
  5755. */
  5756. static readonly UV4Kind: string;
  5757. /**
  5758. * Texture coordinates 5
  5759. */
  5760. static readonly UV5Kind: string;
  5761. /**
  5762. * Texture coordinates 6
  5763. */
  5764. static readonly UV6Kind: string;
  5765. /**
  5766. * Colors
  5767. */
  5768. static readonly ColorKind: string;
  5769. /**
  5770. * Matrix indices (for bones)
  5771. */
  5772. static readonly MatricesIndicesKind: string;
  5773. /**
  5774. * Matrix weights (for bones)
  5775. */
  5776. static readonly MatricesWeightsKind: string;
  5777. /**
  5778. * Additional matrix indices (for bones)
  5779. */
  5780. static readonly MatricesIndicesExtraKind: string;
  5781. /**
  5782. * Additional matrix weights (for bones)
  5783. */
  5784. static readonly MatricesWeightsExtraKind: string;
  5785. /**
  5786. * Deduces the stride given a kind.
  5787. * @param kind The kind string to deduce
  5788. * @returns The deduced stride
  5789. */
  5790. static DeduceStride(kind: string): number;
  5791. /**
  5792. * Gets the byte length of the given type.
  5793. * @param type the type
  5794. * @returns the number of bytes
  5795. */
  5796. static GetTypeByteLength(type: number): number;
  5797. /**
  5798. * Enumerates each value of the given parameters as numbers.
  5799. * @param data the data to enumerate
  5800. * @param byteOffset the byte offset of the data
  5801. * @param byteStride the byte stride of the data
  5802. * @param componentCount the number of components per element
  5803. * @param componentType the type of the component
  5804. * @param count the total number of components
  5805. * @param normalized whether the data is normalized
  5806. * @param callback the callback function called for each value
  5807. */
  5808. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5809. private static _GetFloatValue;
  5810. }
  5811. }
  5812. declare module "babylonjs/Maths/sphericalPolynomial" {
  5813. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5814. /**
  5815. * Class representing spherical harmonics coefficients to the 3rd degree
  5816. */
  5817. export class SphericalHarmonics {
  5818. /**
  5819. * Defines whether or not the harmonics have been prescaled for rendering.
  5820. */
  5821. preScaled: boolean;
  5822. /**
  5823. * The l0,0 coefficients of the spherical harmonics
  5824. */
  5825. l00: Vector3;
  5826. /**
  5827. * The l1,-1 coefficients of the spherical harmonics
  5828. */
  5829. l1_1: Vector3;
  5830. /**
  5831. * The l1,0 coefficients of the spherical harmonics
  5832. */
  5833. l10: Vector3;
  5834. /**
  5835. * The l1,1 coefficients of the spherical harmonics
  5836. */
  5837. l11: Vector3;
  5838. /**
  5839. * The l2,-2 coefficients of the spherical harmonics
  5840. */
  5841. l2_2: Vector3;
  5842. /**
  5843. * The l2,-1 coefficients of the spherical harmonics
  5844. */
  5845. l2_1: Vector3;
  5846. /**
  5847. * The l2,0 coefficients of the spherical harmonics
  5848. */
  5849. l20: Vector3;
  5850. /**
  5851. * The l2,1 coefficients of the spherical harmonics
  5852. */
  5853. l21: Vector3;
  5854. /**
  5855. * The l2,2 coefficients of the spherical harmonics
  5856. */
  5857. l22: Vector3;
  5858. /**
  5859. * Adds a light to the spherical harmonics
  5860. * @param direction the direction of the light
  5861. * @param color the color of the light
  5862. * @param deltaSolidAngle the delta solid angle of the light
  5863. */
  5864. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5865. /**
  5866. * Scales the spherical harmonics by the given amount
  5867. * @param scale the amount to scale
  5868. */
  5869. scaleInPlace(scale: number): void;
  5870. /**
  5871. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5872. *
  5873. * ```
  5874. * E_lm = A_l * L_lm
  5875. * ```
  5876. *
  5877. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5878. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5879. * the scaling factors are given in equation 9.
  5880. */
  5881. convertIncidentRadianceToIrradiance(): void;
  5882. /**
  5883. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5884. *
  5885. * ```
  5886. * L = (1/pi) * E * rho
  5887. * ```
  5888. *
  5889. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5890. */
  5891. convertIrradianceToLambertianRadiance(): void;
  5892. /**
  5893. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5894. * required operations at run time.
  5895. *
  5896. * This is simply done by scaling back the SH with Ylm constants parameter.
  5897. * The trigonometric part being applied by the shader at run time.
  5898. */
  5899. preScaleForRendering(): void;
  5900. /**
  5901. * Constructs a spherical harmonics from an array.
  5902. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5903. * @returns the spherical harmonics
  5904. */
  5905. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5906. /**
  5907. * Gets the spherical harmonics from polynomial
  5908. * @param polynomial the spherical polynomial
  5909. * @returns the spherical harmonics
  5910. */
  5911. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5912. }
  5913. /**
  5914. * Class representing spherical polynomial coefficients to the 3rd degree
  5915. */
  5916. export class SphericalPolynomial {
  5917. private _harmonics;
  5918. /**
  5919. * The spherical harmonics used to create the polynomials.
  5920. */
  5921. readonly preScaledHarmonics: SphericalHarmonics;
  5922. /**
  5923. * The x coefficients of the spherical polynomial
  5924. */
  5925. x: Vector3;
  5926. /**
  5927. * The y coefficients of the spherical polynomial
  5928. */
  5929. y: Vector3;
  5930. /**
  5931. * The z coefficients of the spherical polynomial
  5932. */
  5933. z: Vector3;
  5934. /**
  5935. * The xx coefficients of the spherical polynomial
  5936. */
  5937. xx: Vector3;
  5938. /**
  5939. * The yy coefficients of the spherical polynomial
  5940. */
  5941. yy: Vector3;
  5942. /**
  5943. * The zz coefficients of the spherical polynomial
  5944. */
  5945. zz: Vector3;
  5946. /**
  5947. * The xy coefficients of the spherical polynomial
  5948. */
  5949. xy: Vector3;
  5950. /**
  5951. * The yz coefficients of the spherical polynomial
  5952. */
  5953. yz: Vector3;
  5954. /**
  5955. * The zx coefficients of the spherical polynomial
  5956. */
  5957. zx: Vector3;
  5958. /**
  5959. * Adds an ambient color to the spherical polynomial
  5960. * @param color the color to add
  5961. */
  5962. addAmbient(color: Color3): void;
  5963. /**
  5964. * Scales the spherical polynomial by the given amount
  5965. * @param scale the amount to scale
  5966. */
  5967. scaleInPlace(scale: number): void;
  5968. /**
  5969. * Gets the spherical polynomial from harmonics
  5970. * @param harmonics the spherical harmonics
  5971. * @returns the spherical polynomial
  5972. */
  5973. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5974. /**
  5975. * Constructs a spherical polynomial from an array.
  5976. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5977. * @returns the spherical polynomial
  5978. */
  5979. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5980. }
  5981. }
  5982. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5983. import { Nullable } from "babylonjs/types";
  5984. /**
  5985. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5986. */
  5987. export interface CubeMapInfo {
  5988. /**
  5989. * The pixel array for the front face.
  5990. * This is stored in format, left to right, up to down format.
  5991. */
  5992. front: Nullable<ArrayBufferView>;
  5993. /**
  5994. * The pixel array for the back face.
  5995. * This is stored in format, left to right, up to down format.
  5996. */
  5997. back: Nullable<ArrayBufferView>;
  5998. /**
  5999. * The pixel array for the left face.
  6000. * This is stored in format, left to right, up to down format.
  6001. */
  6002. left: Nullable<ArrayBufferView>;
  6003. /**
  6004. * The pixel array for the right face.
  6005. * This is stored in format, left to right, up to down format.
  6006. */
  6007. right: Nullable<ArrayBufferView>;
  6008. /**
  6009. * The pixel array for the up face.
  6010. * This is stored in format, left to right, up to down format.
  6011. */
  6012. up: Nullable<ArrayBufferView>;
  6013. /**
  6014. * The pixel array for the down face.
  6015. * This is stored in format, left to right, up to down format.
  6016. */
  6017. down: Nullable<ArrayBufferView>;
  6018. /**
  6019. * The size of the cubemap stored.
  6020. *
  6021. * Each faces will be size * size pixels.
  6022. */
  6023. size: number;
  6024. /**
  6025. * The format of the texture.
  6026. *
  6027. * RGBA, RGB.
  6028. */
  6029. format: number;
  6030. /**
  6031. * The type of the texture data.
  6032. *
  6033. * UNSIGNED_INT, FLOAT.
  6034. */
  6035. type: number;
  6036. /**
  6037. * Specifies whether the texture is in gamma space.
  6038. */
  6039. gammaSpace: boolean;
  6040. }
  6041. /**
  6042. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6043. */
  6044. export class PanoramaToCubeMapTools {
  6045. private static FACE_FRONT;
  6046. private static FACE_BACK;
  6047. private static FACE_RIGHT;
  6048. private static FACE_LEFT;
  6049. private static FACE_DOWN;
  6050. private static FACE_UP;
  6051. /**
  6052. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6053. *
  6054. * @param float32Array The source data.
  6055. * @param inputWidth The width of the input panorama.
  6056. * @param inputHeight The height of the input panorama.
  6057. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6058. * @return The cubemap data
  6059. */
  6060. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6061. private static CreateCubemapTexture;
  6062. private static CalcProjectionSpherical;
  6063. }
  6064. }
  6065. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6066. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6067. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6068. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6069. /**
  6070. * Helper class dealing with the extraction of spherical polynomial dataArray
  6071. * from a cube map.
  6072. */
  6073. export class CubeMapToSphericalPolynomialTools {
  6074. private static FileFaces;
  6075. /**
  6076. * Converts a texture to the according Spherical Polynomial data.
  6077. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6078. *
  6079. * @param texture The texture to extract the information from.
  6080. * @return The Spherical Polynomial data.
  6081. */
  6082. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6083. /**
  6084. * Converts a cubemap to the according Spherical Polynomial data.
  6085. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6086. *
  6087. * @param cubeInfo The Cube map to extract the information from.
  6088. * @return The Spherical Polynomial data.
  6089. */
  6090. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6091. }
  6092. }
  6093. declare module "babylonjs/Engines/engineStore" {
  6094. import { Nullable } from "babylonjs/types";
  6095. import { Engine } from "babylonjs/Engines/engine";
  6096. import { Scene } from "babylonjs/scene";
  6097. /**
  6098. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6099. * during the life time of the application.
  6100. */
  6101. export class EngineStore {
  6102. /** Gets the list of created engines */
  6103. static Instances: import("babylonjs/Engines/engine").Engine[];
  6104. /** @hidden */
  6105. static _LastCreatedScene: Nullable<Scene>;
  6106. /**
  6107. * Gets the latest created engine
  6108. */
  6109. static readonly LastCreatedEngine: Nullable<Engine>;
  6110. /**
  6111. * Gets the latest created scene
  6112. */
  6113. static readonly LastCreatedScene: Nullable<Scene>;
  6114. }
  6115. }
  6116. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6117. /**
  6118. * Define options used to create a render target texture
  6119. */
  6120. export class RenderTargetCreationOptions {
  6121. /**
  6122. * Specifies is mipmaps must be generated
  6123. */
  6124. generateMipMaps?: boolean;
  6125. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6126. generateDepthBuffer?: boolean;
  6127. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6128. generateStencilBuffer?: boolean;
  6129. /** Defines texture type (int by default) */
  6130. type?: number;
  6131. /** Defines sampling mode (trilinear by default) */
  6132. samplingMode?: number;
  6133. /** Defines format (RGBA by default) */
  6134. format?: number;
  6135. }
  6136. }
  6137. declare module "babylonjs/States/alphaCullingState" {
  6138. /**
  6139. * @hidden
  6140. **/
  6141. export class _AlphaState {
  6142. private _isAlphaBlendDirty;
  6143. private _isBlendFunctionParametersDirty;
  6144. private _isBlendEquationParametersDirty;
  6145. private _isBlendConstantsDirty;
  6146. private _alphaBlend;
  6147. private _blendFunctionParameters;
  6148. private _blendEquationParameters;
  6149. private _blendConstants;
  6150. /**
  6151. * Initializes the state.
  6152. */
  6153. constructor();
  6154. readonly isDirty: boolean;
  6155. alphaBlend: boolean;
  6156. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6157. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6158. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6159. reset(): void;
  6160. apply(gl: WebGLRenderingContext): void;
  6161. }
  6162. }
  6163. declare module "babylonjs/States/depthCullingState" {
  6164. import { Nullable } from "babylonjs/types";
  6165. /**
  6166. * @hidden
  6167. **/
  6168. export class _DepthCullingState {
  6169. private _isDepthTestDirty;
  6170. private _isDepthMaskDirty;
  6171. private _isDepthFuncDirty;
  6172. private _isCullFaceDirty;
  6173. private _isCullDirty;
  6174. private _isZOffsetDirty;
  6175. private _isFrontFaceDirty;
  6176. private _depthTest;
  6177. private _depthMask;
  6178. private _depthFunc;
  6179. private _cull;
  6180. private _cullFace;
  6181. private _zOffset;
  6182. private _frontFace;
  6183. /**
  6184. * Initializes the state.
  6185. */
  6186. constructor();
  6187. readonly isDirty: boolean;
  6188. zOffset: number;
  6189. cullFace: Nullable<number>;
  6190. cull: Nullable<boolean>;
  6191. depthFunc: Nullable<number>;
  6192. depthMask: boolean;
  6193. depthTest: boolean;
  6194. frontFace: Nullable<number>;
  6195. reset(): void;
  6196. apply(gl: WebGLRenderingContext): void;
  6197. }
  6198. }
  6199. declare module "babylonjs/States/stencilState" {
  6200. /**
  6201. * @hidden
  6202. **/
  6203. export class _StencilState {
  6204. /** 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 */
  6205. static readonly ALWAYS: number;
  6206. /** Passed to stencilOperation to specify that stencil value must be kept */
  6207. static readonly KEEP: number;
  6208. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6209. static readonly REPLACE: number;
  6210. private _isStencilTestDirty;
  6211. private _isStencilMaskDirty;
  6212. private _isStencilFuncDirty;
  6213. private _isStencilOpDirty;
  6214. private _stencilTest;
  6215. private _stencilMask;
  6216. private _stencilFunc;
  6217. private _stencilFuncRef;
  6218. private _stencilFuncMask;
  6219. private _stencilOpStencilFail;
  6220. private _stencilOpDepthFail;
  6221. private _stencilOpStencilDepthPass;
  6222. readonly isDirty: boolean;
  6223. stencilFunc: number;
  6224. stencilFuncRef: number;
  6225. stencilFuncMask: number;
  6226. stencilOpStencilFail: number;
  6227. stencilOpDepthFail: number;
  6228. stencilOpStencilDepthPass: number;
  6229. stencilMask: number;
  6230. stencilTest: boolean;
  6231. constructor();
  6232. reset(): void;
  6233. apply(gl: WebGLRenderingContext): void;
  6234. }
  6235. }
  6236. declare module "babylonjs/States/index" {
  6237. export * from "babylonjs/States/alphaCullingState";
  6238. export * from "babylonjs/States/depthCullingState";
  6239. export * from "babylonjs/States/stencilState";
  6240. }
  6241. declare module "babylonjs/Instrumentation/timeToken" {
  6242. import { Nullable } from "babylonjs/types";
  6243. /**
  6244. * @hidden
  6245. **/
  6246. export class _TimeToken {
  6247. _startTimeQuery: Nullable<WebGLQuery>;
  6248. _endTimeQuery: Nullable<WebGLQuery>;
  6249. _timeElapsedQuery: Nullable<WebGLQuery>;
  6250. _timeElapsedQueryEnded: boolean;
  6251. }
  6252. }
  6253. declare module "babylonjs/Materials/Textures/internalTexture" {
  6254. import { Observable } from "babylonjs/Misc/observable";
  6255. import { Nullable, int } from "babylonjs/types";
  6256. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6257. import { Engine } from "babylonjs/Engines/engine";
  6258. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6259. /**
  6260. * Class used to store data associated with WebGL texture data for the engine
  6261. * This class should not be used directly
  6262. */
  6263. export class InternalTexture {
  6264. /** hidden */
  6265. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6266. /**
  6267. * The source of the texture data is unknown
  6268. */
  6269. static DATASOURCE_UNKNOWN: number;
  6270. /**
  6271. * Texture data comes from an URL
  6272. */
  6273. static DATASOURCE_URL: number;
  6274. /**
  6275. * Texture data is only used for temporary storage
  6276. */
  6277. static DATASOURCE_TEMP: number;
  6278. /**
  6279. * Texture data comes from raw data (ArrayBuffer)
  6280. */
  6281. static DATASOURCE_RAW: number;
  6282. /**
  6283. * Texture content is dynamic (video or dynamic texture)
  6284. */
  6285. static DATASOURCE_DYNAMIC: number;
  6286. /**
  6287. * Texture content is generated by rendering to it
  6288. */
  6289. static DATASOURCE_RENDERTARGET: number;
  6290. /**
  6291. * Texture content is part of a multi render target process
  6292. */
  6293. static DATASOURCE_MULTIRENDERTARGET: number;
  6294. /**
  6295. * Texture data comes from a cube data file
  6296. */
  6297. static DATASOURCE_CUBE: number;
  6298. /**
  6299. * Texture data comes from a raw cube data
  6300. */
  6301. static DATASOURCE_CUBERAW: number;
  6302. /**
  6303. * Texture data come from a prefiltered cube data file
  6304. */
  6305. static DATASOURCE_CUBEPREFILTERED: number;
  6306. /**
  6307. * Texture content is raw 3D data
  6308. */
  6309. static DATASOURCE_RAW3D: number;
  6310. /**
  6311. * Texture content is a depth texture
  6312. */
  6313. static DATASOURCE_DEPTHTEXTURE: number;
  6314. /**
  6315. * Texture data comes from a raw cube data encoded with RGBD
  6316. */
  6317. static DATASOURCE_CUBERAW_RGBD: number;
  6318. /**
  6319. * Defines if the texture is ready
  6320. */
  6321. isReady: boolean;
  6322. /**
  6323. * Defines if the texture is a cube texture
  6324. */
  6325. isCube: boolean;
  6326. /**
  6327. * Defines if the texture contains 3D data
  6328. */
  6329. is3D: boolean;
  6330. /**
  6331. * Defines if the texture contains multiview data
  6332. */
  6333. isMultiview: boolean;
  6334. /**
  6335. * Gets the URL used to load this texture
  6336. */
  6337. url: string;
  6338. /**
  6339. * Gets the sampling mode of the texture
  6340. */
  6341. samplingMode: number;
  6342. /**
  6343. * Gets a boolean indicating if the texture needs mipmaps generation
  6344. */
  6345. generateMipMaps: boolean;
  6346. /**
  6347. * Gets the number of samples used by the texture (WebGL2+ only)
  6348. */
  6349. samples: number;
  6350. /**
  6351. * Gets the type of the texture (int, float...)
  6352. */
  6353. type: number;
  6354. /**
  6355. * Gets the format of the texture (RGB, RGBA...)
  6356. */
  6357. format: number;
  6358. /**
  6359. * Observable called when the texture is loaded
  6360. */
  6361. onLoadedObservable: Observable<InternalTexture>;
  6362. /**
  6363. * Gets the width of the texture
  6364. */
  6365. width: number;
  6366. /**
  6367. * Gets the height of the texture
  6368. */
  6369. height: number;
  6370. /**
  6371. * Gets the depth of the texture
  6372. */
  6373. depth: number;
  6374. /**
  6375. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6376. */
  6377. baseWidth: number;
  6378. /**
  6379. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6380. */
  6381. baseHeight: number;
  6382. /**
  6383. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6384. */
  6385. baseDepth: number;
  6386. /**
  6387. * Gets a boolean indicating if the texture is inverted on Y axis
  6388. */
  6389. invertY: boolean;
  6390. /** @hidden */
  6391. _invertVScale: boolean;
  6392. /** @hidden */
  6393. _associatedChannel: number;
  6394. /** @hidden */
  6395. _dataSource: number;
  6396. /** @hidden */
  6397. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6398. /** @hidden */
  6399. _bufferView: Nullable<ArrayBufferView>;
  6400. /** @hidden */
  6401. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6402. /** @hidden */
  6403. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6404. /** @hidden */
  6405. _size: number;
  6406. /** @hidden */
  6407. _extension: string;
  6408. /** @hidden */
  6409. _files: Nullable<string[]>;
  6410. /** @hidden */
  6411. _workingCanvas: Nullable<HTMLCanvasElement>;
  6412. /** @hidden */
  6413. _workingContext: Nullable<CanvasRenderingContext2D>;
  6414. /** @hidden */
  6415. _framebuffer: Nullable<WebGLFramebuffer>;
  6416. /** @hidden */
  6417. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6418. /** @hidden */
  6419. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6420. /** @hidden */
  6421. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6422. /** @hidden */
  6423. _attachments: Nullable<number[]>;
  6424. /** @hidden */
  6425. _cachedCoordinatesMode: Nullable<number>;
  6426. /** @hidden */
  6427. _cachedWrapU: Nullable<number>;
  6428. /** @hidden */
  6429. _cachedWrapV: Nullable<number>;
  6430. /** @hidden */
  6431. _cachedWrapR: Nullable<number>;
  6432. /** @hidden */
  6433. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6434. /** @hidden */
  6435. _isDisabled: boolean;
  6436. /** @hidden */
  6437. _compression: Nullable<string>;
  6438. /** @hidden */
  6439. _generateStencilBuffer: boolean;
  6440. /** @hidden */
  6441. _generateDepthBuffer: boolean;
  6442. /** @hidden */
  6443. _comparisonFunction: number;
  6444. /** @hidden */
  6445. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6446. /** @hidden */
  6447. _lodGenerationScale: number;
  6448. /** @hidden */
  6449. _lodGenerationOffset: number;
  6450. /** @hidden */
  6451. _colorTextureArray: Nullable<WebGLTexture>;
  6452. /** @hidden */
  6453. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6454. /** @hidden */
  6455. _lodTextureHigh: Nullable<BaseTexture>;
  6456. /** @hidden */
  6457. _lodTextureMid: Nullable<BaseTexture>;
  6458. /** @hidden */
  6459. _lodTextureLow: Nullable<BaseTexture>;
  6460. /** @hidden */
  6461. _isRGBD: boolean;
  6462. /** @hidden */
  6463. _webGLTexture: Nullable<WebGLTexture>;
  6464. /** @hidden */
  6465. _references: number;
  6466. private _engine;
  6467. /**
  6468. * Gets the Engine the texture belongs to.
  6469. * @returns The babylon engine
  6470. */
  6471. getEngine(): Engine;
  6472. /**
  6473. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6474. */
  6475. readonly dataSource: number;
  6476. /**
  6477. * Creates a new InternalTexture
  6478. * @param engine defines the engine to use
  6479. * @param dataSource defines the type of data that will be used
  6480. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6481. */
  6482. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6483. /**
  6484. * Increments the number of references (ie. the number of Texture that point to it)
  6485. */
  6486. incrementReferences(): void;
  6487. /**
  6488. * Change the size of the texture (not the size of the content)
  6489. * @param width defines the new width
  6490. * @param height defines the new height
  6491. * @param depth defines the new depth (1 by default)
  6492. */
  6493. updateSize(width: int, height: int, depth?: int): void;
  6494. /** @hidden */
  6495. _rebuild(): void;
  6496. /** @hidden */
  6497. _swapAndDie(target: InternalTexture): void;
  6498. /**
  6499. * Dispose the current allocated resources
  6500. */
  6501. dispose(): void;
  6502. }
  6503. }
  6504. declare module "babylonjs/Animations/easing" {
  6505. /**
  6506. * This represents the main contract an easing function should follow.
  6507. * Easing functions are used throughout the animation system.
  6508. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6509. */
  6510. export interface IEasingFunction {
  6511. /**
  6512. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6513. * of the easing function.
  6514. * The link below provides some of the most common examples of easing functions.
  6515. * @see https://easings.net/
  6516. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6517. * @returns the corresponding value on the curve defined by the easing function
  6518. */
  6519. ease(gradient: number): number;
  6520. }
  6521. /**
  6522. * Base class used for every default easing function.
  6523. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6524. */
  6525. export class EasingFunction implements IEasingFunction {
  6526. /**
  6527. * Interpolation follows the mathematical formula associated with the easing function.
  6528. */
  6529. static readonly EASINGMODE_EASEIN: number;
  6530. /**
  6531. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6532. */
  6533. static readonly EASINGMODE_EASEOUT: number;
  6534. /**
  6535. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6536. */
  6537. static readonly EASINGMODE_EASEINOUT: number;
  6538. private _easingMode;
  6539. /**
  6540. * Sets the easing mode of the current function.
  6541. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6542. */
  6543. setEasingMode(easingMode: number): void;
  6544. /**
  6545. * Gets the current easing mode.
  6546. * @returns the easing mode
  6547. */
  6548. getEasingMode(): number;
  6549. /**
  6550. * @hidden
  6551. */
  6552. easeInCore(gradient: number): number;
  6553. /**
  6554. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6555. * of the easing function.
  6556. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6557. * @returns the corresponding value on the curve defined by the easing function
  6558. */
  6559. ease(gradient: number): number;
  6560. }
  6561. /**
  6562. * Easing function with a circle shape (see link below).
  6563. * @see https://easings.net/#easeInCirc
  6564. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6565. */
  6566. export class CircleEase extends EasingFunction implements IEasingFunction {
  6567. /** @hidden */
  6568. easeInCore(gradient: number): number;
  6569. }
  6570. /**
  6571. * Easing function with a ease back shape (see link below).
  6572. * @see https://easings.net/#easeInBack
  6573. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6574. */
  6575. export class BackEase extends EasingFunction implements IEasingFunction {
  6576. /** Defines the amplitude of the function */
  6577. amplitude: number;
  6578. /**
  6579. * Instantiates a back ease easing
  6580. * @see https://easings.net/#easeInBack
  6581. * @param amplitude Defines the amplitude of the function
  6582. */
  6583. constructor(
  6584. /** Defines the amplitude of the function */
  6585. amplitude?: number);
  6586. /** @hidden */
  6587. easeInCore(gradient: number): number;
  6588. }
  6589. /**
  6590. * Easing function with a bouncing shape (see link below).
  6591. * @see https://easings.net/#easeInBounce
  6592. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6593. */
  6594. export class BounceEase extends EasingFunction implements IEasingFunction {
  6595. /** Defines the number of bounces */
  6596. bounces: number;
  6597. /** Defines the amplitude of the bounce */
  6598. bounciness: number;
  6599. /**
  6600. * Instantiates a bounce easing
  6601. * @see https://easings.net/#easeInBounce
  6602. * @param bounces Defines the number of bounces
  6603. * @param bounciness Defines the amplitude of the bounce
  6604. */
  6605. constructor(
  6606. /** Defines the number of bounces */
  6607. bounces?: number,
  6608. /** Defines the amplitude of the bounce */
  6609. bounciness?: number);
  6610. /** @hidden */
  6611. easeInCore(gradient: number): number;
  6612. }
  6613. /**
  6614. * Easing function with a power of 3 shape (see link below).
  6615. * @see https://easings.net/#easeInCubic
  6616. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6617. */
  6618. export class CubicEase extends EasingFunction implements IEasingFunction {
  6619. /** @hidden */
  6620. easeInCore(gradient: number): number;
  6621. }
  6622. /**
  6623. * Easing function with an elastic shape (see link below).
  6624. * @see https://easings.net/#easeInElastic
  6625. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6626. */
  6627. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6628. /** Defines the number of oscillations*/
  6629. oscillations: number;
  6630. /** Defines the amplitude of the oscillations*/
  6631. springiness: number;
  6632. /**
  6633. * Instantiates an elastic easing function
  6634. * @see https://easings.net/#easeInElastic
  6635. * @param oscillations Defines the number of oscillations
  6636. * @param springiness Defines the amplitude of the oscillations
  6637. */
  6638. constructor(
  6639. /** Defines the number of oscillations*/
  6640. oscillations?: number,
  6641. /** Defines the amplitude of the oscillations*/
  6642. springiness?: number);
  6643. /** @hidden */
  6644. easeInCore(gradient: number): number;
  6645. }
  6646. /**
  6647. * Easing function with an exponential shape (see link below).
  6648. * @see https://easings.net/#easeInExpo
  6649. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6650. */
  6651. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6652. /** Defines the exponent of the function */
  6653. exponent: number;
  6654. /**
  6655. * Instantiates an exponential easing function
  6656. * @see https://easings.net/#easeInExpo
  6657. * @param exponent Defines the exponent of the function
  6658. */
  6659. constructor(
  6660. /** Defines the exponent of the function */
  6661. exponent?: number);
  6662. /** @hidden */
  6663. easeInCore(gradient: number): number;
  6664. }
  6665. /**
  6666. * Easing function with a power shape (see link below).
  6667. * @see https://easings.net/#easeInQuad
  6668. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6669. */
  6670. export class PowerEase extends EasingFunction implements IEasingFunction {
  6671. /** Defines the power of the function */
  6672. power: number;
  6673. /**
  6674. * Instantiates an power base easing function
  6675. * @see https://easings.net/#easeInQuad
  6676. * @param power Defines the power of the function
  6677. */
  6678. constructor(
  6679. /** Defines the power of the function */
  6680. power?: number);
  6681. /** @hidden */
  6682. easeInCore(gradient: number): number;
  6683. }
  6684. /**
  6685. * Easing function with a power of 2 shape (see link below).
  6686. * @see https://easings.net/#easeInQuad
  6687. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6688. */
  6689. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6690. /** @hidden */
  6691. easeInCore(gradient: number): number;
  6692. }
  6693. /**
  6694. * Easing function with a power of 4 shape (see link below).
  6695. * @see https://easings.net/#easeInQuart
  6696. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6697. */
  6698. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6699. /** @hidden */
  6700. easeInCore(gradient: number): number;
  6701. }
  6702. /**
  6703. * Easing function with a power of 5 shape (see link below).
  6704. * @see https://easings.net/#easeInQuint
  6705. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6706. */
  6707. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6708. /** @hidden */
  6709. easeInCore(gradient: number): number;
  6710. }
  6711. /**
  6712. * Easing function with a sin shape (see link below).
  6713. * @see https://easings.net/#easeInSine
  6714. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6715. */
  6716. export class SineEase extends EasingFunction implements IEasingFunction {
  6717. /** @hidden */
  6718. easeInCore(gradient: number): number;
  6719. }
  6720. /**
  6721. * Easing function with a bezier shape (see link below).
  6722. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6723. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6724. */
  6725. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6726. /** Defines the x component of the start tangent in the bezier curve */
  6727. x1: number;
  6728. /** Defines the y component of the start tangent in the bezier curve */
  6729. y1: number;
  6730. /** Defines the x component of the end tangent in the bezier curve */
  6731. x2: number;
  6732. /** Defines the y component of the end tangent in the bezier curve */
  6733. y2: number;
  6734. /**
  6735. * Instantiates a bezier function
  6736. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6737. * @param x1 Defines the x component of the start tangent in the bezier curve
  6738. * @param y1 Defines the y component of the start tangent in the bezier curve
  6739. * @param x2 Defines the x component of the end tangent in the bezier curve
  6740. * @param y2 Defines the y component of the end tangent in the bezier curve
  6741. */
  6742. constructor(
  6743. /** Defines the x component of the start tangent in the bezier curve */
  6744. x1?: number,
  6745. /** Defines the y component of the start tangent in the bezier curve */
  6746. y1?: number,
  6747. /** Defines the x component of the end tangent in the bezier curve */
  6748. x2?: number,
  6749. /** Defines the y component of the end tangent in the bezier curve */
  6750. y2?: number);
  6751. /** @hidden */
  6752. easeInCore(gradient: number): number;
  6753. }
  6754. }
  6755. declare module "babylonjs/Animations/animationKey" {
  6756. /**
  6757. * Defines an interface which represents an animation key frame
  6758. */
  6759. export interface IAnimationKey {
  6760. /**
  6761. * Frame of the key frame
  6762. */
  6763. frame: number;
  6764. /**
  6765. * Value at the specifies key frame
  6766. */
  6767. value: any;
  6768. /**
  6769. * The input tangent for the cubic hermite spline
  6770. */
  6771. inTangent?: any;
  6772. /**
  6773. * The output tangent for the cubic hermite spline
  6774. */
  6775. outTangent?: any;
  6776. /**
  6777. * The animation interpolation type
  6778. */
  6779. interpolation?: AnimationKeyInterpolation;
  6780. }
  6781. /**
  6782. * Enum for the animation key frame interpolation type
  6783. */
  6784. export enum AnimationKeyInterpolation {
  6785. /**
  6786. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6787. */
  6788. STEP = 1
  6789. }
  6790. }
  6791. declare module "babylonjs/Animations/animationRange" {
  6792. /**
  6793. * Represents the range of an animation
  6794. */
  6795. export class AnimationRange {
  6796. /**The name of the animation range**/
  6797. name: string;
  6798. /**The starting frame of the animation */
  6799. from: number;
  6800. /**The ending frame of the animation*/
  6801. to: number;
  6802. /**
  6803. * Initializes the range of an animation
  6804. * @param name The name of the animation range
  6805. * @param from The starting frame of the animation
  6806. * @param to The ending frame of the animation
  6807. */
  6808. constructor(
  6809. /**The name of the animation range**/
  6810. name: string,
  6811. /**The starting frame of the animation */
  6812. from: number,
  6813. /**The ending frame of the animation*/
  6814. to: number);
  6815. /**
  6816. * Makes a copy of the animation range
  6817. * @returns A copy of the animation range
  6818. */
  6819. clone(): AnimationRange;
  6820. }
  6821. }
  6822. declare module "babylonjs/Animations/animationEvent" {
  6823. /**
  6824. * Composed of a frame, and an action function
  6825. */
  6826. export class AnimationEvent {
  6827. /** The frame for which the event is triggered **/
  6828. frame: number;
  6829. /** The event to perform when triggered **/
  6830. action: (currentFrame: number) => void;
  6831. /** Specifies if the event should be triggered only once**/
  6832. onlyOnce?: boolean | undefined;
  6833. /**
  6834. * Specifies if the animation event is done
  6835. */
  6836. isDone: boolean;
  6837. /**
  6838. * Initializes the animation event
  6839. * @param frame The frame for which the event is triggered
  6840. * @param action The event to perform when triggered
  6841. * @param onlyOnce Specifies if the event should be triggered only once
  6842. */
  6843. constructor(
  6844. /** The frame for which the event is triggered **/
  6845. frame: number,
  6846. /** The event to perform when triggered **/
  6847. action: (currentFrame: number) => void,
  6848. /** Specifies if the event should be triggered only once**/
  6849. onlyOnce?: boolean | undefined);
  6850. /** @hidden */
  6851. _clone(): AnimationEvent;
  6852. }
  6853. }
  6854. declare module "babylonjs/Behaviors/behavior" {
  6855. import { Nullable } from "babylonjs/types";
  6856. /**
  6857. * Interface used to define a behavior
  6858. */
  6859. export interface Behavior<T> {
  6860. /** gets or sets behavior's name */
  6861. name: string;
  6862. /**
  6863. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6864. */
  6865. init(): void;
  6866. /**
  6867. * Called when the behavior is attached to a target
  6868. * @param target defines the target where the behavior is attached to
  6869. */
  6870. attach(target: T): void;
  6871. /**
  6872. * Called when the behavior is detached from its target
  6873. */
  6874. detach(): void;
  6875. }
  6876. /**
  6877. * Interface implemented by classes supporting behaviors
  6878. */
  6879. export interface IBehaviorAware<T> {
  6880. /**
  6881. * Attach a behavior
  6882. * @param behavior defines the behavior to attach
  6883. * @returns the current host
  6884. */
  6885. addBehavior(behavior: Behavior<T>): T;
  6886. /**
  6887. * Remove a behavior from the current object
  6888. * @param behavior defines the behavior to detach
  6889. * @returns the current host
  6890. */
  6891. removeBehavior(behavior: Behavior<T>): T;
  6892. /**
  6893. * Gets a behavior using its name to search
  6894. * @param name defines the name to search
  6895. * @returns the behavior or null if not found
  6896. */
  6897. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6898. }
  6899. }
  6900. declare module "babylonjs/Collisions/intersectionInfo" {
  6901. import { Nullable } from "babylonjs/types";
  6902. /**
  6903. * @hidden
  6904. */
  6905. export class IntersectionInfo {
  6906. bu: Nullable<number>;
  6907. bv: Nullable<number>;
  6908. distance: number;
  6909. faceId: number;
  6910. subMeshId: number;
  6911. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6912. }
  6913. }
  6914. declare module "babylonjs/Culling/boundingSphere" {
  6915. import { DeepImmutable } from "babylonjs/types";
  6916. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6917. /**
  6918. * Class used to store bounding sphere information
  6919. */
  6920. export class BoundingSphere {
  6921. /**
  6922. * Gets the center of the bounding sphere in local space
  6923. */
  6924. readonly center: Vector3;
  6925. /**
  6926. * Radius of the bounding sphere in local space
  6927. */
  6928. radius: number;
  6929. /**
  6930. * Gets the center of the bounding sphere in world space
  6931. */
  6932. readonly centerWorld: Vector3;
  6933. /**
  6934. * Radius of the bounding sphere in world space
  6935. */
  6936. radiusWorld: number;
  6937. /**
  6938. * Gets the minimum vector in local space
  6939. */
  6940. readonly minimum: Vector3;
  6941. /**
  6942. * Gets the maximum vector in local space
  6943. */
  6944. readonly maximum: Vector3;
  6945. private _worldMatrix;
  6946. private static readonly TmpVector3;
  6947. /**
  6948. * Creates a new bounding sphere
  6949. * @param min defines the minimum vector (in local space)
  6950. * @param max defines the maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6954. /**
  6955. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6956. * @param min defines the new minimum vector (in local space)
  6957. * @param max defines the new maximum vector (in local space)
  6958. * @param worldMatrix defines the new world matrix
  6959. */
  6960. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6961. /**
  6962. * Scale the current bounding sphere by applying a scale factor
  6963. * @param factor defines the scale factor to apply
  6964. * @returns the current bounding box
  6965. */
  6966. scale(factor: number): BoundingSphere;
  6967. /**
  6968. * Gets the world matrix of the bounding box
  6969. * @returns a matrix
  6970. */
  6971. getWorldMatrix(): DeepImmutable<Matrix>;
  6972. /** @hidden */
  6973. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6974. /**
  6975. * Tests if the bounding sphere is intersecting the frustum planes
  6976. * @param frustumPlanes defines the frustum planes to test
  6977. * @returns true if there is an intersection
  6978. */
  6979. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6980. /**
  6981. * Tests if the bounding sphere center is in between the frustum planes.
  6982. * Used for optimistic fast inclusion.
  6983. * @param frustumPlanes defines the frustum planes to test
  6984. * @returns true if the sphere center is in between the frustum planes
  6985. */
  6986. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6987. /**
  6988. * Tests if a point is inside the bounding sphere
  6989. * @param point defines the point to test
  6990. * @returns true if the point is inside the bounding sphere
  6991. */
  6992. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6993. /**
  6994. * Checks if two sphere intersct
  6995. * @param sphere0 sphere 0
  6996. * @param sphere1 sphere 1
  6997. * @returns true if the speres intersect
  6998. */
  6999. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7000. }
  7001. }
  7002. declare module "babylonjs/Culling/boundingBox" {
  7003. import { DeepImmutable } from "babylonjs/types";
  7004. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7005. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7006. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7007. /**
  7008. * Class used to store bounding box information
  7009. */
  7010. export class BoundingBox implements ICullable {
  7011. /**
  7012. * Gets the 8 vectors representing the bounding box in local space
  7013. */
  7014. readonly vectors: Vector3[];
  7015. /**
  7016. * Gets the center of the bounding box in local space
  7017. */
  7018. readonly center: Vector3;
  7019. /**
  7020. * Gets the center of the bounding box in world space
  7021. */
  7022. readonly centerWorld: Vector3;
  7023. /**
  7024. * Gets the extend size in local space
  7025. */
  7026. readonly extendSize: Vector3;
  7027. /**
  7028. * Gets the extend size in world space
  7029. */
  7030. readonly extendSizeWorld: Vector3;
  7031. /**
  7032. * Gets the OBB (object bounding box) directions
  7033. */
  7034. readonly directions: Vector3[];
  7035. /**
  7036. * Gets the 8 vectors representing the bounding box in world space
  7037. */
  7038. readonly vectorsWorld: Vector3[];
  7039. /**
  7040. * Gets the minimum vector in world space
  7041. */
  7042. readonly minimumWorld: Vector3;
  7043. /**
  7044. * Gets the maximum vector in world space
  7045. */
  7046. readonly maximumWorld: Vector3;
  7047. /**
  7048. * Gets the minimum vector in local space
  7049. */
  7050. readonly minimum: Vector3;
  7051. /**
  7052. * Gets the maximum vector in local space
  7053. */
  7054. readonly maximum: Vector3;
  7055. private _worldMatrix;
  7056. private static readonly TmpVector3;
  7057. /**
  7058. * @hidden
  7059. */
  7060. _tag: number;
  7061. /**
  7062. * Creates a new bounding box
  7063. * @param min defines the minimum vector (in local space)
  7064. * @param max defines the maximum vector (in local space)
  7065. * @param worldMatrix defines the new world matrix
  7066. */
  7067. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7068. /**
  7069. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7070. * @param min defines the new minimum vector (in local space)
  7071. * @param max defines the new maximum vector (in local space)
  7072. * @param worldMatrix defines the new world matrix
  7073. */
  7074. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7075. /**
  7076. * Scale the current bounding box by applying a scale factor
  7077. * @param factor defines the scale factor to apply
  7078. * @returns the current bounding box
  7079. */
  7080. scale(factor: number): BoundingBox;
  7081. /**
  7082. * Gets the world matrix of the bounding box
  7083. * @returns a matrix
  7084. */
  7085. getWorldMatrix(): DeepImmutable<Matrix>;
  7086. /** @hidden */
  7087. _update(world: DeepImmutable<Matrix>): void;
  7088. /**
  7089. * Tests if the bounding box is intersecting the frustum planes
  7090. * @param frustumPlanes defines the frustum planes to test
  7091. * @returns true if there is an intersection
  7092. */
  7093. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7094. /**
  7095. * Tests if the bounding box is entirely inside the frustum planes
  7096. * @param frustumPlanes defines the frustum planes to test
  7097. * @returns true if there is an inclusion
  7098. */
  7099. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7100. /**
  7101. * Tests if a point is inside the bounding box
  7102. * @param point defines the point to test
  7103. * @returns true if the point is inside the bounding box
  7104. */
  7105. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7106. /**
  7107. * Tests if the bounding box intersects with a bounding sphere
  7108. * @param sphere defines the sphere to test
  7109. * @returns true if there is an intersection
  7110. */
  7111. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7112. /**
  7113. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7114. * @param min defines the min vector to use
  7115. * @param max defines the max vector to use
  7116. * @returns true if there is an intersection
  7117. */
  7118. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7119. /**
  7120. * Tests if two bounding boxes are intersections
  7121. * @param box0 defines the first box to test
  7122. * @param box1 defines the second box to test
  7123. * @returns true if there is an intersection
  7124. */
  7125. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7126. /**
  7127. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7128. * @param minPoint defines the minimum vector of the bounding box
  7129. * @param maxPoint defines the maximum vector of the bounding box
  7130. * @param sphereCenter defines the sphere center
  7131. * @param sphereRadius defines the sphere radius
  7132. * @returns true if there is an intersection
  7133. */
  7134. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7135. /**
  7136. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7137. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7138. * @param frustumPlanes defines the frustum planes to test
  7139. * @return true if there is an inclusion
  7140. */
  7141. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7142. /**
  7143. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7144. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7145. * @param frustumPlanes defines the frustum planes to test
  7146. * @return true if there is an intersection
  7147. */
  7148. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7149. }
  7150. }
  7151. declare module "babylonjs/Collisions/collider" {
  7152. import { Nullable, IndicesArray } from "babylonjs/types";
  7153. import { Vector3, Plane } from "babylonjs/Maths/math";
  7154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7155. /** @hidden */
  7156. export class Collider {
  7157. /** Define if a collision was found */
  7158. collisionFound: boolean;
  7159. /**
  7160. * Define last intersection point in local space
  7161. */
  7162. intersectionPoint: Vector3;
  7163. /**
  7164. * Define last collided mesh
  7165. */
  7166. collidedMesh: Nullable<AbstractMesh>;
  7167. private _collisionPoint;
  7168. private _planeIntersectionPoint;
  7169. private _tempVector;
  7170. private _tempVector2;
  7171. private _tempVector3;
  7172. private _tempVector4;
  7173. private _edge;
  7174. private _baseToVertex;
  7175. private _destinationPoint;
  7176. private _slidePlaneNormal;
  7177. private _displacementVector;
  7178. /** @hidden */
  7179. _radius: Vector3;
  7180. /** @hidden */
  7181. _retry: number;
  7182. private _velocity;
  7183. private _basePoint;
  7184. private _epsilon;
  7185. /** @hidden */
  7186. _velocityWorldLength: number;
  7187. /** @hidden */
  7188. _basePointWorld: Vector3;
  7189. private _velocityWorld;
  7190. private _normalizedVelocity;
  7191. /** @hidden */
  7192. _initialVelocity: Vector3;
  7193. /** @hidden */
  7194. _initialPosition: Vector3;
  7195. private _nearestDistance;
  7196. private _collisionMask;
  7197. collisionMask: number;
  7198. /**
  7199. * Gets the plane normal used to compute the sliding response (in local space)
  7200. */
  7201. readonly slidePlaneNormal: Vector3;
  7202. /** @hidden */
  7203. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7204. /** @hidden */
  7205. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7206. /** @hidden */
  7207. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7208. /** @hidden */
  7209. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7210. /** @hidden */
  7211. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7212. /** @hidden */
  7213. _getResponse(pos: Vector3, vel: Vector3): void;
  7214. }
  7215. }
  7216. declare module "babylonjs/Culling/boundingInfo" {
  7217. import { DeepImmutable } from "babylonjs/types";
  7218. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7219. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7220. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7221. import { Collider } from "babylonjs/Collisions/collider";
  7222. /**
  7223. * Interface for cullable objects
  7224. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7225. */
  7226. export interface ICullable {
  7227. /**
  7228. * Checks if the object or part of the object is in the frustum
  7229. * @param frustumPlanes Camera near/planes
  7230. * @returns true if the object is in frustum otherwise false
  7231. */
  7232. isInFrustum(frustumPlanes: Plane[]): boolean;
  7233. /**
  7234. * Checks if a cullable object (mesh...) is in the camera frustum
  7235. * Unlike isInFrustum this cheks the full bounding box
  7236. * @param frustumPlanes Camera near/planes
  7237. * @returns true if the object is in frustum otherwise false
  7238. */
  7239. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7240. }
  7241. /**
  7242. * Info for a bounding data of a mesh
  7243. */
  7244. export class BoundingInfo implements ICullable {
  7245. /**
  7246. * Bounding box for the mesh
  7247. */
  7248. readonly boundingBox: BoundingBox;
  7249. /**
  7250. * Bounding sphere for the mesh
  7251. */
  7252. readonly boundingSphere: BoundingSphere;
  7253. private _isLocked;
  7254. private static readonly TmpVector3;
  7255. /**
  7256. * Constructs bounding info
  7257. * @param minimum min vector of the bounding box/sphere
  7258. * @param maximum max vector of the bounding box/sphere
  7259. * @param worldMatrix defines the new world matrix
  7260. */
  7261. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7262. /**
  7263. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7264. * @param min defines the new minimum vector (in local space)
  7265. * @param max defines the new maximum vector (in local space)
  7266. * @param worldMatrix defines the new world matrix
  7267. */
  7268. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7269. /**
  7270. * min vector of the bounding box/sphere
  7271. */
  7272. readonly minimum: Vector3;
  7273. /**
  7274. * max vector of the bounding box/sphere
  7275. */
  7276. readonly maximum: Vector3;
  7277. /**
  7278. * If the info is locked and won't be updated to avoid perf overhead
  7279. */
  7280. isLocked: boolean;
  7281. /**
  7282. * Updates the bounding sphere and box
  7283. * @param world world matrix to be used to update
  7284. */
  7285. update(world: DeepImmutable<Matrix>): void;
  7286. /**
  7287. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7288. * @param center New center of the bounding info
  7289. * @param extend New extend of the bounding info
  7290. * @returns the current bounding info
  7291. */
  7292. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7293. /**
  7294. * Scale the current bounding info by applying a scale factor
  7295. * @param factor defines the scale factor to apply
  7296. * @returns the current bounding info
  7297. */
  7298. scale(factor: number): BoundingInfo;
  7299. /**
  7300. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7301. * @param frustumPlanes defines the frustum to test
  7302. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7303. * @returns true if the bounding info is in the frustum planes
  7304. */
  7305. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7306. /**
  7307. * Gets the world distance between the min and max points of the bounding box
  7308. */
  7309. readonly diagonalLength: number;
  7310. /**
  7311. * Checks if a cullable object (mesh...) is in the camera frustum
  7312. * Unlike isInFrustum this cheks the full bounding box
  7313. * @param frustumPlanes Camera near/planes
  7314. * @returns true if the object is in frustum otherwise false
  7315. */
  7316. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7317. /** @hidden */
  7318. _checkCollision(collider: Collider): boolean;
  7319. /**
  7320. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7321. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7322. * @param point the point to check intersection with
  7323. * @returns if the point intersects
  7324. */
  7325. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7326. /**
  7327. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7328. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7329. * @param boundingInfo the bounding info to check intersection with
  7330. * @param precise if the intersection should be done using OBB
  7331. * @returns if the bounding info intersects
  7332. */
  7333. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7334. }
  7335. }
  7336. declare module "babylonjs/Misc/smartArray" {
  7337. /**
  7338. * Defines an array and its length.
  7339. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7340. */
  7341. export interface ISmartArrayLike<T> {
  7342. /**
  7343. * The data of the array.
  7344. */
  7345. data: Array<T>;
  7346. /**
  7347. * The active length of the array.
  7348. */
  7349. length: number;
  7350. }
  7351. /**
  7352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7353. */
  7354. export class SmartArray<T> implements ISmartArrayLike<T> {
  7355. /**
  7356. * The full set of data from the array.
  7357. */
  7358. data: Array<T>;
  7359. /**
  7360. * The active length of the array.
  7361. */
  7362. length: number;
  7363. protected _id: number;
  7364. /**
  7365. * Instantiates a Smart Array.
  7366. * @param capacity defines the default capacity of the array.
  7367. */
  7368. constructor(capacity: number);
  7369. /**
  7370. * Pushes a value at the end of the active data.
  7371. * @param value defines the object to push in the array.
  7372. */
  7373. push(value: T): void;
  7374. /**
  7375. * Iterates over the active data and apply the lambda to them.
  7376. * @param func defines the action to apply on each value.
  7377. */
  7378. forEach(func: (content: T) => void): void;
  7379. /**
  7380. * Sorts the full sets of data.
  7381. * @param compareFn defines the comparison function to apply.
  7382. */
  7383. sort(compareFn: (a: T, b: T) => number): void;
  7384. /**
  7385. * Resets the active data to an empty array.
  7386. */
  7387. reset(): void;
  7388. /**
  7389. * Releases all the data from the array as well as the array.
  7390. */
  7391. dispose(): void;
  7392. /**
  7393. * Concats the active data with a given array.
  7394. * @param array defines the data to concatenate with.
  7395. */
  7396. concat(array: any): void;
  7397. /**
  7398. * Returns the position of a value in the active data.
  7399. * @param value defines the value to find the index for
  7400. * @returns the index if found in the active data otherwise -1
  7401. */
  7402. indexOf(value: T): number;
  7403. /**
  7404. * Returns whether an element is part of the active data.
  7405. * @param value defines the value to look for
  7406. * @returns true if found in the active data otherwise false
  7407. */
  7408. contains(value: T): boolean;
  7409. private static _GlobalId;
  7410. }
  7411. /**
  7412. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7413. * The data in this array can only be present once
  7414. */
  7415. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7416. private _duplicateId;
  7417. /**
  7418. * Pushes a value at the end of the active data.
  7419. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7420. * @param value defines the object to push in the array.
  7421. */
  7422. push(value: T): void;
  7423. /**
  7424. * Pushes a value at the end of the active data.
  7425. * If the data is already present, it won t be added again
  7426. * @param value defines the object to push in the array.
  7427. * @returns true if added false if it was already present
  7428. */
  7429. pushNoDuplicate(value: T): boolean;
  7430. /**
  7431. * Resets the active data to an empty array.
  7432. */
  7433. reset(): void;
  7434. /**
  7435. * Concats the active data with a given array.
  7436. * This ensures no dupplicate will be present in the result.
  7437. * @param array defines the data to concatenate with.
  7438. */
  7439. concatWithNoDuplicate(array: any): void;
  7440. }
  7441. }
  7442. declare module "babylonjs/Materials/multiMaterial" {
  7443. import { Nullable } from "babylonjs/types";
  7444. import { Scene } from "babylonjs/scene";
  7445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7446. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7447. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7448. import { Material } from "babylonjs/Materials/material";
  7449. /**
  7450. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7451. * separate meshes. This can be use to improve performances.
  7452. * @see http://doc.babylonjs.com/how_to/multi_materials
  7453. */
  7454. export class MultiMaterial extends Material {
  7455. private _subMaterials;
  7456. /**
  7457. * Gets or Sets the list of Materials used within the multi material.
  7458. * They need to be ordered according to the submeshes order in the associated mesh
  7459. */
  7460. subMaterials: Nullable<Material>[];
  7461. /**
  7462. * Function used to align with Node.getChildren()
  7463. * @returns the list of Materials used within the multi material
  7464. */
  7465. getChildren(): Nullable<Material>[];
  7466. /**
  7467. * Instantiates a new Multi Material
  7468. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7469. * separate meshes. This can be use to improve performances.
  7470. * @see http://doc.babylonjs.com/how_to/multi_materials
  7471. * @param name Define the name in the scene
  7472. * @param scene Define the scene the material belongs to
  7473. */
  7474. constructor(name: string, scene: Scene);
  7475. private _hookArray;
  7476. /**
  7477. * Get one of the submaterial by its index in the submaterials array
  7478. * @param index The index to look the sub material at
  7479. * @returns The Material if the index has been defined
  7480. */
  7481. getSubMaterial(index: number): Nullable<Material>;
  7482. /**
  7483. * Get the list of active textures for the whole sub materials list.
  7484. * @returns All the textures that will be used during the rendering
  7485. */
  7486. getActiveTextures(): BaseTexture[];
  7487. /**
  7488. * Gets the current class name of the material e.g. "MultiMaterial"
  7489. * Mainly use in serialization.
  7490. * @returns the class name
  7491. */
  7492. getClassName(): string;
  7493. /**
  7494. * Checks if the material is ready to render the requested sub mesh
  7495. * @param mesh Define the mesh the submesh belongs to
  7496. * @param subMesh Define the sub mesh to look readyness for
  7497. * @param useInstances Define whether or not the material is used with instances
  7498. * @returns true if ready, otherwise false
  7499. */
  7500. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7501. /**
  7502. * Clones the current material and its related sub materials
  7503. * @param name Define the name of the newly cloned material
  7504. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7505. * @returns the cloned material
  7506. */
  7507. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7508. /**
  7509. * Serializes the materials into a JSON representation.
  7510. * @returns the JSON representation
  7511. */
  7512. serialize(): any;
  7513. /**
  7514. * Dispose the material and release its associated resources
  7515. * @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)
  7516. * @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)
  7517. * @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)
  7518. */
  7519. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7520. /**
  7521. * Creates a MultiMaterial from parsed MultiMaterial data.
  7522. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7523. * @param scene defines the hosting scene
  7524. * @returns a new MultiMaterial
  7525. */
  7526. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7527. }
  7528. }
  7529. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7530. /**
  7531. * Class used to represent data loading progression
  7532. */
  7533. export class SceneLoaderFlags {
  7534. private static _ForceFullSceneLoadingForIncremental;
  7535. private static _ShowLoadingScreen;
  7536. private static _CleanBoneMatrixWeights;
  7537. private static _loggingLevel;
  7538. /**
  7539. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7540. */
  7541. static ForceFullSceneLoadingForIncremental: boolean;
  7542. /**
  7543. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7544. */
  7545. static ShowLoadingScreen: boolean;
  7546. /**
  7547. * Defines the current logging level (while loading the scene)
  7548. * @ignorenaming
  7549. */
  7550. static loggingLevel: number;
  7551. /**
  7552. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7553. */
  7554. static CleanBoneMatrixWeights: boolean;
  7555. }
  7556. }
  7557. declare module "babylonjs/Meshes/transformNode" {
  7558. import { DeepImmutable } from "babylonjs/types";
  7559. import { Observable } from "babylonjs/Misc/observable";
  7560. import { Nullable } from "babylonjs/types";
  7561. import { Camera } from "babylonjs/Cameras/camera";
  7562. import { Scene } from "babylonjs/scene";
  7563. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7564. import { Node } from "babylonjs/node";
  7565. import { Bone } from "babylonjs/Bones/bone";
  7566. /**
  7567. * 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.
  7568. * @see https://doc.babylonjs.com/how_to/transformnode
  7569. */
  7570. export class TransformNode extends Node {
  7571. /**
  7572. * Object will not rotate to face the camera
  7573. */
  7574. static BILLBOARDMODE_NONE: number;
  7575. /**
  7576. * Object will rotate to face the camera but only on the x axis
  7577. */
  7578. static BILLBOARDMODE_X: number;
  7579. /**
  7580. * Object will rotate to face the camera but only on the y axis
  7581. */
  7582. static BILLBOARDMODE_Y: number;
  7583. /**
  7584. * Object will rotate to face the camera but only on the z axis
  7585. */
  7586. static BILLBOARDMODE_Z: number;
  7587. /**
  7588. * Object will rotate to face the camera
  7589. */
  7590. static BILLBOARDMODE_ALL: number;
  7591. private _forward;
  7592. private _forwardInverted;
  7593. private _up;
  7594. private _right;
  7595. private _rightInverted;
  7596. private _position;
  7597. private _rotation;
  7598. private _rotationQuaternion;
  7599. protected _scaling: Vector3;
  7600. protected _isDirty: boolean;
  7601. private _transformToBoneReferal;
  7602. private _billboardMode;
  7603. /**
  7604. * Gets or sets the billboard mode. Default is 0.
  7605. *
  7606. * | Value | Type | Description |
  7607. * | --- | --- | --- |
  7608. * | 0 | BILLBOARDMODE_NONE | |
  7609. * | 1 | BILLBOARDMODE_X | |
  7610. * | 2 | BILLBOARDMODE_Y | |
  7611. * | 4 | BILLBOARDMODE_Z | |
  7612. * | 7 | BILLBOARDMODE_ALL | |
  7613. *
  7614. */
  7615. billboardMode: number;
  7616. private _preserveParentRotationForBillboard;
  7617. /**
  7618. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7619. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7620. */
  7621. preserveParentRotationForBillboard: boolean;
  7622. /**
  7623. * 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
  7624. */
  7625. scalingDeterminant: number;
  7626. private _infiniteDistance;
  7627. /**
  7628. * Gets or sets the distance of the object to max, often used by skybox
  7629. */
  7630. infiniteDistance: boolean;
  7631. /**
  7632. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7633. * By default the system will update normals to compensate
  7634. */
  7635. ignoreNonUniformScaling: boolean;
  7636. /**
  7637. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  7638. */
  7639. reIntegrateRotationIntoRotationQuaternion: boolean;
  7640. /** @hidden */
  7641. _poseMatrix: Nullable<Matrix>;
  7642. /** @hidden */
  7643. _localMatrix: Matrix;
  7644. private _usePivotMatrix;
  7645. private _absolutePosition;
  7646. private _pivotMatrix;
  7647. private _pivotMatrixInverse;
  7648. protected _postMultiplyPivotMatrix: boolean;
  7649. protected _isWorldMatrixFrozen: boolean;
  7650. /** @hidden */
  7651. _indexInSceneTransformNodesArray: number;
  7652. /**
  7653. * An event triggered after the world matrix is updated
  7654. */
  7655. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7656. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7657. /**
  7658. * Gets a string identifying the name of the class
  7659. * @returns "TransformNode" string
  7660. */
  7661. getClassName(): string;
  7662. /**
  7663. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7664. */
  7665. position: Vector3;
  7666. /**
  7667. * 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)).
  7668. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7669. */
  7670. rotation: Vector3;
  7671. /**
  7672. * 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)).
  7673. */
  7674. scaling: Vector3;
  7675. /**
  7676. * 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).
  7677. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7678. */
  7679. rotationQuaternion: Nullable<Quaternion>;
  7680. /**
  7681. * The forward direction of that transform in world space.
  7682. */
  7683. readonly forward: Vector3;
  7684. /**
  7685. * The up direction of that transform in world space.
  7686. */
  7687. readonly up: Vector3;
  7688. /**
  7689. * The right direction of that transform in world space.
  7690. */
  7691. readonly right: Vector3;
  7692. /**
  7693. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7694. * @param matrix the matrix to copy the pose from
  7695. * @returns this TransformNode.
  7696. */
  7697. updatePoseMatrix(matrix: Matrix): TransformNode;
  7698. /**
  7699. * Returns the mesh Pose matrix.
  7700. * @returns the pose matrix
  7701. */
  7702. getPoseMatrix(): Matrix;
  7703. /** @hidden */
  7704. _isSynchronized(): boolean;
  7705. /** @hidden */
  7706. _initCache(): void;
  7707. /**
  7708. * Flag the transform node as dirty (Forcing it to update everything)
  7709. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7710. * @returns this transform node
  7711. */
  7712. markAsDirty(property: string): TransformNode;
  7713. /**
  7714. * Returns the current mesh absolute position.
  7715. * Returns a Vector3.
  7716. */
  7717. readonly absolutePosition: Vector3;
  7718. /**
  7719. * Sets a new matrix to apply before all other transformation
  7720. * @param matrix defines the transform matrix
  7721. * @returns the current TransformNode
  7722. */
  7723. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7724. /**
  7725. * Sets a new pivot matrix to the current node
  7726. * @param matrix defines the new pivot matrix to use
  7727. * @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
  7728. * @returns the current TransformNode
  7729. */
  7730. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7731. /**
  7732. * Returns the mesh pivot matrix.
  7733. * Default : Identity.
  7734. * @returns the matrix
  7735. */
  7736. getPivotMatrix(): Matrix;
  7737. /**
  7738. * Prevents the World matrix to be computed any longer.
  7739. * @returns the TransformNode.
  7740. */
  7741. freezeWorldMatrix(): TransformNode;
  7742. /**
  7743. * Allows back the World matrix computation.
  7744. * @returns the TransformNode.
  7745. */
  7746. unfreezeWorldMatrix(): this;
  7747. /**
  7748. * True if the World matrix has been frozen.
  7749. */
  7750. readonly isWorldMatrixFrozen: boolean;
  7751. /**
  7752. * Retuns the mesh absolute position in the World.
  7753. * @returns a Vector3.
  7754. */
  7755. getAbsolutePosition(): Vector3;
  7756. /**
  7757. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7758. * @param absolutePosition the absolute position to set
  7759. * @returns the TransformNode.
  7760. */
  7761. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7762. /**
  7763. * Sets the mesh position in its local space.
  7764. * @param vector3 the position to set in localspace
  7765. * @returns the TransformNode.
  7766. */
  7767. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7768. /**
  7769. * Returns the mesh position in the local space from the current World matrix values.
  7770. * @returns a new Vector3.
  7771. */
  7772. getPositionExpressedInLocalSpace(): Vector3;
  7773. /**
  7774. * Translates the mesh along the passed Vector3 in its local space.
  7775. * @param vector3 the distance to translate in localspace
  7776. * @returns the TransformNode.
  7777. */
  7778. locallyTranslate(vector3: Vector3): TransformNode;
  7779. private static _lookAtVectorCache;
  7780. /**
  7781. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7782. * @param targetPoint the position (must be in same space as current mesh) to look at
  7783. * @param yawCor optional yaw (y-axis) correction in radians
  7784. * @param pitchCor optional pitch (x-axis) correction in radians
  7785. * @param rollCor optional roll (z-axis) correction in radians
  7786. * @param space the choosen space of the target
  7787. * @returns the TransformNode.
  7788. */
  7789. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7790. /**
  7791. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7792. * This Vector3 is expressed in the World space.
  7793. * @param localAxis axis to rotate
  7794. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7795. */
  7796. getDirection(localAxis: Vector3): Vector3;
  7797. /**
  7798. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7799. * localAxis is expressed in the mesh local space.
  7800. * result is computed in the Wordl space from the mesh World matrix.
  7801. * @param localAxis axis to rotate
  7802. * @param result the resulting transformnode
  7803. * @returns this TransformNode.
  7804. */
  7805. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7806. /**
  7807. * Sets this transform node rotation to the given local axis.
  7808. * @param localAxis the axis in local space
  7809. * @param yawCor optional yaw (y-axis) correction in radians
  7810. * @param pitchCor optional pitch (x-axis) correction in radians
  7811. * @param rollCor optional roll (z-axis) correction in radians
  7812. * @returns this TransformNode
  7813. */
  7814. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7815. /**
  7816. * Sets a new pivot point to the current node
  7817. * @param point defines the new pivot point to use
  7818. * @param space defines if the point is in world or local space (local by default)
  7819. * @returns the current TransformNode
  7820. */
  7821. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7822. /**
  7823. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7824. * @returns the pivot point
  7825. */
  7826. getPivotPoint(): Vector3;
  7827. /**
  7828. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7829. * @param result the vector3 to store the result
  7830. * @returns this TransformNode.
  7831. */
  7832. getPivotPointToRef(result: Vector3): TransformNode;
  7833. /**
  7834. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7835. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7836. */
  7837. getAbsolutePivotPoint(): Vector3;
  7838. /**
  7839. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7840. * @param result vector3 to store the result
  7841. * @returns this TransformNode.
  7842. */
  7843. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7844. /**
  7845. * Defines the passed node as the parent of the current node.
  7846. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7847. * @see https://doc.babylonjs.com/how_to/parenting
  7848. * @param node the node ot set as the parent
  7849. * @returns this TransformNode.
  7850. */
  7851. setParent(node: Nullable<Node>): TransformNode;
  7852. private _nonUniformScaling;
  7853. /**
  7854. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7855. */
  7856. readonly nonUniformScaling: boolean;
  7857. /** @hidden */
  7858. _updateNonUniformScalingState(value: boolean): boolean;
  7859. /**
  7860. * Attach the current TransformNode to another TransformNode associated with a bone
  7861. * @param bone Bone affecting the TransformNode
  7862. * @param affectedTransformNode TransformNode associated with the bone
  7863. * @returns this object
  7864. */
  7865. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7866. /**
  7867. * Detach the transform node if its associated with a bone
  7868. * @returns this object
  7869. */
  7870. detachFromBone(): TransformNode;
  7871. private static _rotationAxisCache;
  7872. /**
  7873. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7874. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7875. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7876. * The passed axis is also normalized.
  7877. * @param axis the axis to rotate around
  7878. * @param amount the amount to rotate in radians
  7879. * @param space Space to rotate in (Default: local)
  7880. * @returns the TransformNode.
  7881. */
  7882. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7883. /**
  7884. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7885. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7886. * The passed axis is also normalized. .
  7887. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7888. * @param point the point to rotate around
  7889. * @param axis the axis to rotate around
  7890. * @param amount the amount to rotate in radians
  7891. * @returns the TransformNode
  7892. */
  7893. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7894. /**
  7895. * Translates the mesh along the axis vector for the passed distance in the given space.
  7896. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7897. * @param axis the axis to translate in
  7898. * @param distance the distance to translate
  7899. * @param space Space to rotate in (Default: local)
  7900. * @returns the TransformNode.
  7901. */
  7902. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7903. /**
  7904. * Adds a rotation step to the mesh current rotation.
  7905. * x, y, z are Euler angles expressed in radians.
  7906. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7907. * This means this rotation is made in the mesh local space only.
  7908. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7909. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7910. * ```javascript
  7911. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7912. * ```
  7913. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7914. * 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.
  7915. * @param x Rotation to add
  7916. * @param y Rotation to add
  7917. * @param z Rotation to add
  7918. * @returns the TransformNode.
  7919. */
  7920. addRotation(x: number, y: number, z: number): TransformNode;
  7921. /**
  7922. * @hidden
  7923. */
  7924. protected _getEffectiveParent(): Nullable<Node>;
  7925. /**
  7926. * Computes the world matrix of the node
  7927. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7928. * @returns the world matrix
  7929. */
  7930. computeWorldMatrix(force?: boolean): Matrix;
  7931. protected _afterComputeWorldMatrix(): void;
  7932. /**
  7933. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7934. * @param func callback function to add
  7935. *
  7936. * @returns the TransformNode.
  7937. */
  7938. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7939. /**
  7940. * Removes a registered callback function.
  7941. * @param func callback function to remove
  7942. * @returns the TransformNode.
  7943. */
  7944. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7945. /**
  7946. * Gets the position of the current mesh in camera space
  7947. * @param camera defines the camera to use
  7948. * @returns a position
  7949. */
  7950. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7951. /**
  7952. * Returns the distance from the mesh to the active camera
  7953. * @param camera defines the camera to use
  7954. * @returns the distance
  7955. */
  7956. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7957. /**
  7958. * Clone the current transform node
  7959. * @param name Name of the new clone
  7960. * @param newParent New parent for the clone
  7961. * @param doNotCloneChildren Do not clone children hierarchy
  7962. * @returns the new transform node
  7963. */
  7964. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7965. /**
  7966. * Serializes the objects information.
  7967. * @param currentSerializationObject defines the object to serialize in
  7968. * @returns the serialized object
  7969. */
  7970. serialize(currentSerializationObject?: any): any;
  7971. /**
  7972. * Returns a new TransformNode object parsed from the source provided.
  7973. * @param parsedTransformNode is the source.
  7974. * @param scene the scne the object belongs to
  7975. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7976. * @returns a new TransformNode object parsed from the source provided.
  7977. */
  7978. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7979. /**
  7980. * Get all child-transformNodes of this node
  7981. * @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
  7982. * @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
  7983. * @returns an array of TransformNode
  7984. */
  7985. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7986. /**
  7987. * Releases resources associated with this transform node.
  7988. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7989. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7990. */
  7991. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7992. }
  7993. }
  7994. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7995. /**
  7996. * Class used to override all child animations of a given target
  7997. */
  7998. export class AnimationPropertiesOverride {
  7999. /**
  8000. * Gets or sets a value indicating if animation blending must be used
  8001. */
  8002. enableBlending: boolean;
  8003. /**
  8004. * Gets or sets the blending speed to use when enableBlending is true
  8005. */
  8006. blendingSpeed: number;
  8007. /**
  8008. * Gets or sets the default loop mode to use
  8009. */
  8010. loopMode: number;
  8011. }
  8012. }
  8013. declare module "babylonjs/Bones/bone" {
  8014. import { Skeleton } from "babylonjs/Bones/skeleton";
  8015. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8016. import { Nullable } from "babylonjs/types";
  8017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8018. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8019. import { Node } from "babylonjs/node";
  8020. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8021. /**
  8022. * Class used to store bone information
  8023. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8024. */
  8025. export class Bone extends Node {
  8026. /**
  8027. * defines the bone name
  8028. */
  8029. name: string;
  8030. private static _tmpVecs;
  8031. private static _tmpQuat;
  8032. private static _tmpMats;
  8033. /**
  8034. * Gets the list of child bones
  8035. */
  8036. children: Bone[];
  8037. /** Gets the animations associated with this bone */
  8038. animations: import("babylonjs/Animations/animation").Animation[];
  8039. /**
  8040. * Gets or sets bone length
  8041. */
  8042. length: number;
  8043. /**
  8044. * @hidden Internal only
  8045. * Set this value to map this bone to a different index in the transform matrices
  8046. * Set this value to -1 to exclude the bone from the transform matrices
  8047. */
  8048. _index: Nullable<number>;
  8049. private _skeleton;
  8050. private _localMatrix;
  8051. private _restPose;
  8052. private _baseMatrix;
  8053. private _absoluteTransform;
  8054. private _invertedAbsoluteTransform;
  8055. private _parent;
  8056. private _scalingDeterminant;
  8057. private _worldTransform;
  8058. private _localScaling;
  8059. private _localRotation;
  8060. private _localPosition;
  8061. private _needToDecompose;
  8062. private _needToCompose;
  8063. /** @hidden */
  8064. _linkedTransformNode: Nullable<TransformNode>;
  8065. /** @hidden */
  8066. _waitingTransformNodeId: Nullable<string>;
  8067. /** @hidden */
  8068. /** @hidden */
  8069. _matrix: Matrix;
  8070. /**
  8071. * Create a new bone
  8072. * @param name defines the bone name
  8073. * @param skeleton defines the parent skeleton
  8074. * @param parentBone defines the parent (can be null if the bone is the root)
  8075. * @param localMatrix defines the local matrix
  8076. * @param restPose defines the rest pose matrix
  8077. * @param baseMatrix defines the base matrix
  8078. * @param index defines index of the bone in the hiearchy
  8079. */
  8080. constructor(
  8081. /**
  8082. * defines the bone name
  8083. */
  8084. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8085. /**
  8086. * Gets the current object class name.
  8087. * @return the class name
  8088. */
  8089. getClassName(): string;
  8090. /**
  8091. * Gets the parent skeleton
  8092. * @returns a skeleton
  8093. */
  8094. getSkeleton(): Skeleton;
  8095. /**
  8096. * Gets parent bone
  8097. * @returns a bone or null if the bone is the root of the bone hierarchy
  8098. */
  8099. getParent(): Nullable<Bone>;
  8100. /**
  8101. * Returns an array containing the root bones
  8102. * @returns an array containing the root bones
  8103. */
  8104. getChildren(): Array<Bone>;
  8105. /**
  8106. * Sets the parent bone
  8107. * @param parent defines the parent (can be null if the bone is the root)
  8108. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8109. */
  8110. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8111. /**
  8112. * Gets the local matrix
  8113. * @returns a matrix
  8114. */
  8115. getLocalMatrix(): Matrix;
  8116. /**
  8117. * Gets the base matrix (initial matrix which remains unchanged)
  8118. * @returns a matrix
  8119. */
  8120. getBaseMatrix(): Matrix;
  8121. /**
  8122. * Gets the rest pose matrix
  8123. * @returns a matrix
  8124. */
  8125. getRestPose(): Matrix;
  8126. /**
  8127. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8128. */
  8129. getWorldMatrix(): Matrix;
  8130. /**
  8131. * Sets the local matrix to rest pose matrix
  8132. */
  8133. returnToRest(): void;
  8134. /**
  8135. * Gets the inverse of the absolute transform matrix.
  8136. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8137. * @returns a matrix
  8138. */
  8139. getInvertedAbsoluteTransform(): Matrix;
  8140. /**
  8141. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8142. * @returns a matrix
  8143. */
  8144. getAbsoluteTransform(): Matrix;
  8145. /**
  8146. * Links with the given transform node.
  8147. * The local matrix of this bone is copied from the transform node every frame.
  8148. * @param transformNode defines the transform node to link to
  8149. */
  8150. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8151. /** Gets or sets current position (in local space) */
  8152. position: Vector3;
  8153. /** Gets or sets current rotation (in local space) */
  8154. rotation: Vector3;
  8155. /** Gets or sets current rotation quaternion (in local space) */
  8156. rotationQuaternion: Quaternion;
  8157. /** Gets or sets current scaling (in local space) */
  8158. scaling: Vector3;
  8159. /**
  8160. * Gets the animation properties override
  8161. */
  8162. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8163. private _decompose;
  8164. private _compose;
  8165. /**
  8166. * Update the base and local matrices
  8167. * @param matrix defines the new base or local matrix
  8168. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8169. * @param updateLocalMatrix defines if the local matrix should be updated
  8170. */
  8171. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8172. /** @hidden */
  8173. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8174. /**
  8175. * Flag the bone as dirty (Forcing it to update everything)
  8176. */
  8177. markAsDirty(): void;
  8178. private _markAsDirtyAndCompose;
  8179. private _markAsDirtyAndDecompose;
  8180. /**
  8181. * Translate the bone in local or world space
  8182. * @param vec The amount to translate the bone
  8183. * @param space The space that the translation is in
  8184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8185. */
  8186. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8187. /**
  8188. * Set the postion of the bone in local or world space
  8189. * @param position The position to set the bone
  8190. * @param space The space that the position is in
  8191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8192. */
  8193. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8194. /**
  8195. * Set the absolute position of the bone (world space)
  8196. * @param position The position to set the bone
  8197. * @param mesh The mesh that this bone is attached to
  8198. */
  8199. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8200. /**
  8201. * Scale the bone on the x, y and z axes (in local space)
  8202. * @param x The amount to scale the bone on the x axis
  8203. * @param y The amount to scale the bone on the y axis
  8204. * @param z The amount to scale the bone on the z axis
  8205. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8206. */
  8207. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8208. /**
  8209. * Set the bone scaling in local space
  8210. * @param scale defines the scaling vector
  8211. */
  8212. setScale(scale: Vector3): void;
  8213. /**
  8214. * Gets the current scaling in local space
  8215. * @returns the current scaling vector
  8216. */
  8217. getScale(): Vector3;
  8218. /**
  8219. * Gets the current scaling in local space and stores it in a target vector
  8220. * @param result defines the target vector
  8221. */
  8222. getScaleToRef(result: Vector3): void;
  8223. /**
  8224. * Set the yaw, pitch, and roll of the bone in local or world space
  8225. * @param yaw The rotation of the bone on the y axis
  8226. * @param pitch The rotation of the bone on the x axis
  8227. * @param roll The rotation of the bone on the z axis
  8228. * @param space The space that the axes of rotation are in
  8229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8230. */
  8231. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8232. /**
  8233. * Add a rotation to the bone on an axis in local or world space
  8234. * @param axis The axis to rotate the bone on
  8235. * @param amount The amount to rotate the bone
  8236. * @param space The space that the axis is in
  8237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8238. */
  8239. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8240. /**
  8241. * Set the rotation of the bone to a particular axis angle in local or world space
  8242. * @param axis The axis to rotate the bone on
  8243. * @param angle The angle that the bone should be rotated to
  8244. * @param space The space that the axis is in
  8245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8246. */
  8247. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8248. /**
  8249. * Set the euler rotation of the bone in local of world space
  8250. * @param rotation The euler rotation that the bone should be set to
  8251. * @param space The space that the rotation is in
  8252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8253. */
  8254. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8255. /**
  8256. * Set the quaternion rotation of the bone in local of world space
  8257. * @param quat The quaternion rotation that the bone should be set to
  8258. * @param space The space that the rotation is in
  8259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8260. */
  8261. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8262. /**
  8263. * Set the rotation matrix of the bone in local of world space
  8264. * @param rotMat The rotation matrix that the bone should be set to
  8265. * @param space The space that the rotation is in
  8266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8267. */
  8268. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8269. private _rotateWithMatrix;
  8270. private _getNegativeRotationToRef;
  8271. /**
  8272. * Get the position of the bone in local or world space
  8273. * @param space The space that the returned position is in
  8274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8275. * @returns The position of the bone
  8276. */
  8277. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8278. /**
  8279. * Copy the position of the bone to a vector3 in local or world space
  8280. * @param space The space that the returned position is in
  8281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8282. * @param result The vector3 to copy the position to
  8283. */
  8284. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8285. /**
  8286. * Get the absolute position of the bone (world space)
  8287. * @param mesh The mesh that this bone is attached to
  8288. * @returns The absolute position of the bone
  8289. */
  8290. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8291. /**
  8292. * Copy the absolute position of the bone (world space) to the result param
  8293. * @param mesh The mesh that this bone is attached to
  8294. * @param result The vector3 to copy the absolute position to
  8295. */
  8296. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8297. /**
  8298. * Compute the absolute transforms of this bone and its children
  8299. */
  8300. computeAbsoluteTransforms(): void;
  8301. /**
  8302. * Get the world direction from an axis that is in the local space of the bone
  8303. * @param localAxis The local direction that is used to compute the world direction
  8304. * @param mesh The mesh that this bone is attached to
  8305. * @returns The world direction
  8306. */
  8307. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8308. /**
  8309. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8310. * @param localAxis The local direction that is used to compute the world direction
  8311. * @param mesh The mesh that this bone is attached to
  8312. * @param result The vector3 that the world direction will be copied to
  8313. */
  8314. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8315. /**
  8316. * Get the euler rotation of the bone in local or world space
  8317. * @param space The space that the rotation should be in
  8318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8319. * @returns The euler rotation
  8320. */
  8321. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8322. /**
  8323. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8324. * @param space The space that the rotation should be in
  8325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8326. * @param result The vector3 that the rotation should be copied to
  8327. */
  8328. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8329. /**
  8330. * Get the quaternion rotation of the bone in either local or world space
  8331. * @param space The space that the rotation should be in
  8332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8333. * @returns The quaternion rotation
  8334. */
  8335. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8336. /**
  8337. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8338. * @param space The space that the rotation should be in
  8339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8340. * @param result The quaternion that the rotation should be copied to
  8341. */
  8342. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8343. /**
  8344. * Get the rotation matrix of the bone in local or world space
  8345. * @param space The space that the rotation should be in
  8346. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8347. * @returns The rotation matrix
  8348. */
  8349. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8350. /**
  8351. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8352. * @param space The space that the rotation should be in
  8353. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8354. * @param result The quaternion that the rotation should be copied to
  8355. */
  8356. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8357. /**
  8358. * Get the world position of a point that is in the local space of the bone
  8359. * @param position The local position
  8360. * @param mesh The mesh that this bone is attached to
  8361. * @returns The world position
  8362. */
  8363. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8364. /**
  8365. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8366. * @param position The local position
  8367. * @param mesh The mesh that this bone is attached to
  8368. * @param result The vector3 that the world position should be copied to
  8369. */
  8370. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8371. /**
  8372. * Get the local position of a point that is in world space
  8373. * @param position The world position
  8374. * @param mesh The mesh that this bone is attached to
  8375. * @returns The local position
  8376. */
  8377. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8378. /**
  8379. * Get the local position of a point that is in world space and copy it to the result param
  8380. * @param position The world position
  8381. * @param mesh The mesh that this bone is attached to
  8382. * @param result The vector3 that the local position should be copied to
  8383. */
  8384. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8385. }
  8386. }
  8387. declare module "babylonjs/Misc/iInspectable" {
  8388. /**
  8389. * Enum that determines the text-wrapping mode to use.
  8390. */
  8391. export enum InspectableType {
  8392. /**
  8393. * Checkbox for booleans
  8394. */
  8395. Checkbox = 0,
  8396. /**
  8397. * Sliders for numbers
  8398. */
  8399. Slider = 1,
  8400. /**
  8401. * Vector3
  8402. */
  8403. Vector3 = 2,
  8404. /**
  8405. * Quaternions
  8406. */
  8407. Quaternion = 3,
  8408. /**
  8409. * Color3
  8410. */
  8411. Color3 = 4
  8412. }
  8413. /**
  8414. * Interface used to define custom inspectable properties.
  8415. * This interface is used by the inspector to display custom property grids
  8416. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8417. */
  8418. export interface IInspectable {
  8419. /**
  8420. * Gets the label to display
  8421. */
  8422. label: string;
  8423. /**
  8424. * Gets the name of the property to edit
  8425. */
  8426. propertyName: string;
  8427. /**
  8428. * Gets the type of the editor to use
  8429. */
  8430. type: InspectableType;
  8431. /**
  8432. * Gets the minimum value of the property when using in "slider" mode
  8433. */
  8434. min?: number;
  8435. /**
  8436. * Gets the maximum value of the property when using in "slider" mode
  8437. */
  8438. max?: number;
  8439. /**
  8440. * Gets the setp to use when using in "slider" mode
  8441. */
  8442. step?: number;
  8443. }
  8444. }
  8445. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  8446. import { Nullable } from "babylonjs/types";
  8447. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8448. /**
  8449. * This represents the required contract to create a new type of texture loader.
  8450. */
  8451. export interface IInternalTextureLoader {
  8452. /**
  8453. * Defines wether the loader supports cascade loading the different faces.
  8454. */
  8455. supportCascades: boolean;
  8456. /**
  8457. * This returns if the loader support the current file information.
  8458. * @param extension defines the file extension of the file being loaded
  8459. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8460. * @param fallback defines the fallback internal texture if any
  8461. * @param isBase64 defines whether the texture is encoded as a base64
  8462. * @param isBuffer defines whether the texture data are stored as a buffer
  8463. * @returns true if the loader can load the specified file
  8464. */
  8465. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8466. /**
  8467. * Transform the url before loading if required.
  8468. * @param rootUrl the url of the texture
  8469. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8470. * @returns the transformed texture
  8471. */
  8472. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8473. /**
  8474. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8475. * @param rootUrl the url of the texture
  8476. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8477. * @returns the fallback texture
  8478. */
  8479. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8480. /**
  8481. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8482. * @param data contains the texture data
  8483. * @param texture defines the BabylonJS internal texture
  8484. * @param createPolynomials will be true if polynomials have been requested
  8485. * @param onLoad defines the callback to trigger once the texture is ready
  8486. * @param onError defines the callback to trigger in case of error
  8487. */
  8488. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8489. /**
  8490. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8491. * @param data contains the texture data
  8492. * @param texture defines the BabylonJS internal texture
  8493. * @param callback defines the method to call once ready to upload
  8494. */
  8495. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8496. }
  8497. }
  8498. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  8499. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8500. import { Nullable } from "babylonjs/types";
  8501. import { Scene } from "babylonjs/scene";
  8502. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  8503. module "babylonjs/Engines/engine" {
  8504. interface Engine {
  8505. /**
  8506. * Creates a depth stencil cube texture.
  8507. * This is only available in WebGL 2.
  8508. * @param size The size of face edge in the cube texture.
  8509. * @param options The options defining the cube texture.
  8510. * @returns The cube texture
  8511. */
  8512. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8513. /**
  8514. * Creates a cube texture
  8515. * @param rootUrl defines the url where the files to load is located
  8516. * @param scene defines the current scene
  8517. * @param files defines the list of files to load (1 per face)
  8518. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8519. * @param onLoad defines an optional callback raised when the texture is loaded
  8520. * @param onError defines an optional callback raised if there is an issue to load the texture
  8521. * @param format defines the format of the data
  8522. * @param forcedExtension defines the extension to use to pick the right loader
  8523. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8524. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8525. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8526. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8527. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8528. * @returns the cube texture as an InternalTexture
  8529. */
  8530. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  8531. /**
  8532. * Creates a cube texture
  8533. * @param rootUrl defines the url where the files to load is located
  8534. * @param scene defines the current scene
  8535. * @param files defines the list of files to load (1 per face)
  8536. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8537. * @param onLoad defines an optional callback raised when the texture is loaded
  8538. * @param onError defines an optional callback raised if there is an issue to load the texture
  8539. * @param format defines the format of the data
  8540. * @param forcedExtension defines the extension to use to pick the right loader
  8541. * @returns the cube texture as an InternalTexture
  8542. */
  8543. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  8544. /**
  8545. * Creates a cube texture
  8546. * @param rootUrl defines the url where the files to load is located
  8547. * @param scene defines the current scene
  8548. * @param files defines the list of files to load (1 per face)
  8549. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8550. * @param onLoad defines an optional callback raised when the texture is loaded
  8551. * @param onError defines an optional callback raised if there is an issue to load the texture
  8552. * @param format defines the format of the data
  8553. * @param forcedExtension defines the extension to use to pick the right loader
  8554. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8555. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8556. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8557. * @returns the cube texture as an InternalTexture
  8558. */
  8559. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  8560. /** @hidden */
  8561. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8562. /** @hidden */
  8563. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8564. /** @hidden */
  8565. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8566. /** @hidden */
  8567. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8568. }
  8569. }
  8570. }
  8571. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8572. import { Nullable } from "babylonjs/types";
  8573. import { Scene } from "babylonjs/scene";
  8574. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8575. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8576. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  8577. /**
  8578. * Class for creating a cube texture
  8579. */
  8580. export class CubeTexture extends BaseTexture {
  8581. private _delayedOnLoad;
  8582. /**
  8583. * The url of the texture
  8584. */
  8585. url: string;
  8586. /**
  8587. * Gets or sets the center of the bounding box associated with the cube texture.
  8588. * It must define where the camera used to render the texture was set
  8589. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8590. */
  8591. boundingBoxPosition: Vector3;
  8592. private _boundingBoxSize;
  8593. /**
  8594. * Gets or sets the size of the bounding box associated with the cube texture
  8595. * When defined, the cubemap will switch to local mode
  8596. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8597. * @example https://www.babylonjs-playground.com/#RNASML
  8598. */
  8599. /**
  8600. * Returns the bounding box size
  8601. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8602. */
  8603. boundingBoxSize: Vector3;
  8604. protected _rotationY: number;
  8605. /**
  8606. * Sets texture matrix rotation angle around Y axis in radians.
  8607. */
  8608. /**
  8609. * Gets texture matrix rotation angle around Y axis radians.
  8610. */
  8611. rotationY: number;
  8612. /**
  8613. * Are mip maps generated for this texture or not.
  8614. */
  8615. readonly noMipmap: boolean;
  8616. private _noMipmap;
  8617. private _files;
  8618. private _extensions;
  8619. private _textureMatrix;
  8620. private _format;
  8621. private _createPolynomials;
  8622. /** @hidden */
  8623. _prefiltered: boolean;
  8624. /**
  8625. * Creates a cube texture from an array of image urls
  8626. * @param files defines an array of image urls
  8627. * @param scene defines the hosting scene
  8628. * @param noMipmap specifies if mip maps are not used
  8629. * @returns a cube texture
  8630. */
  8631. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8632. /**
  8633. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8634. * @param url defines the url of the prefiltered texture
  8635. * @param scene defines the scene the texture is attached to
  8636. * @param forcedExtension defines the extension of the file if different from the url
  8637. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8638. * @return the prefiltered texture
  8639. */
  8640. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8641. /**
  8642. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8643. * as prefiltered data.
  8644. * @param rootUrl defines the url of the texture or the root name of the six images
  8645. * @param scene defines the scene the texture is attached to
  8646. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8647. * @param noMipmap defines if mipmaps should be created or not
  8648. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8649. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8650. * @param onError defines a callback triggered in case of error during load
  8651. * @param format defines the internal format to use for the texture once loaded
  8652. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8653. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8654. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8655. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8656. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8657. * @return the cube texture
  8658. */
  8659. 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);
  8660. /**
  8661. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8662. */
  8663. readonly isPrefiltered: boolean;
  8664. /**
  8665. * Get the current class name of the texture useful for serialization or dynamic coding.
  8666. * @returns "CubeTexture"
  8667. */
  8668. getClassName(): string;
  8669. /**
  8670. * Update the url (and optional buffer) of this texture if url was null during construction.
  8671. * @param url the url of the texture
  8672. * @param forcedExtension defines the extension to use
  8673. * @param onLoad callback called when the texture is loaded (defaults to null)
  8674. */
  8675. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8676. /**
  8677. * Delays loading of the cube texture
  8678. * @param forcedExtension defines the extension to use
  8679. */
  8680. delayLoad(forcedExtension?: string): void;
  8681. /**
  8682. * Returns the reflection texture matrix
  8683. * @returns the reflection texture matrix
  8684. */
  8685. getReflectionTextureMatrix(): Matrix;
  8686. /**
  8687. * Sets the reflection texture matrix
  8688. * @param value Reflection texture matrix
  8689. */
  8690. setReflectionTextureMatrix(value: Matrix): void;
  8691. /**
  8692. * Parses text to create a cube texture
  8693. * @param parsedTexture define the serialized text to read from
  8694. * @param scene defines the hosting scene
  8695. * @param rootUrl defines the root url of the cube texture
  8696. * @returns a cube texture
  8697. */
  8698. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8699. /**
  8700. * Makes a clone, or deep copy, of the cube texture
  8701. * @returns a new cube texture
  8702. */
  8703. clone(): CubeTexture;
  8704. }
  8705. }
  8706. declare module "babylonjs/Shaders/postprocess.vertex" {
  8707. /** @hidden */
  8708. export var postprocessVertexShader: {
  8709. name: string;
  8710. shader: string;
  8711. };
  8712. }
  8713. declare module "babylonjs/Cameras/targetCamera" {
  8714. import { Nullable } from "babylonjs/types";
  8715. import { Camera } from "babylonjs/Cameras/camera";
  8716. import { Scene } from "babylonjs/scene";
  8717. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8718. /**
  8719. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8720. * This is the base of the follow, arc rotate cameras and Free camera
  8721. * @see http://doc.babylonjs.com/features/cameras
  8722. */
  8723. export class TargetCamera extends Camera {
  8724. private static _RigCamTransformMatrix;
  8725. private static _TargetTransformMatrix;
  8726. private static _TargetFocalPoint;
  8727. /**
  8728. * Define the current direction the camera is moving to
  8729. */
  8730. cameraDirection: Vector3;
  8731. /**
  8732. * Define the current rotation the camera is rotating to
  8733. */
  8734. cameraRotation: Vector2;
  8735. /**
  8736. * When set, the up vector of the camera will be updated by the rotation of the camera
  8737. */
  8738. updateUpVectorFromRotation: boolean;
  8739. private _tmpQuaternion;
  8740. /**
  8741. * Define the current rotation of the camera
  8742. */
  8743. rotation: Vector3;
  8744. /**
  8745. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8746. */
  8747. rotationQuaternion: Quaternion;
  8748. /**
  8749. * Define the current speed of the camera
  8750. */
  8751. speed: number;
  8752. /**
  8753. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8754. * around all axis.
  8755. */
  8756. noRotationConstraint: boolean;
  8757. /**
  8758. * Define the current target of the camera as an object or a position.
  8759. */
  8760. lockedTarget: any;
  8761. /** @hidden */
  8762. _currentTarget: Vector3;
  8763. /** @hidden */
  8764. _initialFocalDistance: number;
  8765. /** @hidden */
  8766. _viewMatrix: Matrix;
  8767. /** @hidden */
  8768. _camMatrix: Matrix;
  8769. /** @hidden */
  8770. _cameraTransformMatrix: Matrix;
  8771. /** @hidden */
  8772. _cameraRotationMatrix: Matrix;
  8773. /** @hidden */
  8774. _referencePoint: Vector3;
  8775. /** @hidden */
  8776. _transformedReferencePoint: Vector3;
  8777. protected _globalCurrentTarget: Vector3;
  8778. protected _globalCurrentUpVector: Vector3;
  8779. /** @hidden */
  8780. _reset: () => void;
  8781. private _defaultUp;
  8782. /**
  8783. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8784. * This is the base of the follow, arc rotate cameras and Free camera
  8785. * @see http://doc.babylonjs.com/features/cameras
  8786. * @param name Defines the name of the camera in the scene
  8787. * @param position Defines the start position of the camera in the scene
  8788. * @param scene Defines the scene the camera belongs to
  8789. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8790. */
  8791. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8792. /**
  8793. * Gets the position in front of the camera at a given distance.
  8794. * @param distance The distance from the camera we want the position to be
  8795. * @returns the position
  8796. */
  8797. getFrontPosition(distance: number): Vector3;
  8798. /** @hidden */
  8799. _getLockedTargetPosition(): Nullable<Vector3>;
  8800. private _storedPosition;
  8801. private _storedRotation;
  8802. private _storedRotationQuaternion;
  8803. /**
  8804. * Store current camera state of the camera (fov, position, rotation, etc..)
  8805. * @returns the camera
  8806. */
  8807. storeState(): Camera;
  8808. /**
  8809. * Restored camera state. You must call storeState() first
  8810. * @returns whether it was successful or not
  8811. * @hidden
  8812. */
  8813. _restoreStateValues(): boolean;
  8814. /** @hidden */
  8815. _initCache(): void;
  8816. /** @hidden */
  8817. _updateCache(ignoreParentClass?: boolean): void;
  8818. /** @hidden */
  8819. _isSynchronizedViewMatrix(): boolean;
  8820. /** @hidden */
  8821. _computeLocalCameraSpeed(): number;
  8822. /**
  8823. * Defines the target the camera should look at.
  8824. * This will automatically adapt alpha beta and radius to fit within the new target.
  8825. * @param target Defines the new target as a Vector or a mesh
  8826. */
  8827. setTarget(target: Vector3): void;
  8828. /**
  8829. * Return the current target position of the camera. This value is expressed in local space.
  8830. * @returns the target position
  8831. */
  8832. getTarget(): Vector3;
  8833. /** @hidden */
  8834. _decideIfNeedsToMove(): boolean;
  8835. /** @hidden */
  8836. _updatePosition(): void;
  8837. /** @hidden */
  8838. _checkInputs(): void;
  8839. protected _updateCameraRotationMatrix(): void;
  8840. /**
  8841. * 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)
  8842. * @returns the current camera
  8843. */
  8844. private _rotateUpVectorWithCameraRotationMatrix;
  8845. private _cachedRotationZ;
  8846. private _cachedQuaternionRotationZ;
  8847. /** @hidden */
  8848. _getViewMatrix(): Matrix;
  8849. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8850. /**
  8851. * @hidden
  8852. */
  8853. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8854. /**
  8855. * @hidden
  8856. */
  8857. _updateRigCameras(): void;
  8858. private _getRigCamPositionAndTarget;
  8859. /**
  8860. * Gets the current object class name.
  8861. * @return the class name
  8862. */
  8863. getClassName(): string;
  8864. }
  8865. }
  8866. declare module "babylonjs/Cameras/cameraInputsManager" {
  8867. import { Nullable } from "babylonjs/types";
  8868. import { Camera } from "babylonjs/Cameras/camera";
  8869. /**
  8870. * @ignore
  8871. * This is a list of all the different input types that are available in the application.
  8872. * Fo instance: ArcRotateCameraGamepadInput...
  8873. */
  8874. export var CameraInputTypes: {};
  8875. /**
  8876. * This is the contract to implement in order to create a new input class.
  8877. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8878. */
  8879. export interface ICameraInput<TCamera extends Camera> {
  8880. /**
  8881. * Defines the camera the input is attached to.
  8882. */
  8883. camera: Nullable<TCamera>;
  8884. /**
  8885. * Gets the class name of the current intput.
  8886. * @returns the class name
  8887. */
  8888. getClassName(): string;
  8889. /**
  8890. * Get the friendly name associated with the input class.
  8891. * @returns the input friendly name
  8892. */
  8893. getSimpleName(): string;
  8894. /**
  8895. * Attach the input controls to a specific dom element to get the input from.
  8896. * @param element Defines the element the controls should be listened from
  8897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8898. */
  8899. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8900. /**
  8901. * Detach the current controls from the specified dom element.
  8902. * @param element Defines the element to stop listening the inputs from
  8903. */
  8904. detachControl(element: Nullable<HTMLElement>): void;
  8905. /**
  8906. * Update the current camera state depending on the inputs that have been used this frame.
  8907. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8908. */
  8909. checkInputs?: () => void;
  8910. }
  8911. /**
  8912. * Represents a map of input types to input instance or input index to input instance.
  8913. */
  8914. export interface CameraInputsMap<TCamera extends Camera> {
  8915. /**
  8916. * Accessor to the input by input type.
  8917. */
  8918. [name: string]: ICameraInput<TCamera>;
  8919. /**
  8920. * Accessor to the input by input index.
  8921. */
  8922. [idx: number]: ICameraInput<TCamera>;
  8923. }
  8924. /**
  8925. * This represents the input manager used within a camera.
  8926. * It helps dealing with all the different kind of input attached to a camera.
  8927. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8928. */
  8929. export class CameraInputsManager<TCamera extends Camera> {
  8930. /**
  8931. * Defines the list of inputs attahed to the camera.
  8932. */
  8933. attached: CameraInputsMap<TCamera>;
  8934. /**
  8935. * Defines the dom element the camera is collecting inputs from.
  8936. * This is null if the controls have not been attached.
  8937. */
  8938. attachedElement: Nullable<HTMLElement>;
  8939. /**
  8940. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8941. */
  8942. noPreventDefault: boolean;
  8943. /**
  8944. * Defined the camera the input manager belongs to.
  8945. */
  8946. camera: TCamera;
  8947. /**
  8948. * Update the current camera state depending on the inputs that have been used this frame.
  8949. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8950. */
  8951. checkInputs: () => void;
  8952. /**
  8953. * Instantiate a new Camera Input Manager.
  8954. * @param camera Defines the camera the input manager blongs to
  8955. */
  8956. constructor(camera: TCamera);
  8957. /**
  8958. * Add an input method to a camera
  8959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8960. * @param input camera input method
  8961. */
  8962. add(input: ICameraInput<TCamera>): void;
  8963. /**
  8964. * Remove a specific input method from a camera
  8965. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8966. * @param inputToRemove camera input method
  8967. */
  8968. remove(inputToRemove: ICameraInput<TCamera>): void;
  8969. /**
  8970. * Remove a specific input type from a camera
  8971. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8972. * @param inputType the type of the input to remove
  8973. */
  8974. removeByType(inputType: string): void;
  8975. private _addCheckInputs;
  8976. /**
  8977. * Attach the input controls to the currently attached dom element to listen the events from.
  8978. * @param input Defines the input to attach
  8979. */
  8980. attachInput(input: ICameraInput<TCamera>): void;
  8981. /**
  8982. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8983. * @param element Defines the dom element to collect the events from
  8984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8985. */
  8986. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8987. /**
  8988. * Detach the current manager inputs controls from a specific dom element.
  8989. * @param element Defines the dom element to collect the events from
  8990. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8991. */
  8992. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8993. /**
  8994. * Rebuild the dynamic inputCheck function from the current list of
  8995. * defined inputs in the manager.
  8996. */
  8997. rebuildInputCheck(): void;
  8998. /**
  8999. * Remove all attached input methods from a camera
  9000. */
  9001. clear(): void;
  9002. /**
  9003. * Serialize the current input manager attached to a camera.
  9004. * This ensures than once parsed,
  9005. * the input associated to the camera will be identical to the current ones
  9006. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9007. */
  9008. serialize(serializedCamera: any): void;
  9009. /**
  9010. * Parses an input manager serialized JSON to restore the previous list of inputs
  9011. * and states associated to a camera.
  9012. * @param parsedCamera Defines the JSON to parse
  9013. */
  9014. parse(parsedCamera: any): void;
  9015. }
  9016. }
  9017. declare module "babylonjs/Events/keyboardEvents" {
  9018. /**
  9019. * Gather the list of keyboard event types as constants.
  9020. */
  9021. export class KeyboardEventTypes {
  9022. /**
  9023. * The keydown event is fired when a key becomes active (pressed).
  9024. */
  9025. static readonly KEYDOWN: number;
  9026. /**
  9027. * The keyup event is fired when a key has been released.
  9028. */
  9029. static readonly KEYUP: number;
  9030. }
  9031. /**
  9032. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9033. */
  9034. export class KeyboardInfo {
  9035. /**
  9036. * Defines the type of event (KeyboardEventTypes)
  9037. */
  9038. type: number;
  9039. /**
  9040. * Defines the related dom event
  9041. */
  9042. event: KeyboardEvent;
  9043. /**
  9044. * Instantiates a new keyboard info.
  9045. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9046. * @param type Defines the type of event (KeyboardEventTypes)
  9047. * @param event Defines the related dom event
  9048. */
  9049. constructor(
  9050. /**
  9051. * Defines the type of event (KeyboardEventTypes)
  9052. */
  9053. type: number,
  9054. /**
  9055. * Defines the related dom event
  9056. */
  9057. event: KeyboardEvent);
  9058. }
  9059. /**
  9060. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9061. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9062. */
  9063. export class KeyboardInfoPre extends KeyboardInfo {
  9064. /**
  9065. * Defines the type of event (KeyboardEventTypes)
  9066. */
  9067. type: number;
  9068. /**
  9069. * Defines the related dom event
  9070. */
  9071. event: KeyboardEvent;
  9072. /**
  9073. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9074. */
  9075. skipOnPointerObservable: boolean;
  9076. /**
  9077. * Instantiates a new keyboard pre info.
  9078. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9079. * @param type Defines the type of event (KeyboardEventTypes)
  9080. * @param event Defines the related dom event
  9081. */
  9082. constructor(
  9083. /**
  9084. * Defines the type of event (KeyboardEventTypes)
  9085. */
  9086. type: number,
  9087. /**
  9088. * Defines the related dom event
  9089. */
  9090. event: KeyboardEvent);
  9091. }
  9092. }
  9093. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9094. import { Nullable } from "babylonjs/types";
  9095. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9096. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9097. /**
  9098. * Manage the keyboard inputs to control the movement of a free camera.
  9099. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9100. */
  9101. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9102. /**
  9103. * Defines the camera the input is attached to.
  9104. */
  9105. camera: FreeCamera;
  9106. /**
  9107. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9108. */
  9109. keysUp: number[];
  9110. /**
  9111. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9112. */
  9113. keysDown: number[];
  9114. /**
  9115. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9116. */
  9117. keysLeft: number[];
  9118. /**
  9119. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9120. */
  9121. keysRight: number[];
  9122. private _keys;
  9123. private _onCanvasBlurObserver;
  9124. private _onKeyboardObserver;
  9125. private _engine;
  9126. private _scene;
  9127. /**
  9128. * Attach the input controls to a specific dom element to get the input from.
  9129. * @param element Defines the element the controls should be listened from
  9130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9131. */
  9132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9133. /**
  9134. * Detach the current controls from the specified dom element.
  9135. * @param element Defines the element to stop listening the inputs from
  9136. */
  9137. detachControl(element: Nullable<HTMLElement>): void;
  9138. /**
  9139. * Update the current camera state depending on the inputs that have been used this frame.
  9140. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9141. */
  9142. checkInputs(): void;
  9143. /**
  9144. * Gets the class name of the current intput.
  9145. * @returns the class name
  9146. */
  9147. getClassName(): string;
  9148. /** @hidden */
  9149. _onLostFocus(): void;
  9150. /**
  9151. * Get the friendly name associated with the input class.
  9152. * @returns the input friendly name
  9153. */
  9154. getSimpleName(): string;
  9155. }
  9156. }
  9157. declare module "babylonjs/Lights/shadowLight" {
  9158. import { Camera } from "babylonjs/Cameras/camera";
  9159. import { Scene } from "babylonjs/scene";
  9160. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  9161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9162. import { Light } from "babylonjs/Lights/light";
  9163. /**
  9164. * Interface describing all the common properties and methods a shadow light needs to implement.
  9165. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9166. * as well as binding the different shadow properties to the effects.
  9167. */
  9168. export interface IShadowLight extends Light {
  9169. /**
  9170. * The light id in the scene (used in scene.findLighById for instance)
  9171. */
  9172. id: string;
  9173. /**
  9174. * The position the shdow will be casted from.
  9175. */
  9176. position: Vector3;
  9177. /**
  9178. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9179. */
  9180. direction: Vector3;
  9181. /**
  9182. * The transformed position. Position of the light in world space taking parenting in account.
  9183. */
  9184. transformedPosition: Vector3;
  9185. /**
  9186. * The transformed direction. Direction of the light in world space taking parenting in account.
  9187. */
  9188. transformedDirection: Vector3;
  9189. /**
  9190. * The friendly name of the light in the scene.
  9191. */
  9192. name: string;
  9193. /**
  9194. * Defines the shadow projection clipping minimum z value.
  9195. */
  9196. shadowMinZ: number;
  9197. /**
  9198. * Defines the shadow projection clipping maximum z value.
  9199. */
  9200. shadowMaxZ: number;
  9201. /**
  9202. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9203. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9204. */
  9205. computeTransformedInformation(): boolean;
  9206. /**
  9207. * Gets the scene the light belongs to.
  9208. * @returns The scene
  9209. */
  9210. getScene(): Scene;
  9211. /**
  9212. * Callback defining a custom Projection Matrix Builder.
  9213. * This can be used to override the default projection matrix computation.
  9214. */
  9215. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9216. /**
  9217. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9218. * @param matrix The materix to updated with the projection information
  9219. * @param viewMatrix The transform matrix of the light
  9220. * @param renderList The list of mesh to render in the map
  9221. * @returns The current light
  9222. */
  9223. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9224. /**
  9225. * Gets the current depth scale used in ESM.
  9226. * @returns The scale
  9227. */
  9228. getDepthScale(): number;
  9229. /**
  9230. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9231. * @returns true if a cube texture needs to be use
  9232. */
  9233. needCube(): boolean;
  9234. /**
  9235. * Detects if the projection matrix requires to be recomputed this frame.
  9236. * @returns true if it requires to be recomputed otherwise, false.
  9237. */
  9238. needProjectionMatrixCompute(): boolean;
  9239. /**
  9240. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9241. */
  9242. forceProjectionMatrixCompute(): void;
  9243. /**
  9244. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9245. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9246. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9247. */
  9248. getShadowDirection(faceIndex?: number): Vector3;
  9249. /**
  9250. * Gets the minZ used for shadow according to both the scene and the light.
  9251. * @param activeCamera The camera we are returning the min for
  9252. * @returns the depth min z
  9253. */
  9254. getDepthMinZ(activeCamera: Camera): number;
  9255. /**
  9256. * Gets the maxZ used for shadow according to both the scene and the light.
  9257. * @param activeCamera The camera we are returning the max for
  9258. * @returns the depth max z
  9259. */
  9260. getDepthMaxZ(activeCamera: Camera): number;
  9261. }
  9262. /**
  9263. * Base implementation IShadowLight
  9264. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9265. */
  9266. export abstract class ShadowLight extends Light implements IShadowLight {
  9267. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9268. protected _position: Vector3;
  9269. protected _setPosition(value: Vector3): void;
  9270. /**
  9271. * Sets the position the shadow will be casted from. Also use as the light position for both
  9272. * point and spot lights.
  9273. */
  9274. /**
  9275. * Sets the position the shadow will be casted from. Also use as the light position for both
  9276. * point and spot lights.
  9277. */
  9278. position: Vector3;
  9279. protected _direction: Vector3;
  9280. protected _setDirection(value: Vector3): void;
  9281. /**
  9282. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9283. * Also use as the light direction on spot and directional lights.
  9284. */
  9285. /**
  9286. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9287. * Also use as the light direction on spot and directional lights.
  9288. */
  9289. direction: Vector3;
  9290. private _shadowMinZ;
  9291. /**
  9292. * Gets the shadow projection clipping minimum z value.
  9293. */
  9294. /**
  9295. * Sets the shadow projection clipping minimum z value.
  9296. */
  9297. shadowMinZ: number;
  9298. private _shadowMaxZ;
  9299. /**
  9300. * Sets the shadow projection clipping maximum z value.
  9301. */
  9302. /**
  9303. * Gets the shadow projection clipping maximum z value.
  9304. */
  9305. shadowMaxZ: number;
  9306. /**
  9307. * Callback defining a custom Projection Matrix Builder.
  9308. * This can be used to override the default projection matrix computation.
  9309. */
  9310. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9311. /**
  9312. * The transformed position. Position of the light in world space taking parenting in account.
  9313. */
  9314. transformedPosition: Vector3;
  9315. /**
  9316. * The transformed direction. Direction of the light in world space taking parenting in account.
  9317. */
  9318. transformedDirection: Vector3;
  9319. private _needProjectionMatrixCompute;
  9320. /**
  9321. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9322. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9323. */
  9324. computeTransformedInformation(): boolean;
  9325. /**
  9326. * Return the depth scale used for the shadow map.
  9327. * @returns the depth scale.
  9328. */
  9329. getDepthScale(): number;
  9330. /**
  9331. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9332. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9333. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9334. */
  9335. getShadowDirection(faceIndex?: number): Vector3;
  9336. /**
  9337. * Returns the ShadowLight absolute position in the World.
  9338. * @returns the position vector in world space
  9339. */
  9340. getAbsolutePosition(): Vector3;
  9341. /**
  9342. * Sets the ShadowLight direction toward the passed target.
  9343. * @param target The point to target in local space
  9344. * @returns the updated ShadowLight direction
  9345. */
  9346. setDirectionToTarget(target: Vector3): Vector3;
  9347. /**
  9348. * Returns the light rotation in euler definition.
  9349. * @returns the x y z rotation in local space.
  9350. */
  9351. getRotation(): Vector3;
  9352. /**
  9353. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9354. * @returns true if a cube texture needs to be use
  9355. */
  9356. needCube(): boolean;
  9357. /**
  9358. * Detects if the projection matrix requires to be recomputed this frame.
  9359. * @returns true if it requires to be recomputed otherwise, false.
  9360. */
  9361. needProjectionMatrixCompute(): boolean;
  9362. /**
  9363. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9364. */
  9365. forceProjectionMatrixCompute(): void;
  9366. /** @hidden */
  9367. _initCache(): void;
  9368. /** @hidden */
  9369. _isSynchronized(): boolean;
  9370. /**
  9371. * Computes the world matrix of the node
  9372. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9373. * @returns the world matrix
  9374. */
  9375. computeWorldMatrix(force?: boolean): Matrix;
  9376. /**
  9377. * Gets the minZ used for shadow according to both the scene and the light.
  9378. * @param activeCamera The camera we are returning the min for
  9379. * @returns the depth min z
  9380. */
  9381. getDepthMinZ(activeCamera: Camera): number;
  9382. /**
  9383. * Gets the maxZ used for shadow according to both the scene and the light.
  9384. * @param activeCamera The camera we are returning the max for
  9385. * @returns the depth max z
  9386. */
  9387. getDepthMaxZ(activeCamera: Camera): number;
  9388. /**
  9389. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9390. * @param matrix The materix to updated with the projection information
  9391. * @param viewMatrix The transform matrix of the light
  9392. * @param renderList The list of mesh to render in the map
  9393. * @returns The current light
  9394. */
  9395. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9396. }
  9397. }
  9398. declare module "babylonjs/Materials/materialHelper" {
  9399. import { Nullable } from "babylonjs/types";
  9400. import { Scene } from "babylonjs/scene";
  9401. import { Engine } from "babylonjs/Engines/engine";
  9402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9403. import { Light } from "babylonjs/Lights/light";
  9404. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9405. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9406. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9407. /**
  9408. * "Static Class" containing the most commonly used helper while dealing with material for
  9409. * rendering purpose.
  9410. *
  9411. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9412. *
  9413. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9414. */
  9415. export class MaterialHelper {
  9416. /**
  9417. * Bind the current view position to an effect.
  9418. * @param effect The effect to be bound
  9419. * @param scene The scene the eyes position is used from
  9420. */
  9421. static BindEyePosition(effect: Effect, scene: Scene): void;
  9422. /**
  9423. * Helps preparing the defines values about the UVs in used in the effect.
  9424. * UVs are shared as much as we can accross channels in the shaders.
  9425. * @param texture The texture we are preparing the UVs for
  9426. * @param defines The defines to update
  9427. * @param key The channel key "diffuse", "specular"... used in the shader
  9428. */
  9429. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9430. /**
  9431. * Binds a texture matrix value to its corrsponding uniform
  9432. * @param texture The texture to bind the matrix for
  9433. * @param uniformBuffer The uniform buffer receivin the data
  9434. * @param key The channel key "diffuse", "specular"... used in the shader
  9435. */
  9436. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9437. /**
  9438. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9439. * @param mesh defines the current mesh
  9440. * @param scene defines the current scene
  9441. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9442. * @param pointsCloud defines if point cloud rendering has to be turned on
  9443. * @param fogEnabled defines if fog has to be turned on
  9444. * @param alphaTest defines if alpha testing has to be turned on
  9445. * @param defines defines the current list of defines
  9446. */
  9447. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9448. /**
  9449. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9450. * @param scene defines the current scene
  9451. * @param engine defines the current engine
  9452. * @param defines specifies the list of active defines
  9453. * @param useInstances defines if instances have to be turned on
  9454. * @param useClipPlane defines if clip plane have to be turned on
  9455. */
  9456. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9457. /**
  9458. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9459. * @param mesh The mesh containing the geometry data we will draw
  9460. * @param defines The defines to update
  9461. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9462. * @param useBones Precise whether bones should be used or not (override mesh info)
  9463. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9464. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9465. * @returns false if defines are considered not dirty and have not been checked
  9466. */
  9467. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9468. /**
  9469. * Prepares the defines related to multiview
  9470. * @param scene The scene we are intending to draw
  9471. * @param defines The defines to update
  9472. */
  9473. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9474. /**
  9475. * Prepares the defines related to the light information passed in parameter
  9476. * @param scene The scene we are intending to draw
  9477. * @param mesh The mesh the effect is compiling for
  9478. * @param defines The defines to update
  9479. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9480. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9481. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9482. * @returns true if normals will be required for the rest of the effect
  9483. */
  9484. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9485. /**
  9486. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9487. * that won t be acctive due to defines being turned off.
  9488. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9489. * @param samplersList The samplers list
  9490. * @param defines The defines helping in the list generation
  9491. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9492. */
  9493. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9494. /**
  9495. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9496. * @param defines The defines to update while falling back
  9497. * @param fallbacks The authorized effect fallbacks
  9498. * @param maxSimultaneousLights The maximum number of lights allowed
  9499. * @param rank the current rank of the Effect
  9500. * @returns The newly affected rank
  9501. */
  9502. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9503. /**
  9504. * Prepares the list of attributes required for morph targets according to the effect defines.
  9505. * @param attribs The current list of supported attribs
  9506. * @param mesh The mesh to prepare the morph targets attributes for
  9507. * @param defines The current Defines of the effect
  9508. */
  9509. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9510. /**
  9511. * Prepares the list of attributes required for bones according to the effect defines.
  9512. * @param attribs The current list of supported attribs
  9513. * @param mesh The mesh to prepare the bones attributes for
  9514. * @param defines The current Defines of the effect
  9515. * @param fallbacks The current efffect fallback strategy
  9516. */
  9517. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9518. /**
  9519. * Prepares the list of attributes required for instances according to the effect defines.
  9520. * @param attribs The current list of supported attribs
  9521. * @param defines The current Defines of the effect
  9522. */
  9523. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9524. /**
  9525. * Binds the light shadow information to the effect for the given mesh.
  9526. * @param light The light containing the generator
  9527. * @param scene The scene the lights belongs to
  9528. * @param mesh The mesh we are binding the information to render
  9529. * @param lightIndex The light index in the effect used to render the mesh
  9530. * @param effect The effect we are binding the data to
  9531. */
  9532. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9533. /**
  9534. * Binds the light information to the effect.
  9535. * @param light The light containing the generator
  9536. * @param effect The effect we are binding the data to
  9537. * @param lightIndex The light index in the effect used to render
  9538. */
  9539. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9540. /**
  9541. * Binds the lights information from the scene to the effect for the given mesh.
  9542. * @param scene The scene the lights belongs to
  9543. * @param mesh The mesh we are binding the information to render
  9544. * @param effect The effect we are binding the data to
  9545. * @param defines The generated defines for the effect
  9546. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9547. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9548. */
  9549. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9550. private static _tempFogColor;
  9551. /**
  9552. * Binds the fog information from the scene to the effect for the given mesh.
  9553. * @param scene The scene the lights belongs to
  9554. * @param mesh The mesh we are binding the information to render
  9555. * @param effect The effect we are binding the data to
  9556. * @param linearSpace Defines if the fog effect is applied in linear space
  9557. */
  9558. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9559. /**
  9560. * Binds the bones information from the mesh to the effect.
  9561. * @param mesh The mesh we are binding the information to render
  9562. * @param effect The effect we are binding the data to
  9563. */
  9564. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9565. /**
  9566. * Binds the morph targets information from the mesh to the effect.
  9567. * @param abstractMesh The mesh we are binding the information to render
  9568. * @param effect The effect we are binding the data to
  9569. */
  9570. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9571. /**
  9572. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9573. * @param defines The generated defines used in the effect
  9574. * @param effect The effect we are binding the data to
  9575. * @param scene The scene we are willing to render with logarithmic scale for
  9576. */
  9577. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9578. /**
  9579. * Binds the clip plane information from the scene to the effect.
  9580. * @param scene The scene the clip plane information are extracted from
  9581. * @param effect The effect we are binding the data to
  9582. */
  9583. static BindClipPlane(effect: Effect, scene: Scene): void;
  9584. }
  9585. }
  9586. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9587. /** @hidden */
  9588. export var kernelBlurVaryingDeclaration: {
  9589. name: string;
  9590. shader: string;
  9591. };
  9592. }
  9593. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9594. /** @hidden */
  9595. export var kernelBlurFragment: {
  9596. name: string;
  9597. shader: string;
  9598. };
  9599. }
  9600. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9601. /** @hidden */
  9602. export var kernelBlurFragment2: {
  9603. name: string;
  9604. shader: string;
  9605. };
  9606. }
  9607. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9608. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9609. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9610. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9611. /** @hidden */
  9612. export var kernelBlurPixelShader: {
  9613. name: string;
  9614. shader: string;
  9615. };
  9616. }
  9617. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9618. /** @hidden */
  9619. export var kernelBlurVertex: {
  9620. name: string;
  9621. shader: string;
  9622. };
  9623. }
  9624. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9625. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9626. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9627. /** @hidden */
  9628. export var kernelBlurVertexShader: {
  9629. name: string;
  9630. shader: string;
  9631. };
  9632. }
  9633. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9634. import { Vector2 } from "babylonjs/Maths/math";
  9635. import { Nullable } from "babylonjs/types";
  9636. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9637. import { Camera } from "babylonjs/Cameras/camera";
  9638. import { Effect } from "babylonjs/Materials/effect";
  9639. import { Engine } from "babylonjs/Engines/engine";
  9640. import "babylonjs/Shaders/kernelBlur.fragment";
  9641. import "babylonjs/Shaders/kernelBlur.vertex";
  9642. /**
  9643. * The Blur Post Process which blurs an image based on a kernel and direction.
  9644. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9645. */
  9646. export class BlurPostProcess extends PostProcess {
  9647. /** The direction in which to blur the image. */
  9648. direction: Vector2;
  9649. private blockCompilation;
  9650. protected _kernel: number;
  9651. protected _idealKernel: number;
  9652. protected _packedFloat: boolean;
  9653. private _staticDefines;
  9654. /**
  9655. * Sets the length in pixels of the blur sample region
  9656. */
  9657. /**
  9658. * Gets the length in pixels of the blur sample region
  9659. */
  9660. kernel: number;
  9661. /**
  9662. * Sets wether or not the blur needs to unpack/repack floats
  9663. */
  9664. /**
  9665. * Gets wether or not the blur is unpacking/repacking floats
  9666. */
  9667. packedFloat: boolean;
  9668. /**
  9669. * Creates a new instance BlurPostProcess
  9670. * @param name The name of the effect.
  9671. * @param direction The direction in which to blur the image.
  9672. * @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.
  9673. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9674. * @param camera The camera to apply the render pass to.
  9675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9676. * @param engine The engine which the post process will be applied. (default: current engine)
  9677. * @param reusable If the post process can be reused on the same frame. (default: false)
  9678. * @param textureType Type of textures used when performing the post process. (default: 0)
  9679. * @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)
  9680. */
  9681. constructor(name: string,
  9682. /** The direction in which to blur the image. */
  9683. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9684. /**
  9685. * Updates the effect with the current post process compile time values and recompiles the shader.
  9686. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9687. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9688. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9689. * @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
  9690. * @param onCompiled Called when the shader has been compiled.
  9691. * @param onError Called if there is an error when compiling a shader.
  9692. */
  9693. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9694. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9695. /**
  9696. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9697. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9698. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9699. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9700. * The gaps between physical kernels are compensated for in the weighting of the samples
  9701. * @param idealKernel Ideal blur kernel.
  9702. * @return Nearest best kernel.
  9703. */
  9704. protected _nearestBestKernel(idealKernel: number): number;
  9705. /**
  9706. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9707. * @param x The point on the Gaussian distribution to sample.
  9708. * @return the value of the Gaussian function at x.
  9709. */
  9710. protected _gaussianWeight(x: number): number;
  9711. /**
  9712. * Generates a string that can be used as a floating point number in GLSL.
  9713. * @param x Value to print.
  9714. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9715. * @return GLSL float string.
  9716. */
  9717. protected _glslFloat(x: number, decimalFigures?: number): string;
  9718. }
  9719. }
  9720. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9721. /** @hidden */
  9722. export var shadowMapPixelShader: {
  9723. name: string;
  9724. shader: string;
  9725. };
  9726. }
  9727. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9728. /** @hidden */
  9729. export var bonesDeclaration: {
  9730. name: string;
  9731. shader: string;
  9732. };
  9733. }
  9734. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9735. /** @hidden */
  9736. export var morphTargetsVertexGlobalDeclaration: {
  9737. name: string;
  9738. shader: string;
  9739. };
  9740. }
  9741. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9742. /** @hidden */
  9743. export var morphTargetsVertexDeclaration: {
  9744. name: string;
  9745. shader: string;
  9746. };
  9747. }
  9748. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9749. /** @hidden */
  9750. export var instancesDeclaration: {
  9751. name: string;
  9752. shader: string;
  9753. };
  9754. }
  9755. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9756. /** @hidden */
  9757. export var helperFunctions: {
  9758. name: string;
  9759. shader: string;
  9760. };
  9761. }
  9762. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9763. /** @hidden */
  9764. export var morphTargetsVertex: {
  9765. name: string;
  9766. shader: string;
  9767. };
  9768. }
  9769. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9770. /** @hidden */
  9771. export var instancesVertex: {
  9772. name: string;
  9773. shader: string;
  9774. };
  9775. }
  9776. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9777. /** @hidden */
  9778. export var bonesVertex: {
  9779. name: string;
  9780. shader: string;
  9781. };
  9782. }
  9783. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9784. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9785. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9786. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9787. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9788. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9789. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9790. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9791. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9792. /** @hidden */
  9793. export var shadowMapVertexShader: {
  9794. name: string;
  9795. shader: string;
  9796. };
  9797. }
  9798. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9799. /** @hidden */
  9800. export var depthBoxBlurPixelShader: {
  9801. name: string;
  9802. shader: string;
  9803. };
  9804. }
  9805. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9806. import { Nullable } from "babylonjs/types";
  9807. import { Scene } from "babylonjs/scene";
  9808. import { Matrix } from "babylonjs/Maths/math";
  9809. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9811. import { Mesh } from "babylonjs/Meshes/mesh";
  9812. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9813. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9814. import { Effect } from "babylonjs/Materials/effect";
  9815. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9816. import "babylonjs/Shaders/shadowMap.fragment";
  9817. import "babylonjs/Shaders/shadowMap.vertex";
  9818. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9819. import { Observable } from "babylonjs/Misc/observable";
  9820. /**
  9821. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9822. */
  9823. export interface ICustomShaderOptions {
  9824. /**
  9825. * Gets or sets the custom shader name to use
  9826. */
  9827. shaderName: string;
  9828. /**
  9829. * The list of attribute names used in the shader
  9830. */
  9831. attributes?: string[];
  9832. /**
  9833. * The list of unifrom names used in the shader
  9834. */
  9835. uniforms?: string[];
  9836. /**
  9837. * The list of sampler names used in the shader
  9838. */
  9839. samplers?: string[];
  9840. /**
  9841. * The list of defines used in the shader
  9842. */
  9843. defines?: string[];
  9844. }
  9845. /**
  9846. * Interface to implement to create a shadow generator compatible with BJS.
  9847. */
  9848. export interface IShadowGenerator {
  9849. /**
  9850. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9851. * @returns The render target texture if present otherwise, null
  9852. */
  9853. getShadowMap(): Nullable<RenderTargetTexture>;
  9854. /**
  9855. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9856. * @returns The render target texture if the shadow map is present otherwise, null
  9857. */
  9858. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9859. /**
  9860. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9861. * @param subMesh The submesh we want to render in the shadow map
  9862. * @param useInstances Defines wether will draw in the map using instances
  9863. * @returns true if ready otherwise, false
  9864. */
  9865. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9866. /**
  9867. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9868. * @param defines Defines of the material we want to update
  9869. * @param lightIndex Index of the light in the enabled light list of the material
  9870. */
  9871. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9872. /**
  9873. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9874. * defined in the generator but impacting the effect).
  9875. * It implies the unifroms available on the materials are the standard BJS ones.
  9876. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9877. * @param effect The effect we are binfing the information for
  9878. */
  9879. bindShadowLight(lightIndex: string, effect: Effect): void;
  9880. /**
  9881. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9882. * (eq to shadow prjection matrix * light transform matrix)
  9883. * @returns The transform matrix used to create the shadow map
  9884. */
  9885. getTransformMatrix(): Matrix;
  9886. /**
  9887. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9888. * Cube and 2D textures for instance.
  9889. */
  9890. recreateShadowMap(): void;
  9891. /**
  9892. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9893. * @param onCompiled Callback triggered at the and of the effects compilation
  9894. * @param options Sets of optional options forcing the compilation with different modes
  9895. */
  9896. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9897. useInstances: boolean;
  9898. }>): void;
  9899. /**
  9900. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9901. * @param options Sets of optional options forcing the compilation with different modes
  9902. * @returns A promise that resolves when the compilation completes
  9903. */
  9904. forceCompilationAsync(options?: Partial<{
  9905. useInstances: boolean;
  9906. }>): Promise<void>;
  9907. /**
  9908. * Serializes the shadow generator setup to a json object.
  9909. * @returns The serialized JSON object
  9910. */
  9911. serialize(): any;
  9912. /**
  9913. * Disposes the Shadow map and related Textures and effects.
  9914. */
  9915. dispose(): void;
  9916. }
  9917. /**
  9918. * Default implementation IShadowGenerator.
  9919. * This is the main object responsible of generating shadows in the framework.
  9920. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9921. */
  9922. export class ShadowGenerator implements IShadowGenerator {
  9923. /**
  9924. * Shadow generator mode None: no filtering applied.
  9925. */
  9926. static readonly FILTER_NONE: number;
  9927. /**
  9928. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9929. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9930. */
  9931. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9932. /**
  9933. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9934. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9935. */
  9936. static readonly FILTER_POISSONSAMPLING: number;
  9937. /**
  9938. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9939. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9940. */
  9941. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9942. /**
  9943. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9944. * edge artifacts on steep falloff.
  9945. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9946. */
  9947. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9948. /**
  9949. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9950. * edge artifacts on steep falloff.
  9951. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9952. */
  9953. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9954. /**
  9955. * Shadow generator mode PCF: Percentage Closer Filtering
  9956. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9957. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9958. */
  9959. static readonly FILTER_PCF: number;
  9960. /**
  9961. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9962. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9963. * Contact Hardening
  9964. */
  9965. static readonly FILTER_PCSS: number;
  9966. /**
  9967. * Reserved for PCF and PCSS
  9968. * Highest Quality.
  9969. *
  9970. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9971. *
  9972. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9973. */
  9974. static readonly QUALITY_HIGH: number;
  9975. /**
  9976. * Reserved for PCF and PCSS
  9977. * Good tradeoff for quality/perf cross devices
  9978. *
  9979. * Execute PCF on a 3*3 kernel.
  9980. *
  9981. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9982. */
  9983. static readonly QUALITY_MEDIUM: number;
  9984. /**
  9985. * Reserved for PCF and PCSS
  9986. * The lowest quality but the fastest.
  9987. *
  9988. * Execute PCF on a 1*1 kernel.
  9989. *
  9990. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9991. */
  9992. static readonly QUALITY_LOW: number;
  9993. /** Gets or sets the custom shader name to use */
  9994. customShaderOptions: ICustomShaderOptions;
  9995. /**
  9996. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9997. */
  9998. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9999. /**
  10000. * Observable triggered before a mesh is rendered in the shadow map.
  10001. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  10002. */
  10003. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  10004. private _bias;
  10005. /**
  10006. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10007. */
  10008. /**
  10009. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10010. */
  10011. bias: number;
  10012. private _normalBias;
  10013. /**
  10014. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10015. */
  10016. /**
  10017. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10018. */
  10019. normalBias: number;
  10020. private _blurBoxOffset;
  10021. /**
  10022. * Gets the blur box offset: offset applied during the blur pass.
  10023. * Only useful if useKernelBlur = false
  10024. */
  10025. /**
  10026. * Sets the blur box offset: offset applied during the blur pass.
  10027. * Only useful if useKernelBlur = false
  10028. */
  10029. blurBoxOffset: number;
  10030. private _blurScale;
  10031. /**
  10032. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10033. * 2 means half of the size.
  10034. */
  10035. /**
  10036. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10037. * 2 means half of the size.
  10038. */
  10039. blurScale: number;
  10040. private _blurKernel;
  10041. /**
  10042. * Gets the blur kernel: kernel size of the blur pass.
  10043. * Only useful if useKernelBlur = true
  10044. */
  10045. /**
  10046. * Sets the blur kernel: kernel size of the blur pass.
  10047. * Only useful if useKernelBlur = true
  10048. */
  10049. blurKernel: number;
  10050. private _useKernelBlur;
  10051. /**
  10052. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10053. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10054. */
  10055. /**
  10056. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10057. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10058. */
  10059. useKernelBlur: boolean;
  10060. private _depthScale;
  10061. /**
  10062. * Gets the depth scale used in ESM mode.
  10063. */
  10064. /**
  10065. * Sets the depth scale used in ESM mode.
  10066. * This can override the scale stored on the light.
  10067. */
  10068. depthScale: number;
  10069. private _filter;
  10070. /**
  10071. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10072. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10073. */
  10074. /**
  10075. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10076. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10077. */
  10078. filter: number;
  10079. /**
  10080. * Gets if the current filter is set to Poisson Sampling.
  10081. */
  10082. /**
  10083. * Sets the current filter to Poisson Sampling.
  10084. */
  10085. usePoissonSampling: boolean;
  10086. /**
  10087. * Gets if the current filter is set to ESM.
  10088. */
  10089. /**
  10090. * Sets the current filter is to ESM.
  10091. */
  10092. useExponentialShadowMap: boolean;
  10093. /**
  10094. * Gets if the current filter is set to filtered ESM.
  10095. */
  10096. /**
  10097. * Gets if the current filter is set to filtered ESM.
  10098. */
  10099. useBlurExponentialShadowMap: boolean;
  10100. /**
  10101. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10102. * exponential to prevent steep falloff artifacts).
  10103. */
  10104. /**
  10105. * Sets the current filter to "close ESM" (using the inverse of the
  10106. * exponential to prevent steep falloff artifacts).
  10107. */
  10108. useCloseExponentialShadowMap: boolean;
  10109. /**
  10110. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10111. * exponential to prevent steep falloff artifacts).
  10112. */
  10113. /**
  10114. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10115. * exponential to prevent steep falloff artifacts).
  10116. */
  10117. useBlurCloseExponentialShadowMap: boolean;
  10118. /**
  10119. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10120. */
  10121. /**
  10122. * Sets the current filter to "PCF" (percentage closer filtering).
  10123. */
  10124. usePercentageCloserFiltering: boolean;
  10125. private _filteringQuality;
  10126. /**
  10127. * Gets the PCF or PCSS Quality.
  10128. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10129. */
  10130. /**
  10131. * Sets the PCF or PCSS Quality.
  10132. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10133. */
  10134. filteringQuality: number;
  10135. /**
  10136. * Gets if the current filter is set to "PCSS" (contact hardening).
  10137. */
  10138. /**
  10139. * Sets the current filter to "PCSS" (contact hardening).
  10140. */
  10141. useContactHardeningShadow: boolean;
  10142. private _contactHardeningLightSizeUVRatio;
  10143. /**
  10144. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10145. * Using a ratio helps keeping shape stability independently of the map size.
  10146. *
  10147. * It does not account for the light projection as it was having too much
  10148. * instability during the light setup or during light position changes.
  10149. *
  10150. * Only valid if useContactHardeningShadow is true.
  10151. */
  10152. /**
  10153. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10154. * Using a ratio helps keeping shape stability independently of the map size.
  10155. *
  10156. * It does not account for the light projection as it was having too much
  10157. * instability during the light setup or during light position changes.
  10158. *
  10159. * Only valid if useContactHardeningShadow is true.
  10160. */
  10161. contactHardeningLightSizeUVRatio: number;
  10162. private _darkness;
  10163. /**
  10164. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10165. * 0 means strongest and 1 would means no shadow.
  10166. * @returns the darkness.
  10167. */
  10168. getDarkness(): number;
  10169. /**
  10170. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10171. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10172. * @returns the shadow generator allowing fluent coding.
  10173. */
  10174. setDarkness(darkness: number): ShadowGenerator;
  10175. private _transparencyShadow;
  10176. /**
  10177. * Sets the ability to have transparent shadow (boolean).
  10178. * @param transparent True if transparent else False
  10179. * @returns the shadow generator allowing fluent coding
  10180. */
  10181. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10182. private _shadowMap;
  10183. private _shadowMap2;
  10184. /**
  10185. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10186. * @returns The render target texture if present otherwise, null
  10187. */
  10188. getShadowMap(): Nullable<RenderTargetTexture>;
  10189. /**
  10190. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10191. * @returns The render target texture if the shadow map is present otherwise, null
  10192. */
  10193. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10194. /**
  10195. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10196. * @param mesh Mesh to add
  10197. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10198. * @returns the Shadow Generator itself
  10199. */
  10200. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10201. /**
  10202. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10203. * @param mesh Mesh to remove
  10204. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10205. * @returns the Shadow Generator itself
  10206. */
  10207. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10208. /**
  10209. * Controls the extent to which the shadows fade out at the edge of the frustum
  10210. * Used only by directionals and spots
  10211. */
  10212. frustumEdgeFalloff: number;
  10213. private _light;
  10214. /**
  10215. * Returns the associated light object.
  10216. * @returns the light generating the shadow
  10217. */
  10218. getLight(): IShadowLight;
  10219. /**
  10220. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10221. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10222. * It might on the other hand introduce peter panning.
  10223. */
  10224. forceBackFacesOnly: boolean;
  10225. private _scene;
  10226. private _lightDirection;
  10227. private _effect;
  10228. private _viewMatrix;
  10229. private _projectionMatrix;
  10230. private _transformMatrix;
  10231. private _cachedPosition;
  10232. private _cachedDirection;
  10233. private _cachedDefines;
  10234. private _currentRenderID;
  10235. private _boxBlurPostprocess;
  10236. private _kernelBlurXPostprocess;
  10237. private _kernelBlurYPostprocess;
  10238. private _blurPostProcesses;
  10239. private _mapSize;
  10240. private _currentFaceIndex;
  10241. private _currentFaceIndexCache;
  10242. private _textureType;
  10243. private _defaultTextureMatrix;
  10244. /** @hidden */
  10245. static _SceneComponentInitialization: (scene: Scene) => void;
  10246. /**
  10247. * Creates a ShadowGenerator object.
  10248. * A ShadowGenerator is the required tool to use the shadows.
  10249. * Each light casting shadows needs to use its own ShadowGenerator.
  10250. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10251. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10252. * @param light The light object generating the shadows.
  10253. * @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.
  10254. */
  10255. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10256. private _initializeGenerator;
  10257. private _initializeShadowMap;
  10258. private _initializeBlurRTTAndPostProcesses;
  10259. private _renderForShadowMap;
  10260. private _renderSubMeshForShadowMap;
  10261. private _applyFilterValues;
  10262. /**
  10263. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10264. * @param onCompiled Callback triggered at the and of the effects compilation
  10265. * @param options Sets of optional options forcing the compilation with different modes
  10266. */
  10267. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10268. useInstances: boolean;
  10269. }>): void;
  10270. /**
  10271. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10272. * @param options Sets of optional options forcing the compilation with different modes
  10273. * @returns A promise that resolves when the compilation completes
  10274. */
  10275. forceCompilationAsync(options?: Partial<{
  10276. useInstances: boolean;
  10277. }>): Promise<void>;
  10278. /**
  10279. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10280. * @param subMesh The submesh we want to render in the shadow map
  10281. * @param useInstances Defines wether will draw in the map using instances
  10282. * @returns true if ready otherwise, false
  10283. */
  10284. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10285. /**
  10286. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10287. * @param defines Defines of the material we want to update
  10288. * @param lightIndex Index of the light in the enabled light list of the material
  10289. */
  10290. prepareDefines(defines: any, lightIndex: number): void;
  10291. /**
  10292. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10293. * defined in the generator but impacting the effect).
  10294. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10295. * @param effect The effect we are binfing the information for
  10296. */
  10297. bindShadowLight(lightIndex: string, effect: Effect): void;
  10298. /**
  10299. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10300. * (eq to shadow prjection matrix * light transform matrix)
  10301. * @returns The transform matrix used to create the shadow map
  10302. */
  10303. getTransformMatrix(): Matrix;
  10304. /**
  10305. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10306. * Cube and 2D textures for instance.
  10307. */
  10308. recreateShadowMap(): void;
  10309. private _disposeBlurPostProcesses;
  10310. private _disposeRTTandPostProcesses;
  10311. /**
  10312. * Disposes the ShadowGenerator.
  10313. * Returns nothing.
  10314. */
  10315. dispose(): void;
  10316. /**
  10317. * Serializes the shadow generator setup to a json object.
  10318. * @returns The serialized JSON object
  10319. */
  10320. serialize(): any;
  10321. /**
  10322. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10323. * @param parsedShadowGenerator The JSON object to parse
  10324. * @param scene The scene to create the shadow map for
  10325. * @returns The parsed shadow generator
  10326. */
  10327. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10328. }
  10329. }
  10330. declare module "babylonjs/Lights/light" {
  10331. import { Nullable } from "babylonjs/types";
  10332. import { Scene } from "babylonjs/scene";
  10333. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10334. import { Node } from "babylonjs/node";
  10335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10336. import { Effect } from "babylonjs/Materials/effect";
  10337. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10338. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10339. /**
  10340. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10341. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10342. * 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.
  10343. */
  10344. export abstract class Light extends Node {
  10345. /**
  10346. * Falloff Default: light is falling off following the material specification:
  10347. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10348. */
  10349. static readonly FALLOFF_DEFAULT: number;
  10350. /**
  10351. * Falloff Physical: light is falling off following the inverse squared distance law.
  10352. */
  10353. static readonly FALLOFF_PHYSICAL: number;
  10354. /**
  10355. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10356. * to enhance interoperability with other engines.
  10357. */
  10358. static readonly FALLOFF_GLTF: number;
  10359. /**
  10360. * Falloff Standard: light is falling off like in the standard material
  10361. * to enhance interoperability with other materials.
  10362. */
  10363. static readonly FALLOFF_STANDARD: number;
  10364. /**
  10365. * If every light affecting the material is in this lightmapMode,
  10366. * material.lightmapTexture adds or multiplies
  10367. * (depends on material.useLightmapAsShadowmap)
  10368. * after every other light calculations.
  10369. */
  10370. static readonly LIGHTMAP_DEFAULT: number;
  10371. /**
  10372. * material.lightmapTexture as only diffuse lighting from this light
  10373. * adds only specular lighting from this light
  10374. * adds dynamic shadows
  10375. */
  10376. static readonly LIGHTMAP_SPECULAR: number;
  10377. /**
  10378. * material.lightmapTexture as only lighting
  10379. * no light calculation from this light
  10380. * only adds dynamic shadows from this light
  10381. */
  10382. static readonly LIGHTMAP_SHADOWSONLY: number;
  10383. /**
  10384. * Each light type uses the default quantity according to its type:
  10385. * point/spot lights use luminous intensity
  10386. * directional lights use illuminance
  10387. */
  10388. static readonly INTENSITYMODE_AUTOMATIC: number;
  10389. /**
  10390. * lumen (lm)
  10391. */
  10392. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10393. /**
  10394. * candela (lm/sr)
  10395. */
  10396. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10397. /**
  10398. * lux (lm/m^2)
  10399. */
  10400. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10401. /**
  10402. * nit (cd/m^2)
  10403. */
  10404. static readonly INTENSITYMODE_LUMINANCE: number;
  10405. /**
  10406. * Light type const id of the point light.
  10407. */
  10408. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10409. /**
  10410. * Light type const id of the directional light.
  10411. */
  10412. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10413. /**
  10414. * Light type const id of the spot light.
  10415. */
  10416. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10417. /**
  10418. * Light type const id of the hemispheric light.
  10419. */
  10420. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10421. /**
  10422. * Diffuse gives the basic color to an object.
  10423. */
  10424. diffuse: Color3;
  10425. /**
  10426. * Specular produces a highlight color on an object.
  10427. * Note: This is note affecting PBR materials.
  10428. */
  10429. specular: Color3;
  10430. /**
  10431. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10432. * falling off base on range or angle.
  10433. * This can be set to any values in Light.FALLOFF_x.
  10434. *
  10435. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10436. * other types of materials.
  10437. */
  10438. falloffType: number;
  10439. /**
  10440. * Strength of the light.
  10441. * Note: By default it is define in the framework own unit.
  10442. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10443. */
  10444. intensity: number;
  10445. private _range;
  10446. protected _inverseSquaredRange: number;
  10447. /**
  10448. * Defines how far from the source the light is impacting in scene units.
  10449. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10450. */
  10451. /**
  10452. * Defines how far from the source the light is impacting in scene units.
  10453. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10454. */
  10455. range: number;
  10456. /**
  10457. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10458. * of light.
  10459. */
  10460. private _photometricScale;
  10461. private _intensityMode;
  10462. /**
  10463. * Gets the photometric scale used to interpret the intensity.
  10464. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10465. */
  10466. /**
  10467. * Sets the photometric scale used to interpret the intensity.
  10468. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10469. */
  10470. intensityMode: number;
  10471. private _radius;
  10472. /**
  10473. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10474. */
  10475. /**
  10476. * sets the light radius used by PBR Materials to simulate soft area lights.
  10477. */
  10478. radius: number;
  10479. private _renderPriority;
  10480. /**
  10481. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10482. * exceeding the number allowed of the materials.
  10483. */
  10484. renderPriority: number;
  10485. private _shadowEnabled;
  10486. /**
  10487. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10488. * the current shadow generator.
  10489. */
  10490. /**
  10491. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10492. * the current shadow generator.
  10493. */
  10494. shadowEnabled: boolean;
  10495. private _includedOnlyMeshes;
  10496. /**
  10497. * Gets the only meshes impacted by this light.
  10498. */
  10499. /**
  10500. * Sets the only meshes impacted by this light.
  10501. */
  10502. includedOnlyMeshes: AbstractMesh[];
  10503. private _excludedMeshes;
  10504. /**
  10505. * Gets the meshes not impacted by this light.
  10506. */
  10507. /**
  10508. * Sets the meshes not impacted by this light.
  10509. */
  10510. excludedMeshes: AbstractMesh[];
  10511. private _excludeWithLayerMask;
  10512. /**
  10513. * Gets the layer id use to find what meshes are not impacted by the light.
  10514. * Inactive if 0
  10515. */
  10516. /**
  10517. * Sets the layer id use to find what meshes are not impacted by the light.
  10518. * Inactive if 0
  10519. */
  10520. excludeWithLayerMask: number;
  10521. private _includeOnlyWithLayerMask;
  10522. /**
  10523. * Gets the layer id use to find what meshes are impacted by the light.
  10524. * Inactive if 0
  10525. */
  10526. /**
  10527. * Sets the layer id use to find what meshes are impacted by the light.
  10528. * Inactive if 0
  10529. */
  10530. includeOnlyWithLayerMask: number;
  10531. private _lightmapMode;
  10532. /**
  10533. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10534. */
  10535. /**
  10536. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10537. */
  10538. lightmapMode: number;
  10539. /**
  10540. * Shadow generator associted to the light.
  10541. * @hidden Internal use only.
  10542. */
  10543. _shadowGenerator: Nullable<IShadowGenerator>;
  10544. /**
  10545. * @hidden Internal use only.
  10546. */
  10547. _excludedMeshesIds: string[];
  10548. /**
  10549. * @hidden Internal use only.
  10550. */
  10551. _includedOnlyMeshesIds: string[];
  10552. /**
  10553. * The current light unifom buffer.
  10554. * @hidden Internal use only.
  10555. */
  10556. _uniformBuffer: UniformBuffer;
  10557. /**
  10558. * Creates a Light object in the scene.
  10559. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10560. * @param name The firendly name of the light
  10561. * @param scene The scene the light belongs too
  10562. */
  10563. constructor(name: string, scene: Scene);
  10564. protected abstract _buildUniformLayout(): void;
  10565. /**
  10566. * Sets the passed Effect "effect" with the Light information.
  10567. * @param effect The effect to update
  10568. * @param lightIndex The index of the light in the effect to update
  10569. * @returns The light
  10570. */
  10571. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10572. /**
  10573. * Returns the string "Light".
  10574. * @returns the class name
  10575. */
  10576. getClassName(): string;
  10577. /** @hidden */
  10578. readonly _isLight: boolean;
  10579. /**
  10580. * Converts the light information to a readable string for debug purpose.
  10581. * @param fullDetails Supports for multiple levels of logging within scene loading
  10582. * @returns the human readable light info
  10583. */
  10584. toString(fullDetails?: boolean): string;
  10585. /** @hidden */
  10586. protected _syncParentEnabledState(): void;
  10587. /**
  10588. * Set the enabled state of this node.
  10589. * @param value - the new enabled state
  10590. */
  10591. setEnabled(value: boolean): void;
  10592. /**
  10593. * Returns the Light associated shadow generator if any.
  10594. * @return the associated shadow generator.
  10595. */
  10596. getShadowGenerator(): Nullable<IShadowGenerator>;
  10597. /**
  10598. * Returns a Vector3, the absolute light position in the World.
  10599. * @returns the world space position of the light
  10600. */
  10601. getAbsolutePosition(): Vector3;
  10602. /**
  10603. * Specifies if the light will affect the passed mesh.
  10604. * @param mesh The mesh to test against the light
  10605. * @return true the mesh is affected otherwise, false.
  10606. */
  10607. canAffectMesh(mesh: AbstractMesh): boolean;
  10608. /**
  10609. * Sort function to order lights for rendering.
  10610. * @param a First Light object to compare to second.
  10611. * @param b Second Light object to compare first.
  10612. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10613. */
  10614. static CompareLightsPriority(a: Light, b: Light): number;
  10615. /**
  10616. * Releases resources associated with this node.
  10617. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10618. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10619. */
  10620. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10621. /**
  10622. * Returns the light type ID (integer).
  10623. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10624. */
  10625. getTypeID(): number;
  10626. /**
  10627. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10628. * @returns the scaled intensity in intensity mode unit
  10629. */
  10630. getScaledIntensity(): number;
  10631. /**
  10632. * Returns a new Light object, named "name", from the current one.
  10633. * @param name The name of the cloned light
  10634. * @returns the new created light
  10635. */
  10636. clone(name: string): Nullable<Light>;
  10637. /**
  10638. * Serializes the current light into a Serialization object.
  10639. * @returns the serialized object.
  10640. */
  10641. serialize(): any;
  10642. /**
  10643. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10644. * This new light is named "name" and added to the passed scene.
  10645. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10646. * @param name The friendly name of the light
  10647. * @param scene The scene the new light will belong to
  10648. * @returns the constructor function
  10649. */
  10650. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10651. /**
  10652. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10653. * @param parsedLight The JSON representation of the light
  10654. * @param scene The scene to create the parsed light in
  10655. * @returns the created light after parsing
  10656. */
  10657. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10658. private _hookArrayForExcluded;
  10659. private _hookArrayForIncludedOnly;
  10660. private _resyncMeshes;
  10661. /**
  10662. * Forces the meshes to update their light related information in their rendering used effects
  10663. * @hidden Internal Use Only
  10664. */
  10665. _markMeshesAsLightDirty(): void;
  10666. /**
  10667. * Recomputes the cached photometric scale if needed.
  10668. */
  10669. private _computePhotometricScale;
  10670. /**
  10671. * Returns the Photometric Scale according to the light type and intensity mode.
  10672. */
  10673. private _getPhotometricScale;
  10674. /**
  10675. * Reorder the light in the scene according to their defined priority.
  10676. * @hidden Internal Use Only
  10677. */
  10678. _reorderLightsInScene(): void;
  10679. /**
  10680. * Prepares the list of defines specific to the light type.
  10681. * @param defines the list of defines
  10682. * @param lightIndex defines the index of the light for the effect
  10683. */
  10684. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10685. }
  10686. }
  10687. declare module "babylonjs/Actions/action" {
  10688. import { Observable } from "babylonjs/Misc/observable";
  10689. import { Condition } from "babylonjs/Actions/condition";
  10690. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10691. import { ActionManager } from "babylonjs/Actions/actionManager";
  10692. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10693. /**
  10694. * Interface used to define Action
  10695. */
  10696. export interface IAction {
  10697. /**
  10698. * Trigger for the action
  10699. */
  10700. trigger: number;
  10701. /** Options of the trigger */
  10702. triggerOptions: any;
  10703. /**
  10704. * Gets the trigger parameters
  10705. * @returns the trigger parameters
  10706. */
  10707. getTriggerParameter(): any;
  10708. /**
  10709. * Internal only - executes current action event
  10710. * @hidden
  10711. */
  10712. _executeCurrent(evt?: ActionEvent): void;
  10713. /**
  10714. * Serialize placeholder for child classes
  10715. * @param parent of child
  10716. * @returns the serialized object
  10717. */
  10718. serialize(parent: any): any;
  10719. /**
  10720. * Internal only
  10721. * @hidden
  10722. */
  10723. _prepare(): void;
  10724. /**
  10725. * Internal only - manager for action
  10726. * @hidden
  10727. */
  10728. _actionManager: AbstractActionManager;
  10729. }
  10730. /**
  10731. * The action to be carried out following a trigger
  10732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10733. */
  10734. export class Action implements IAction {
  10735. /** the trigger, with or without parameters, for the action */
  10736. triggerOptions: any;
  10737. /**
  10738. * Trigger for the action
  10739. */
  10740. trigger: number;
  10741. /**
  10742. * Internal only - manager for action
  10743. * @hidden
  10744. */
  10745. _actionManager: ActionManager;
  10746. private _nextActiveAction;
  10747. private _child;
  10748. private _condition?;
  10749. private _triggerParameter;
  10750. /**
  10751. * An event triggered prior to action being executed.
  10752. */
  10753. onBeforeExecuteObservable: Observable<Action>;
  10754. /**
  10755. * Creates a new Action
  10756. * @param triggerOptions the trigger, with or without parameters, for the action
  10757. * @param condition an optional determinant of action
  10758. */
  10759. constructor(
  10760. /** the trigger, with or without parameters, for the action */
  10761. triggerOptions: any, condition?: Condition);
  10762. /**
  10763. * Internal only
  10764. * @hidden
  10765. */
  10766. _prepare(): void;
  10767. /**
  10768. * Gets the trigger parameters
  10769. * @returns the trigger parameters
  10770. */
  10771. getTriggerParameter(): any;
  10772. /**
  10773. * Internal only - executes current action event
  10774. * @hidden
  10775. */
  10776. _executeCurrent(evt?: ActionEvent): void;
  10777. /**
  10778. * Execute placeholder for child classes
  10779. * @param evt optional action event
  10780. */
  10781. execute(evt?: ActionEvent): void;
  10782. /**
  10783. * Skips to next active action
  10784. */
  10785. skipToNextActiveAction(): void;
  10786. /**
  10787. * Adds action to chain of actions, may be a DoNothingAction
  10788. * @param action defines the next action to execute
  10789. * @returns The action passed in
  10790. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10791. */
  10792. then(action: Action): Action;
  10793. /**
  10794. * Internal only
  10795. * @hidden
  10796. */
  10797. _getProperty(propertyPath: string): string;
  10798. /**
  10799. * Internal only
  10800. * @hidden
  10801. */
  10802. _getEffectiveTarget(target: any, propertyPath: string): any;
  10803. /**
  10804. * Serialize placeholder for child classes
  10805. * @param parent of child
  10806. * @returns the serialized object
  10807. */
  10808. serialize(parent: any): any;
  10809. /**
  10810. * Internal only called by serialize
  10811. * @hidden
  10812. */
  10813. protected _serialize(serializedAction: any, parent?: any): any;
  10814. /**
  10815. * Internal only
  10816. * @hidden
  10817. */
  10818. static _SerializeValueAsString: (value: any) => string;
  10819. /**
  10820. * Internal only
  10821. * @hidden
  10822. */
  10823. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10824. name: string;
  10825. targetType: string;
  10826. value: string;
  10827. };
  10828. }
  10829. }
  10830. declare module "babylonjs/Actions/condition" {
  10831. import { ActionManager } from "babylonjs/Actions/actionManager";
  10832. /**
  10833. * A Condition applied to an Action
  10834. */
  10835. export class Condition {
  10836. /**
  10837. * Internal only - manager for action
  10838. * @hidden
  10839. */
  10840. _actionManager: ActionManager;
  10841. /**
  10842. * Internal only
  10843. * @hidden
  10844. */
  10845. _evaluationId: number;
  10846. /**
  10847. * Internal only
  10848. * @hidden
  10849. */
  10850. _currentResult: boolean;
  10851. /**
  10852. * Creates a new Condition
  10853. * @param actionManager the manager of the action the condition is applied to
  10854. */
  10855. constructor(actionManager: ActionManager);
  10856. /**
  10857. * Check if the current condition is valid
  10858. * @returns a boolean
  10859. */
  10860. isValid(): boolean;
  10861. /**
  10862. * Internal only
  10863. * @hidden
  10864. */
  10865. _getProperty(propertyPath: string): string;
  10866. /**
  10867. * Internal only
  10868. * @hidden
  10869. */
  10870. _getEffectiveTarget(target: any, propertyPath: string): any;
  10871. /**
  10872. * Serialize placeholder for child classes
  10873. * @returns the serialized object
  10874. */
  10875. serialize(): any;
  10876. /**
  10877. * Internal only
  10878. * @hidden
  10879. */
  10880. protected _serialize(serializedCondition: any): any;
  10881. }
  10882. /**
  10883. * Defines specific conditional operators as extensions of Condition
  10884. */
  10885. export class ValueCondition extends Condition {
  10886. /** path to specify the property of the target the conditional operator uses */
  10887. propertyPath: string;
  10888. /** the value compared by the conditional operator against the current value of the property */
  10889. value: any;
  10890. /** the conditional operator, default ValueCondition.IsEqual */
  10891. operator: number;
  10892. /**
  10893. * Internal only
  10894. * @hidden
  10895. */
  10896. private static _IsEqual;
  10897. /**
  10898. * Internal only
  10899. * @hidden
  10900. */
  10901. private static _IsDifferent;
  10902. /**
  10903. * Internal only
  10904. * @hidden
  10905. */
  10906. private static _IsGreater;
  10907. /**
  10908. * Internal only
  10909. * @hidden
  10910. */
  10911. private static _IsLesser;
  10912. /**
  10913. * returns the number for IsEqual
  10914. */
  10915. static readonly IsEqual: number;
  10916. /**
  10917. * Returns the number for IsDifferent
  10918. */
  10919. static readonly IsDifferent: number;
  10920. /**
  10921. * Returns the number for IsGreater
  10922. */
  10923. static readonly IsGreater: number;
  10924. /**
  10925. * Returns the number for IsLesser
  10926. */
  10927. static readonly IsLesser: number;
  10928. /**
  10929. * Internal only The action manager for the condition
  10930. * @hidden
  10931. */
  10932. _actionManager: ActionManager;
  10933. /**
  10934. * Internal only
  10935. * @hidden
  10936. */
  10937. private _target;
  10938. /**
  10939. * Internal only
  10940. * @hidden
  10941. */
  10942. private _effectiveTarget;
  10943. /**
  10944. * Internal only
  10945. * @hidden
  10946. */
  10947. private _property;
  10948. /**
  10949. * Creates a new ValueCondition
  10950. * @param actionManager manager for the action the condition applies to
  10951. * @param target for the action
  10952. * @param propertyPath path to specify the property of the target the conditional operator uses
  10953. * @param value the value compared by the conditional operator against the current value of the property
  10954. * @param operator the conditional operator, default ValueCondition.IsEqual
  10955. */
  10956. constructor(actionManager: ActionManager, target: any,
  10957. /** path to specify the property of the target the conditional operator uses */
  10958. propertyPath: string,
  10959. /** the value compared by the conditional operator against the current value of the property */
  10960. value: any,
  10961. /** the conditional operator, default ValueCondition.IsEqual */
  10962. operator?: number);
  10963. /**
  10964. * Compares the given value with the property value for the specified conditional operator
  10965. * @returns the result of the comparison
  10966. */
  10967. isValid(): boolean;
  10968. /**
  10969. * Serialize the ValueCondition into a JSON compatible object
  10970. * @returns serialization object
  10971. */
  10972. serialize(): any;
  10973. /**
  10974. * Gets the name of the conditional operator for the ValueCondition
  10975. * @param operator the conditional operator
  10976. * @returns the name
  10977. */
  10978. static GetOperatorName(operator: number): string;
  10979. }
  10980. /**
  10981. * Defines a predicate condition as an extension of Condition
  10982. */
  10983. export class PredicateCondition extends Condition {
  10984. /** defines the predicate function used to validate the condition */
  10985. predicate: () => boolean;
  10986. /**
  10987. * Internal only - manager for action
  10988. * @hidden
  10989. */
  10990. _actionManager: ActionManager;
  10991. /**
  10992. * Creates a new PredicateCondition
  10993. * @param actionManager manager for the action the condition applies to
  10994. * @param predicate defines the predicate function used to validate the condition
  10995. */
  10996. constructor(actionManager: ActionManager,
  10997. /** defines the predicate function used to validate the condition */
  10998. predicate: () => boolean);
  10999. /**
  11000. * @returns the validity of the predicate condition
  11001. */
  11002. isValid(): boolean;
  11003. }
  11004. /**
  11005. * Defines a state condition as an extension of Condition
  11006. */
  11007. export class StateCondition extends Condition {
  11008. /** Value to compare with target state */
  11009. value: string;
  11010. /**
  11011. * Internal only - manager for action
  11012. * @hidden
  11013. */
  11014. _actionManager: ActionManager;
  11015. /**
  11016. * Internal only
  11017. * @hidden
  11018. */
  11019. private _target;
  11020. /**
  11021. * Creates a new StateCondition
  11022. * @param actionManager manager for the action the condition applies to
  11023. * @param target of the condition
  11024. * @param value to compare with target state
  11025. */
  11026. constructor(actionManager: ActionManager, target: any,
  11027. /** Value to compare with target state */
  11028. value: string);
  11029. /**
  11030. * Gets a boolean indicating if the current condition is met
  11031. * @returns the validity of the state
  11032. */
  11033. isValid(): boolean;
  11034. /**
  11035. * Serialize the StateCondition into a JSON compatible object
  11036. * @returns serialization object
  11037. */
  11038. serialize(): any;
  11039. }
  11040. }
  11041. declare module "babylonjs/Actions/directActions" {
  11042. import { Action } from "babylonjs/Actions/action";
  11043. import { Condition } from "babylonjs/Actions/condition";
  11044. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  11045. /**
  11046. * This defines an action responsible to toggle a boolean once triggered.
  11047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11048. */
  11049. export class SwitchBooleanAction extends Action {
  11050. /**
  11051. * The path to the boolean property in the target object
  11052. */
  11053. propertyPath: string;
  11054. private _target;
  11055. private _effectiveTarget;
  11056. private _property;
  11057. /**
  11058. * Instantiate the action
  11059. * @param triggerOptions defines the trigger options
  11060. * @param target defines the object containing the boolean
  11061. * @param propertyPath defines the path to the boolean property in the target object
  11062. * @param condition defines the trigger related conditions
  11063. */
  11064. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11065. /** @hidden */
  11066. _prepare(): void;
  11067. /**
  11068. * Execute the action toggle the boolean value.
  11069. */
  11070. execute(): void;
  11071. /**
  11072. * Serializes the actions and its related information.
  11073. * @param parent defines the object to serialize in
  11074. * @returns the serialized object
  11075. */
  11076. serialize(parent: any): any;
  11077. }
  11078. /**
  11079. * This defines an action responsible to set a the state field of the target
  11080. * to a desired value once triggered.
  11081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11082. */
  11083. export class SetStateAction extends Action {
  11084. /**
  11085. * The value to store in the state field.
  11086. */
  11087. value: string;
  11088. private _target;
  11089. /**
  11090. * Instantiate the action
  11091. * @param triggerOptions defines the trigger options
  11092. * @param target defines the object containing the state property
  11093. * @param value defines the value to store in the state field
  11094. * @param condition defines the trigger related conditions
  11095. */
  11096. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11097. /**
  11098. * Execute the action and store the value on the target state property.
  11099. */
  11100. execute(): void;
  11101. /**
  11102. * Serializes the actions and its related information.
  11103. * @param parent defines the object to serialize in
  11104. * @returns the serialized object
  11105. */
  11106. serialize(parent: any): any;
  11107. }
  11108. /**
  11109. * This defines an action responsible to set a property of the target
  11110. * to a desired value once triggered.
  11111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11112. */
  11113. export class SetValueAction extends Action {
  11114. /**
  11115. * The path of the property to set in the target.
  11116. */
  11117. propertyPath: string;
  11118. /**
  11119. * The value to set in the property
  11120. */
  11121. value: any;
  11122. private _target;
  11123. private _effectiveTarget;
  11124. private _property;
  11125. /**
  11126. * Instantiate the action
  11127. * @param triggerOptions defines the trigger options
  11128. * @param target defines the object containing the property
  11129. * @param propertyPath defines the path of the property to set in the target
  11130. * @param value defines the value to set in the property
  11131. * @param condition defines the trigger related conditions
  11132. */
  11133. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11134. /** @hidden */
  11135. _prepare(): void;
  11136. /**
  11137. * Execute the action and set the targetted property to the desired value.
  11138. */
  11139. execute(): void;
  11140. /**
  11141. * Serializes the actions and its related information.
  11142. * @param parent defines the object to serialize in
  11143. * @returns the serialized object
  11144. */
  11145. serialize(parent: any): any;
  11146. }
  11147. /**
  11148. * This defines an action responsible to increment the target value
  11149. * to a desired value once triggered.
  11150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11151. */
  11152. export class IncrementValueAction extends Action {
  11153. /**
  11154. * The path of the property to increment in the target.
  11155. */
  11156. propertyPath: string;
  11157. /**
  11158. * The value we should increment the property by.
  11159. */
  11160. value: any;
  11161. private _target;
  11162. private _effectiveTarget;
  11163. private _property;
  11164. /**
  11165. * Instantiate the action
  11166. * @param triggerOptions defines the trigger options
  11167. * @param target defines the object containing the property
  11168. * @param propertyPath defines the path of the property to increment in the target
  11169. * @param value defines the value value we should increment the property by
  11170. * @param condition defines the trigger related conditions
  11171. */
  11172. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11173. /** @hidden */
  11174. _prepare(): void;
  11175. /**
  11176. * Execute the action and increment the target of the value amount.
  11177. */
  11178. execute(): void;
  11179. /**
  11180. * Serializes the actions and its related information.
  11181. * @param parent defines the object to serialize in
  11182. * @returns the serialized object
  11183. */
  11184. serialize(parent: any): any;
  11185. }
  11186. /**
  11187. * This defines an action responsible to start an animation once triggered.
  11188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11189. */
  11190. export class PlayAnimationAction extends Action {
  11191. /**
  11192. * Where the animation should start (animation frame)
  11193. */
  11194. from: number;
  11195. /**
  11196. * Where the animation should stop (animation frame)
  11197. */
  11198. to: number;
  11199. /**
  11200. * Define if the animation should loop or stop after the first play.
  11201. */
  11202. loop?: boolean;
  11203. private _target;
  11204. /**
  11205. * Instantiate the action
  11206. * @param triggerOptions defines the trigger options
  11207. * @param target defines the target animation or animation name
  11208. * @param from defines from where the animation should start (animation frame)
  11209. * @param end defines where the animation should stop (animation frame)
  11210. * @param loop defines if the animation should loop or stop after the first play
  11211. * @param condition defines the trigger related conditions
  11212. */
  11213. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11214. /** @hidden */
  11215. _prepare(): void;
  11216. /**
  11217. * Execute the action and play the animation.
  11218. */
  11219. execute(): void;
  11220. /**
  11221. * Serializes the actions and its related information.
  11222. * @param parent defines the object to serialize in
  11223. * @returns the serialized object
  11224. */
  11225. serialize(parent: any): any;
  11226. }
  11227. /**
  11228. * This defines an action responsible to stop an animation once triggered.
  11229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11230. */
  11231. export class StopAnimationAction extends Action {
  11232. private _target;
  11233. /**
  11234. * Instantiate the action
  11235. * @param triggerOptions defines the trigger options
  11236. * @param target defines the target animation or animation name
  11237. * @param condition defines the trigger related conditions
  11238. */
  11239. constructor(triggerOptions: any, target: any, condition?: Condition);
  11240. /** @hidden */
  11241. _prepare(): void;
  11242. /**
  11243. * Execute the action and stop the animation.
  11244. */
  11245. execute(): void;
  11246. /**
  11247. * Serializes the actions and its related information.
  11248. * @param parent defines the object to serialize in
  11249. * @returns the serialized object
  11250. */
  11251. serialize(parent: any): any;
  11252. }
  11253. /**
  11254. * This defines an action responsible that does nothing once triggered.
  11255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11256. */
  11257. export class DoNothingAction extends Action {
  11258. /**
  11259. * Instantiate the action
  11260. * @param triggerOptions defines the trigger options
  11261. * @param condition defines the trigger related conditions
  11262. */
  11263. constructor(triggerOptions?: any, condition?: Condition);
  11264. /**
  11265. * Execute the action and do nothing.
  11266. */
  11267. execute(): void;
  11268. /**
  11269. * Serializes the actions and its related information.
  11270. * @param parent defines the object to serialize in
  11271. * @returns the serialized object
  11272. */
  11273. serialize(parent: any): any;
  11274. }
  11275. /**
  11276. * This defines an action responsible to trigger several actions once triggered.
  11277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11278. */
  11279. export class CombineAction extends Action {
  11280. /**
  11281. * The list of aggregated animations to run.
  11282. */
  11283. children: Action[];
  11284. /**
  11285. * Instantiate the action
  11286. * @param triggerOptions defines the trigger options
  11287. * @param children defines the list of aggregated animations to run
  11288. * @param condition defines the trigger related conditions
  11289. */
  11290. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11291. /** @hidden */
  11292. _prepare(): void;
  11293. /**
  11294. * Execute the action and executes all the aggregated actions.
  11295. */
  11296. execute(evt: ActionEvent): void;
  11297. /**
  11298. * Serializes the actions and its related information.
  11299. * @param parent defines the object to serialize in
  11300. * @returns the serialized object
  11301. */
  11302. serialize(parent: any): any;
  11303. }
  11304. /**
  11305. * This defines an action responsible to run code (external event) once triggered.
  11306. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11307. */
  11308. export class ExecuteCodeAction extends Action {
  11309. /**
  11310. * The callback function to run.
  11311. */
  11312. func: (evt: ActionEvent) => void;
  11313. /**
  11314. * Instantiate the action
  11315. * @param triggerOptions defines the trigger options
  11316. * @param func defines the callback function to run
  11317. * @param condition defines the trigger related conditions
  11318. */
  11319. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11320. /**
  11321. * Execute the action and run the attached code.
  11322. */
  11323. execute(evt: ActionEvent): void;
  11324. }
  11325. /**
  11326. * This defines an action responsible to set the parent property of the target once triggered.
  11327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11328. */
  11329. export class SetParentAction extends Action {
  11330. private _parent;
  11331. private _target;
  11332. /**
  11333. * Instantiate the action
  11334. * @param triggerOptions defines the trigger options
  11335. * @param target defines the target containing the parent property
  11336. * @param parent defines from where the animation should start (animation frame)
  11337. * @param condition defines the trigger related conditions
  11338. */
  11339. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11340. /** @hidden */
  11341. _prepare(): void;
  11342. /**
  11343. * Execute the action and set the parent property.
  11344. */
  11345. execute(): void;
  11346. /**
  11347. * Serializes the actions and its related information.
  11348. * @param parent defines the object to serialize in
  11349. * @returns the serialized object
  11350. */
  11351. serialize(parent: any): any;
  11352. }
  11353. }
  11354. declare module "babylonjs/Actions/actionManager" {
  11355. import { Nullable } from "babylonjs/types";
  11356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11357. import { Scene } from "babylonjs/scene";
  11358. import { IAction } from "babylonjs/Actions/action";
  11359. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11360. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11361. /**
  11362. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11363. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11365. */
  11366. export class ActionManager extends AbstractActionManager {
  11367. /**
  11368. * Nothing
  11369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11370. */
  11371. static readonly NothingTrigger: number;
  11372. /**
  11373. * On pick
  11374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11375. */
  11376. static readonly OnPickTrigger: number;
  11377. /**
  11378. * On left pick
  11379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11380. */
  11381. static readonly OnLeftPickTrigger: number;
  11382. /**
  11383. * On right pick
  11384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11385. */
  11386. static readonly OnRightPickTrigger: number;
  11387. /**
  11388. * On center pick
  11389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11390. */
  11391. static readonly OnCenterPickTrigger: number;
  11392. /**
  11393. * On pick down
  11394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11395. */
  11396. static readonly OnPickDownTrigger: number;
  11397. /**
  11398. * On double pick
  11399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11400. */
  11401. static readonly OnDoublePickTrigger: number;
  11402. /**
  11403. * On pick up
  11404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11405. */
  11406. static readonly OnPickUpTrigger: number;
  11407. /**
  11408. * On pick out.
  11409. * This trigger will only be raised if you also declared a OnPickDown
  11410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11411. */
  11412. static readonly OnPickOutTrigger: number;
  11413. /**
  11414. * On long press
  11415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11416. */
  11417. static readonly OnLongPressTrigger: number;
  11418. /**
  11419. * On pointer over
  11420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11421. */
  11422. static readonly OnPointerOverTrigger: number;
  11423. /**
  11424. * On pointer out
  11425. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11426. */
  11427. static readonly OnPointerOutTrigger: number;
  11428. /**
  11429. * On every frame
  11430. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11431. */
  11432. static readonly OnEveryFrameTrigger: number;
  11433. /**
  11434. * On intersection enter
  11435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11436. */
  11437. static readonly OnIntersectionEnterTrigger: number;
  11438. /**
  11439. * On intersection exit
  11440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11441. */
  11442. static readonly OnIntersectionExitTrigger: number;
  11443. /**
  11444. * On key down
  11445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11446. */
  11447. static readonly OnKeyDownTrigger: number;
  11448. /**
  11449. * On key up
  11450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11451. */
  11452. static readonly OnKeyUpTrigger: number;
  11453. private _scene;
  11454. /**
  11455. * Creates a new action manager
  11456. * @param scene defines the hosting scene
  11457. */
  11458. constructor(scene: Scene);
  11459. /**
  11460. * Releases all associated resources
  11461. */
  11462. dispose(): void;
  11463. /**
  11464. * Gets hosting scene
  11465. * @returns the hosting scene
  11466. */
  11467. getScene(): Scene;
  11468. /**
  11469. * Does this action manager handles actions of any of the given triggers
  11470. * @param triggers defines the triggers to be tested
  11471. * @return a boolean indicating whether one (or more) of the triggers is handled
  11472. */
  11473. hasSpecificTriggers(triggers: number[]): boolean;
  11474. /**
  11475. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11476. * speed.
  11477. * @param triggerA defines the trigger to be tested
  11478. * @param triggerB defines the trigger to be tested
  11479. * @return a boolean indicating whether one (or more) of the triggers is handled
  11480. */
  11481. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11482. /**
  11483. * Does this action manager handles actions of a given trigger
  11484. * @param trigger defines the trigger to be tested
  11485. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11486. * @return whether the trigger is handled
  11487. */
  11488. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11489. /**
  11490. * Does this action manager has pointer triggers
  11491. */
  11492. readonly hasPointerTriggers: boolean;
  11493. /**
  11494. * Does this action manager has pick triggers
  11495. */
  11496. readonly hasPickTriggers: boolean;
  11497. /**
  11498. * Registers an action to this action manager
  11499. * @param action defines the action to be registered
  11500. * @return the action amended (prepared) after registration
  11501. */
  11502. registerAction(action: IAction): Nullable<IAction>;
  11503. /**
  11504. * Unregisters an action to this action manager
  11505. * @param action defines the action to be unregistered
  11506. * @return a boolean indicating whether the action has been unregistered
  11507. */
  11508. unregisterAction(action: IAction): Boolean;
  11509. /**
  11510. * Process a specific trigger
  11511. * @param trigger defines the trigger to process
  11512. * @param evt defines the event details to be processed
  11513. */
  11514. processTrigger(trigger: number, evt?: IActionEvent): void;
  11515. /** @hidden */
  11516. _getEffectiveTarget(target: any, propertyPath: string): any;
  11517. /** @hidden */
  11518. _getProperty(propertyPath: string): string;
  11519. /**
  11520. * Serialize this manager to a JSON object
  11521. * @param name defines the property name to store this manager
  11522. * @returns a JSON representation of this manager
  11523. */
  11524. serialize(name: string): any;
  11525. /**
  11526. * Creates a new ActionManager from a JSON data
  11527. * @param parsedActions defines the JSON data to read from
  11528. * @param object defines the hosting mesh
  11529. * @param scene defines the hosting scene
  11530. */
  11531. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11532. /**
  11533. * Get a trigger name by index
  11534. * @param trigger defines the trigger index
  11535. * @returns a trigger name
  11536. */
  11537. static GetTriggerName(trigger: number): string;
  11538. }
  11539. }
  11540. declare module "babylonjs/Culling/ray" {
  11541. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11542. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11544. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11545. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11546. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11547. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11548. /**
  11549. * Class representing a ray with position and direction
  11550. */
  11551. export class Ray {
  11552. /** origin point */
  11553. origin: Vector3;
  11554. /** direction */
  11555. direction: Vector3;
  11556. /** length of the ray */
  11557. length: number;
  11558. private static readonly TmpVector3;
  11559. private _tmpRay;
  11560. /**
  11561. * Creates a new ray
  11562. * @param origin origin point
  11563. * @param direction direction
  11564. * @param length length of the ray
  11565. */
  11566. constructor(
  11567. /** origin point */
  11568. origin: Vector3,
  11569. /** direction */
  11570. direction: Vector3,
  11571. /** length of the ray */
  11572. length?: number);
  11573. /**
  11574. * Checks if the ray intersects a box
  11575. * @param minimum bound of the box
  11576. * @param maximum bound of the box
  11577. * @param intersectionTreshold extra extend to be added to the box in all direction
  11578. * @returns if the box was hit
  11579. */
  11580. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11581. /**
  11582. * Checks if the ray intersects a box
  11583. * @param box the bounding box to check
  11584. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11585. * @returns if the box was hit
  11586. */
  11587. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11588. /**
  11589. * If the ray hits a sphere
  11590. * @param sphere the bounding sphere to check
  11591. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11592. * @returns true if it hits the sphere
  11593. */
  11594. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11595. /**
  11596. * If the ray hits a triange
  11597. * @param vertex0 triangle vertex
  11598. * @param vertex1 triangle vertex
  11599. * @param vertex2 triangle vertex
  11600. * @returns intersection information if hit
  11601. */
  11602. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11603. /**
  11604. * Checks if ray intersects a plane
  11605. * @param plane the plane to check
  11606. * @returns the distance away it was hit
  11607. */
  11608. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11609. /**
  11610. * Checks if ray intersects a mesh
  11611. * @param mesh the mesh to check
  11612. * @param fastCheck if only the bounding box should checked
  11613. * @returns picking info of the intersecton
  11614. */
  11615. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11616. /**
  11617. * Checks if ray intersects a mesh
  11618. * @param meshes the meshes to check
  11619. * @param fastCheck if only the bounding box should checked
  11620. * @param results array to store result in
  11621. * @returns Array of picking infos
  11622. */
  11623. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11624. private _comparePickingInfo;
  11625. private static smallnum;
  11626. private static rayl;
  11627. /**
  11628. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11629. * @param sega the first point of the segment to test the intersection against
  11630. * @param segb the second point of the segment to test the intersection against
  11631. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11632. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11633. */
  11634. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11635. /**
  11636. * Update the ray from viewport position
  11637. * @param x position
  11638. * @param y y position
  11639. * @param viewportWidth viewport width
  11640. * @param viewportHeight viewport height
  11641. * @param world world matrix
  11642. * @param view view matrix
  11643. * @param projection projection matrix
  11644. * @returns this ray updated
  11645. */
  11646. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11647. /**
  11648. * Creates a ray with origin and direction of 0,0,0
  11649. * @returns the new ray
  11650. */
  11651. static Zero(): Ray;
  11652. /**
  11653. * Creates a new ray from screen space and viewport
  11654. * @param x position
  11655. * @param y y position
  11656. * @param viewportWidth viewport width
  11657. * @param viewportHeight viewport height
  11658. * @param world world matrix
  11659. * @param view view matrix
  11660. * @param projection projection matrix
  11661. * @returns new ray
  11662. */
  11663. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11664. /**
  11665. * 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
  11666. * transformed to the given world matrix.
  11667. * @param origin The origin point
  11668. * @param end The end point
  11669. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11670. * @returns the new ray
  11671. */
  11672. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11673. /**
  11674. * Transforms a ray by a matrix
  11675. * @param ray ray to transform
  11676. * @param matrix matrix to apply
  11677. * @returns the resulting new ray
  11678. */
  11679. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11680. /**
  11681. * Transforms a ray by a matrix
  11682. * @param ray ray to transform
  11683. * @param matrix matrix to apply
  11684. * @param result ray to store result in
  11685. */
  11686. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11687. /**
  11688. * Unproject a ray from screen space to object space
  11689. * @param sourceX defines the screen space x coordinate to use
  11690. * @param sourceY defines the screen space y coordinate to use
  11691. * @param viewportWidth defines the current width of the viewport
  11692. * @param viewportHeight defines the current height of the viewport
  11693. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11694. * @param view defines the view matrix to use
  11695. * @param projection defines the projection matrix to use
  11696. */
  11697. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11698. }
  11699. /**
  11700. * Type used to define predicate used to select faces when a mesh intersection is detected
  11701. */
  11702. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11703. module "babylonjs/scene" {
  11704. interface Scene {
  11705. /** @hidden */
  11706. _tempPickingRay: Nullable<Ray>;
  11707. /** @hidden */
  11708. _cachedRayForTransform: Ray;
  11709. /** @hidden */
  11710. _pickWithRayInverseMatrix: Matrix;
  11711. /** @hidden */
  11712. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11713. /** @hidden */
  11714. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11715. }
  11716. }
  11717. }
  11718. declare module "babylonjs/sceneComponent" {
  11719. import { Scene } from "babylonjs/scene";
  11720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11721. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11722. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11723. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11724. import { Nullable } from "babylonjs/types";
  11725. import { Camera } from "babylonjs/Cameras/camera";
  11726. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11727. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11728. import { AbstractScene } from "babylonjs/abstractScene";
  11729. /**
  11730. * Groups all the scene component constants in one place to ease maintenance.
  11731. * @hidden
  11732. */
  11733. export class SceneComponentConstants {
  11734. static readonly NAME_EFFECTLAYER: string;
  11735. static readonly NAME_LAYER: string;
  11736. static readonly NAME_LENSFLARESYSTEM: string;
  11737. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11738. static readonly NAME_PARTICLESYSTEM: string;
  11739. static readonly NAME_GAMEPAD: string;
  11740. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11741. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11742. static readonly NAME_DEPTHRENDERER: string;
  11743. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11744. static readonly NAME_SPRITE: string;
  11745. static readonly NAME_OUTLINERENDERER: string;
  11746. static readonly NAME_PROCEDURALTEXTURE: string;
  11747. static readonly NAME_SHADOWGENERATOR: string;
  11748. static readonly NAME_OCTREE: string;
  11749. static readonly NAME_PHYSICSENGINE: string;
  11750. static readonly NAME_AUDIO: string;
  11751. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11752. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11753. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11754. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11755. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11756. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11757. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11758. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11759. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11760. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11761. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11762. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11763. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11764. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11765. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11766. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11767. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11768. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11769. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11770. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11771. static readonly STEP_AFTERRENDER_AUDIO: number;
  11772. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11773. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11774. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11775. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11776. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11777. static readonly STEP_POINTERMOVE_SPRITE: number;
  11778. static readonly STEP_POINTERDOWN_SPRITE: number;
  11779. static readonly STEP_POINTERUP_SPRITE: number;
  11780. }
  11781. /**
  11782. * This represents a scene component.
  11783. *
  11784. * This is used to decouple the dependency the scene is having on the different workloads like
  11785. * layers, post processes...
  11786. */
  11787. export interface ISceneComponent {
  11788. /**
  11789. * The name of the component. Each component must have a unique name.
  11790. */
  11791. name: string;
  11792. /**
  11793. * The scene the component belongs to.
  11794. */
  11795. scene: Scene;
  11796. /**
  11797. * Register the component to one instance of a scene.
  11798. */
  11799. register(): void;
  11800. /**
  11801. * Rebuilds the elements related to this component in case of
  11802. * context lost for instance.
  11803. */
  11804. rebuild(): void;
  11805. /**
  11806. * Disposes the component and the associated ressources.
  11807. */
  11808. dispose(): void;
  11809. }
  11810. /**
  11811. * This represents a SERIALIZABLE scene component.
  11812. *
  11813. * This extends Scene Component to add Serialization methods on top.
  11814. */
  11815. export interface ISceneSerializableComponent extends ISceneComponent {
  11816. /**
  11817. * Adds all the element from the container to the scene
  11818. * @param container the container holding the elements
  11819. */
  11820. addFromContainer(container: AbstractScene): void;
  11821. /**
  11822. * Removes all the elements in the container from the scene
  11823. * @param container contains the elements to remove
  11824. * @param dispose if the removed element should be disposed (default: false)
  11825. */
  11826. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11827. /**
  11828. * Serializes the component data to the specified json object
  11829. * @param serializationObject The object to serialize to
  11830. */
  11831. serialize(serializationObject: any): void;
  11832. }
  11833. /**
  11834. * Strong typing of a Mesh related stage step action
  11835. */
  11836. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11837. /**
  11838. * Strong typing of a Evaluate Sub Mesh related stage step action
  11839. */
  11840. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11841. /**
  11842. * Strong typing of a Active Mesh related stage step action
  11843. */
  11844. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11845. /**
  11846. * Strong typing of a Camera related stage step action
  11847. */
  11848. export type CameraStageAction = (camera: Camera) => void;
  11849. /**
  11850. * Strong typing of a Camera Frame buffer related stage step action
  11851. */
  11852. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11853. /**
  11854. * Strong typing of a Render Target related stage step action
  11855. */
  11856. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11857. /**
  11858. * Strong typing of a RenderingGroup related stage step action
  11859. */
  11860. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11861. /**
  11862. * Strong typing of a Mesh Render related stage step action
  11863. */
  11864. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11865. /**
  11866. * Strong typing of a simple stage step action
  11867. */
  11868. export type SimpleStageAction = () => void;
  11869. /**
  11870. * Strong typing of a render target action.
  11871. */
  11872. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11873. /**
  11874. * Strong typing of a pointer move action.
  11875. */
  11876. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11877. /**
  11878. * Strong typing of a pointer up/down action.
  11879. */
  11880. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11881. /**
  11882. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11883. * @hidden
  11884. */
  11885. export class Stage<T extends Function> extends Array<{
  11886. index: number;
  11887. component: ISceneComponent;
  11888. action: T;
  11889. }> {
  11890. /**
  11891. * Hide ctor from the rest of the world.
  11892. * @param items The items to add.
  11893. */
  11894. private constructor();
  11895. /**
  11896. * Creates a new Stage.
  11897. * @returns A new instance of a Stage
  11898. */
  11899. static Create<T extends Function>(): Stage<T>;
  11900. /**
  11901. * Registers a step in an ordered way in the targeted stage.
  11902. * @param index Defines the position to register the step in
  11903. * @param component Defines the component attached to the step
  11904. * @param action Defines the action to launch during the step
  11905. */
  11906. registerStep(index: number, component: ISceneComponent, action: T): void;
  11907. /**
  11908. * Clears all the steps from the stage.
  11909. */
  11910. clear(): void;
  11911. }
  11912. }
  11913. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11914. import { Nullable } from "babylonjs/types";
  11915. import { Observable } from "babylonjs/Misc/observable";
  11916. import { Scene } from "babylonjs/scene";
  11917. import { Sprite } from "babylonjs/Sprites/sprite";
  11918. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11919. import { Ray } from "babylonjs/Culling/ray";
  11920. import { Camera } from "babylonjs/Cameras/camera";
  11921. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11922. import { ISceneComponent } from "babylonjs/sceneComponent";
  11923. module "babylonjs/scene" {
  11924. interface Scene {
  11925. /** @hidden */
  11926. _pointerOverSprite: Nullable<Sprite>;
  11927. /** @hidden */
  11928. _pickedDownSprite: Nullable<Sprite>;
  11929. /** @hidden */
  11930. _tempSpritePickingRay: Nullable<Ray>;
  11931. /**
  11932. * All of the sprite managers added to this scene
  11933. * @see http://doc.babylonjs.com/babylon101/sprites
  11934. */
  11935. spriteManagers: Array<ISpriteManager>;
  11936. /**
  11937. * An event triggered when sprites rendering is about to start
  11938. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11939. */
  11940. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11941. /**
  11942. * An event triggered when sprites rendering is done
  11943. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11944. */
  11945. onAfterSpritesRenderingObservable: Observable<Scene>;
  11946. /** @hidden */
  11947. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11948. /** Launch a ray to try to pick a sprite in the scene
  11949. * @param x position on screen
  11950. * @param y position on screen
  11951. * @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
  11952. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11953. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11954. * @returns a PickingInfo
  11955. */
  11956. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11957. /** Use the given ray to pick a sprite in the scene
  11958. * @param ray The ray (in world space) to use to pick meshes
  11959. * @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
  11960. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11961. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11962. * @returns a PickingInfo
  11963. */
  11964. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11965. /**
  11966. * Force the sprite under the pointer
  11967. * @param sprite defines the sprite to use
  11968. */
  11969. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11970. /**
  11971. * Gets the sprite under the pointer
  11972. * @returns a Sprite or null if no sprite is under the pointer
  11973. */
  11974. getPointerOverSprite(): Nullable<Sprite>;
  11975. }
  11976. }
  11977. /**
  11978. * Defines the sprite scene component responsible to manage sprites
  11979. * in a given scene.
  11980. */
  11981. export class SpriteSceneComponent implements ISceneComponent {
  11982. /**
  11983. * The component name helpfull to identify the component in the list of scene components.
  11984. */
  11985. readonly name: string;
  11986. /**
  11987. * The scene the component belongs to.
  11988. */
  11989. scene: Scene;
  11990. /** @hidden */
  11991. private _spritePredicate;
  11992. /**
  11993. * Creates a new instance of the component for the given scene
  11994. * @param scene Defines the scene to register the component in
  11995. */
  11996. constructor(scene: Scene);
  11997. /**
  11998. * Registers the component in a given scene
  11999. */
  12000. register(): void;
  12001. /**
  12002. * Rebuilds the elements related to this component in case of
  12003. * context lost for instance.
  12004. */
  12005. rebuild(): void;
  12006. /**
  12007. * Disposes the component and the associated ressources.
  12008. */
  12009. dispose(): void;
  12010. private _pickSpriteButKeepRay;
  12011. private _pointerMove;
  12012. private _pointerDown;
  12013. private _pointerUp;
  12014. }
  12015. }
  12016. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  12017. /** @hidden */
  12018. export var fogFragmentDeclaration: {
  12019. name: string;
  12020. shader: string;
  12021. };
  12022. }
  12023. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  12024. /** @hidden */
  12025. export var fogFragment: {
  12026. name: string;
  12027. shader: string;
  12028. };
  12029. }
  12030. declare module "babylonjs/Shaders/sprites.fragment" {
  12031. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  12032. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  12033. /** @hidden */
  12034. export var spritesPixelShader: {
  12035. name: string;
  12036. shader: string;
  12037. };
  12038. }
  12039. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  12040. /** @hidden */
  12041. export var fogVertexDeclaration: {
  12042. name: string;
  12043. shader: string;
  12044. };
  12045. }
  12046. declare module "babylonjs/Shaders/sprites.vertex" {
  12047. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  12048. /** @hidden */
  12049. export var spritesVertexShader: {
  12050. name: string;
  12051. shader: string;
  12052. };
  12053. }
  12054. declare module "babylonjs/Sprites/spriteManager" {
  12055. import { IDisposable, Scene } from "babylonjs/scene";
  12056. import { Nullable } from "babylonjs/types";
  12057. import { Observable } from "babylonjs/Misc/observable";
  12058. import { Sprite } from "babylonjs/Sprites/sprite";
  12059. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12060. import { Camera } from "babylonjs/Cameras/camera";
  12061. import { Texture } from "babylonjs/Materials/Textures/texture";
  12062. import "babylonjs/Shaders/sprites.fragment";
  12063. import "babylonjs/Shaders/sprites.vertex";
  12064. import { Ray } from "babylonjs/Culling/ray";
  12065. /**
  12066. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12067. */
  12068. export interface ISpriteManager extends IDisposable {
  12069. /**
  12070. * Restricts the camera to viewing objects with the same layerMask.
  12071. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12072. */
  12073. layerMask: number;
  12074. /**
  12075. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12076. */
  12077. isPickable: boolean;
  12078. /**
  12079. * Specifies the rendering group id for this mesh (0 by default)
  12080. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12081. */
  12082. renderingGroupId: number;
  12083. /**
  12084. * Defines the list of sprites managed by the manager.
  12085. */
  12086. sprites: Array<Sprite>;
  12087. /**
  12088. * Tests the intersection of a sprite with a specific ray.
  12089. * @param ray The ray we are sending to test the collision
  12090. * @param camera The camera space we are sending rays in
  12091. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12092. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12093. * @returns picking info or null.
  12094. */
  12095. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12096. /**
  12097. * Renders the list of sprites on screen.
  12098. */
  12099. render(): void;
  12100. }
  12101. /**
  12102. * Class used to manage multiple sprites on the same spritesheet
  12103. * @see http://doc.babylonjs.com/babylon101/sprites
  12104. */
  12105. export class SpriteManager implements ISpriteManager {
  12106. /** defines the manager's name */
  12107. name: string;
  12108. /** Gets the list of sprites */
  12109. sprites: Sprite[];
  12110. /** Gets or sets the rendering group id (0 by default) */
  12111. renderingGroupId: number;
  12112. /** Gets or sets camera layer mask */
  12113. layerMask: number;
  12114. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12115. fogEnabled: boolean;
  12116. /** Gets or sets a boolean indicating if the sprites are pickable */
  12117. isPickable: boolean;
  12118. /** Defines the default width of a cell in the spritesheet */
  12119. cellWidth: number;
  12120. /** Defines the default height of a cell in the spritesheet */
  12121. cellHeight: number;
  12122. /**
  12123. * An event triggered when the manager is disposed.
  12124. */
  12125. onDisposeObservable: Observable<SpriteManager>;
  12126. private _onDisposeObserver;
  12127. /**
  12128. * Callback called when the manager is disposed
  12129. */
  12130. onDispose: () => void;
  12131. private _capacity;
  12132. private _spriteTexture;
  12133. private _epsilon;
  12134. private _scene;
  12135. private _vertexData;
  12136. private _buffer;
  12137. private _vertexBuffers;
  12138. private _indexBuffer;
  12139. private _effectBase;
  12140. private _effectFog;
  12141. /**
  12142. * Gets or sets the spritesheet texture
  12143. */
  12144. texture: Texture;
  12145. /**
  12146. * Creates a new sprite manager
  12147. * @param name defines the manager's name
  12148. * @param imgUrl defines the sprite sheet url
  12149. * @param capacity defines the maximum allowed number of sprites
  12150. * @param cellSize defines the size of a sprite cell
  12151. * @param scene defines the hosting scene
  12152. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12153. * @param samplingMode defines the smapling mode to use with spritesheet
  12154. */
  12155. constructor(
  12156. /** defines the manager's name */
  12157. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12158. private _appendSpriteVertex;
  12159. /**
  12160. * Intersects the sprites with a ray
  12161. * @param ray defines the ray to intersect with
  12162. * @param camera defines the current active camera
  12163. * @param predicate defines a predicate used to select candidate sprites
  12164. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12165. * @returns null if no hit or a PickingInfo
  12166. */
  12167. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12168. /**
  12169. * Render all child sprites
  12170. */
  12171. render(): void;
  12172. /**
  12173. * Release associated resources
  12174. */
  12175. dispose(): void;
  12176. }
  12177. }
  12178. declare module "babylonjs/Sprites/sprite" {
  12179. import { Vector3, Color4 } from "babylonjs/Maths/math";
  12180. import { Nullable } from "babylonjs/types";
  12181. import { ActionManager } from "babylonjs/Actions/actionManager";
  12182. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12183. /**
  12184. * Class used to represent a sprite
  12185. * @see http://doc.babylonjs.com/babylon101/sprites
  12186. */
  12187. export class Sprite {
  12188. /** defines the name */
  12189. name: string;
  12190. /** Gets or sets the current world position */
  12191. position: Vector3;
  12192. /** Gets or sets the main color */
  12193. color: Color4;
  12194. /** Gets or sets the width */
  12195. width: number;
  12196. /** Gets or sets the height */
  12197. height: number;
  12198. /** Gets or sets rotation angle */
  12199. angle: number;
  12200. /** Gets or sets the cell index in the sprite sheet */
  12201. cellIndex: number;
  12202. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12203. invertU: number;
  12204. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12205. invertV: number;
  12206. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12207. disposeWhenFinishedAnimating: boolean;
  12208. /** Gets the list of attached animations */
  12209. animations: Animation[];
  12210. /** Gets or sets a boolean indicating if the sprite can be picked */
  12211. isPickable: boolean;
  12212. /**
  12213. * Gets or sets the associated action manager
  12214. */
  12215. actionManager: Nullable<ActionManager>;
  12216. private _animationStarted;
  12217. private _loopAnimation;
  12218. private _fromIndex;
  12219. private _toIndex;
  12220. private _delay;
  12221. private _direction;
  12222. private _manager;
  12223. private _time;
  12224. private _onAnimationEnd;
  12225. /**
  12226. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12227. */
  12228. isVisible: boolean;
  12229. /**
  12230. * Gets or sets the sprite size
  12231. */
  12232. size: number;
  12233. /**
  12234. * Creates a new Sprite
  12235. * @param name defines the name
  12236. * @param manager defines the manager
  12237. */
  12238. constructor(
  12239. /** defines the name */
  12240. name: string, manager: ISpriteManager);
  12241. /**
  12242. * Starts an animation
  12243. * @param from defines the initial key
  12244. * @param to defines the end key
  12245. * @param loop defines if the animation must loop
  12246. * @param delay defines the start delay (in ms)
  12247. * @param onAnimationEnd defines a callback to call when animation ends
  12248. */
  12249. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12250. /** Stops current animation (if any) */
  12251. stopAnimation(): void;
  12252. /** @hidden */
  12253. _animate(deltaTime: number): void;
  12254. /** Release associated resources */
  12255. dispose(): void;
  12256. }
  12257. }
  12258. declare module "babylonjs/Collisions/pickingInfo" {
  12259. import { Nullable } from "babylonjs/types";
  12260. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12262. import { Sprite } from "babylonjs/Sprites/sprite";
  12263. import { Ray } from "babylonjs/Culling/ray";
  12264. /**
  12265. * Information about the result of picking within a scene
  12266. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12267. */
  12268. export class PickingInfo {
  12269. /** @hidden */
  12270. _pickingUnavailable: boolean;
  12271. /**
  12272. * If the pick collided with an object
  12273. */
  12274. hit: boolean;
  12275. /**
  12276. * Distance away where the pick collided
  12277. */
  12278. distance: number;
  12279. /**
  12280. * The location of pick collision
  12281. */
  12282. pickedPoint: Nullable<Vector3>;
  12283. /**
  12284. * The mesh corresponding the the pick collision
  12285. */
  12286. pickedMesh: Nullable<AbstractMesh>;
  12287. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12288. bu: number;
  12289. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12290. bv: number;
  12291. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12292. faceId: number;
  12293. /** Id of the the submesh that was picked */
  12294. subMeshId: number;
  12295. /** If a sprite was picked, this will be the sprite the pick collided with */
  12296. pickedSprite: Nullable<Sprite>;
  12297. /**
  12298. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12299. */
  12300. originMesh: Nullable<AbstractMesh>;
  12301. /**
  12302. * The ray that was used to perform the picking.
  12303. */
  12304. ray: Nullable<Ray>;
  12305. /**
  12306. * Gets the normal correspodning to the face the pick collided with
  12307. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12308. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12309. * @returns The normal correspodning to the face the pick collided with
  12310. */
  12311. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12312. /**
  12313. * Gets the texture coordinates of where the pick occured
  12314. * @returns the vector containing the coordnates of the texture
  12315. */
  12316. getTextureCoordinates(): Nullable<Vector2>;
  12317. }
  12318. }
  12319. declare module "babylonjs/Events/pointerEvents" {
  12320. import { Nullable } from "babylonjs/types";
  12321. import { Vector2 } from "babylonjs/Maths/math";
  12322. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12323. import { Ray } from "babylonjs/Culling/ray";
  12324. /**
  12325. * Gather the list of pointer event types as constants.
  12326. */
  12327. export class PointerEventTypes {
  12328. /**
  12329. * 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.
  12330. */
  12331. static readonly POINTERDOWN: number;
  12332. /**
  12333. * The pointerup event is fired when a pointer is no longer active.
  12334. */
  12335. static readonly POINTERUP: number;
  12336. /**
  12337. * The pointermove event is fired when a pointer changes coordinates.
  12338. */
  12339. static readonly POINTERMOVE: number;
  12340. /**
  12341. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12342. */
  12343. static readonly POINTERWHEEL: number;
  12344. /**
  12345. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12346. */
  12347. static readonly POINTERPICK: number;
  12348. /**
  12349. * The pointertap event is fired when a the object has been touched and released without drag.
  12350. */
  12351. static readonly POINTERTAP: number;
  12352. /**
  12353. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12354. */
  12355. static readonly POINTERDOUBLETAP: number;
  12356. }
  12357. /**
  12358. * Base class of pointer info types.
  12359. */
  12360. export class PointerInfoBase {
  12361. /**
  12362. * Defines the type of event (PointerEventTypes)
  12363. */
  12364. type: number;
  12365. /**
  12366. * Defines the related dom event
  12367. */
  12368. event: PointerEvent | MouseWheelEvent;
  12369. /**
  12370. * Instantiates the base class of pointers info.
  12371. * @param type Defines the type of event (PointerEventTypes)
  12372. * @param event Defines the related dom event
  12373. */
  12374. constructor(
  12375. /**
  12376. * Defines the type of event (PointerEventTypes)
  12377. */
  12378. type: number,
  12379. /**
  12380. * Defines the related dom event
  12381. */
  12382. event: PointerEvent | MouseWheelEvent);
  12383. }
  12384. /**
  12385. * This class is used to store pointer related info for the onPrePointerObservable event.
  12386. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12387. */
  12388. export class PointerInfoPre extends PointerInfoBase {
  12389. /**
  12390. * Ray from a pointer if availible (eg. 6dof controller)
  12391. */
  12392. ray: Nullable<Ray>;
  12393. /**
  12394. * Defines the local position of the pointer on the canvas.
  12395. */
  12396. localPosition: Vector2;
  12397. /**
  12398. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12399. */
  12400. skipOnPointerObservable: boolean;
  12401. /**
  12402. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12403. * @param type Defines the type of event (PointerEventTypes)
  12404. * @param event Defines the related dom event
  12405. * @param localX Defines the local x coordinates of the pointer when the event occured
  12406. * @param localY Defines the local y coordinates of the pointer when the event occured
  12407. */
  12408. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12409. }
  12410. /**
  12411. * This type contains all the data related to a pointer event in Babylon.js.
  12412. * 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.
  12413. */
  12414. export class PointerInfo extends PointerInfoBase {
  12415. /**
  12416. * Defines the picking info associated to the info (if any)\
  12417. */
  12418. pickInfo: Nullable<PickingInfo>;
  12419. /**
  12420. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12421. * @param type Defines the type of event (PointerEventTypes)
  12422. * @param event Defines the related dom event
  12423. * @param pickInfo Defines the picking info associated to the info (if any)\
  12424. */
  12425. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12426. /**
  12427. * Defines the picking info associated to the info (if any)\
  12428. */
  12429. pickInfo: Nullable<PickingInfo>);
  12430. }
  12431. /**
  12432. * Data relating to a touch event on the screen.
  12433. */
  12434. export interface PointerTouch {
  12435. /**
  12436. * X coordinate of touch.
  12437. */
  12438. x: number;
  12439. /**
  12440. * Y coordinate of touch.
  12441. */
  12442. y: number;
  12443. /**
  12444. * Id of touch. Unique for each finger.
  12445. */
  12446. pointerId: number;
  12447. /**
  12448. * Event type passed from DOM.
  12449. */
  12450. type: any;
  12451. }
  12452. }
  12453. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12454. import { Observable } from "babylonjs/Misc/observable";
  12455. import { Nullable } from "babylonjs/types";
  12456. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12457. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12458. /**
  12459. * Manage the mouse inputs to control the movement of a free camera.
  12460. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12461. */
  12462. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12463. /**
  12464. * Define if touch is enabled in the mouse input
  12465. */
  12466. touchEnabled: boolean;
  12467. /**
  12468. * Defines the camera the input is attached to.
  12469. */
  12470. camera: FreeCamera;
  12471. /**
  12472. * Defines the buttons associated with the input to handle camera move.
  12473. */
  12474. buttons: number[];
  12475. /**
  12476. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12477. */
  12478. angularSensibility: number;
  12479. private _pointerInput;
  12480. private _onMouseMove;
  12481. private _observer;
  12482. private previousPosition;
  12483. /**
  12484. * Observable for when a pointer move event occurs containing the move offset
  12485. */
  12486. onPointerMovedObservable: Observable<{
  12487. offsetX: number;
  12488. offsetY: number;
  12489. }>;
  12490. /**
  12491. * @hidden
  12492. * If the camera should be rotated automatically based on pointer movement
  12493. */
  12494. _allowCameraRotation: boolean;
  12495. /**
  12496. * Manage the mouse inputs to control the movement of a free camera.
  12497. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12498. * @param touchEnabled Defines if touch is enabled or not
  12499. */
  12500. constructor(
  12501. /**
  12502. * Define if touch is enabled in the mouse input
  12503. */
  12504. touchEnabled?: boolean);
  12505. /**
  12506. * Attach the input controls to a specific dom element to get the input from.
  12507. * @param element Defines the element the controls should be listened from
  12508. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12509. */
  12510. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12511. /**
  12512. * Called on JS contextmenu event.
  12513. * Override this method to provide functionality.
  12514. */
  12515. protected onContextMenu(evt: PointerEvent): void;
  12516. /**
  12517. * Detach the current controls from the specified dom element.
  12518. * @param element Defines the element to stop listening the inputs from
  12519. */
  12520. detachControl(element: Nullable<HTMLElement>): void;
  12521. /**
  12522. * Gets the class name of the current intput.
  12523. * @returns the class name
  12524. */
  12525. getClassName(): string;
  12526. /**
  12527. * Get the friendly name associated with the input class.
  12528. * @returns the input friendly name
  12529. */
  12530. getSimpleName(): string;
  12531. }
  12532. }
  12533. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12534. import { Nullable } from "babylonjs/types";
  12535. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12536. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12537. /**
  12538. * Manage the touch inputs to control the movement of a free camera.
  12539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12540. */
  12541. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12542. /**
  12543. * Defines the camera the input is attached to.
  12544. */
  12545. camera: FreeCamera;
  12546. /**
  12547. * Defines the touch sensibility for rotation.
  12548. * The higher the faster.
  12549. */
  12550. touchAngularSensibility: number;
  12551. /**
  12552. * Defines the touch sensibility for move.
  12553. * The higher the faster.
  12554. */
  12555. touchMoveSensibility: number;
  12556. private _offsetX;
  12557. private _offsetY;
  12558. private _pointerPressed;
  12559. private _pointerInput;
  12560. private _observer;
  12561. private _onLostFocus;
  12562. /**
  12563. * Attach the input controls to a specific dom element to get the input from.
  12564. * @param element Defines the element the controls should be listened from
  12565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12566. */
  12567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12568. /**
  12569. * Detach the current controls from the specified dom element.
  12570. * @param element Defines the element to stop listening the inputs from
  12571. */
  12572. detachControl(element: Nullable<HTMLElement>): void;
  12573. /**
  12574. * Update the current camera state depending on the inputs that have been used this frame.
  12575. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12576. */
  12577. checkInputs(): void;
  12578. /**
  12579. * Gets the class name of the current intput.
  12580. * @returns the class name
  12581. */
  12582. getClassName(): string;
  12583. /**
  12584. * Get the friendly name associated with the input class.
  12585. * @returns the input friendly name
  12586. */
  12587. getSimpleName(): string;
  12588. }
  12589. }
  12590. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12591. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12592. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12593. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12594. import { Nullable } from "babylonjs/types";
  12595. /**
  12596. * Default Inputs manager for the FreeCamera.
  12597. * It groups all the default supported inputs for ease of use.
  12598. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12599. */
  12600. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12601. /**
  12602. * @hidden
  12603. */
  12604. _mouseInput: Nullable<FreeCameraMouseInput>;
  12605. /**
  12606. * Instantiates a new FreeCameraInputsManager.
  12607. * @param camera Defines the camera the inputs belong to
  12608. */
  12609. constructor(camera: FreeCamera);
  12610. /**
  12611. * Add keyboard input support to the input manager.
  12612. * @returns the current input manager
  12613. */
  12614. addKeyboard(): FreeCameraInputsManager;
  12615. /**
  12616. * Add mouse input support to the input manager.
  12617. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12618. * @returns the current input manager
  12619. */
  12620. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12621. /**
  12622. * Removes the mouse input support from the manager
  12623. * @returns the current input manager
  12624. */
  12625. removeMouse(): FreeCameraInputsManager;
  12626. /**
  12627. * Add touch input support to the input manager.
  12628. * @returns the current input manager
  12629. */
  12630. addTouch(): FreeCameraInputsManager;
  12631. /**
  12632. * Remove all attached input methods from a camera
  12633. */
  12634. clear(): void;
  12635. }
  12636. }
  12637. declare module "babylonjs/Cameras/freeCamera" {
  12638. import { Vector3 } from "babylonjs/Maths/math";
  12639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12640. import { Scene } from "babylonjs/scene";
  12641. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12642. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12643. /**
  12644. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12645. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12646. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12647. */
  12648. export class FreeCamera extends TargetCamera {
  12649. /**
  12650. * Define the collision ellipsoid of the camera.
  12651. * This is helpful to simulate a camera body like the player body around the camera
  12652. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12653. */
  12654. ellipsoid: Vector3;
  12655. /**
  12656. * Define an offset for the position of the ellipsoid around the camera.
  12657. * This can be helpful to determine the center of the body near the gravity center of the body
  12658. * instead of its head.
  12659. */
  12660. ellipsoidOffset: Vector3;
  12661. /**
  12662. * Enable or disable collisions of the camera with the rest of the scene objects.
  12663. */
  12664. checkCollisions: boolean;
  12665. /**
  12666. * Enable or disable gravity on the camera.
  12667. */
  12668. applyGravity: boolean;
  12669. /**
  12670. * Define the input manager associated to the camera.
  12671. */
  12672. inputs: FreeCameraInputsManager;
  12673. /**
  12674. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12675. * Higher values reduce sensitivity.
  12676. */
  12677. /**
  12678. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12679. * Higher values reduce sensitivity.
  12680. */
  12681. angularSensibility: number;
  12682. /**
  12683. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12684. */
  12685. keysUp: number[];
  12686. /**
  12687. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12688. */
  12689. keysDown: number[];
  12690. /**
  12691. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12692. */
  12693. keysLeft: number[];
  12694. /**
  12695. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12696. */
  12697. keysRight: number[];
  12698. /**
  12699. * Event raised when the camera collide with a mesh in the scene.
  12700. */
  12701. onCollide: (collidedMesh: AbstractMesh) => void;
  12702. private _collider;
  12703. private _needMoveForGravity;
  12704. private _oldPosition;
  12705. private _diffPosition;
  12706. private _newPosition;
  12707. /** @hidden */
  12708. _localDirection: Vector3;
  12709. /** @hidden */
  12710. _transformedDirection: Vector3;
  12711. /**
  12712. * Instantiates a Free Camera.
  12713. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12714. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12715. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12716. * @param name Define the name of the camera in the scene
  12717. * @param position Define the start position of the camera in the scene
  12718. * @param scene Define the scene the camera belongs to
  12719. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12720. */
  12721. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12722. /**
  12723. * Attached controls to the current camera.
  12724. * @param element Defines the element the controls should be listened from
  12725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12726. */
  12727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12728. /**
  12729. * Detach the current controls from the camera.
  12730. * The camera will stop reacting to inputs.
  12731. * @param element Defines the element to stop listening the inputs from
  12732. */
  12733. detachControl(element: HTMLElement): void;
  12734. private _collisionMask;
  12735. /**
  12736. * Define a collision mask to limit the list of object the camera can collide with
  12737. */
  12738. collisionMask: number;
  12739. /** @hidden */
  12740. _collideWithWorld(displacement: Vector3): void;
  12741. private _onCollisionPositionChange;
  12742. /** @hidden */
  12743. _checkInputs(): void;
  12744. /** @hidden */
  12745. _decideIfNeedsToMove(): boolean;
  12746. /** @hidden */
  12747. _updatePosition(): void;
  12748. /**
  12749. * Destroy the camera and release the current resources hold by it.
  12750. */
  12751. dispose(): void;
  12752. /**
  12753. * Gets the current object class name.
  12754. * @return the class name
  12755. */
  12756. getClassName(): string;
  12757. }
  12758. }
  12759. declare module "babylonjs/Gamepads/gamepad" {
  12760. import { Observable } from "babylonjs/Misc/observable";
  12761. /**
  12762. * Represents a gamepad control stick position
  12763. */
  12764. export class StickValues {
  12765. /**
  12766. * The x component of the control stick
  12767. */
  12768. x: number;
  12769. /**
  12770. * The y component of the control stick
  12771. */
  12772. y: number;
  12773. /**
  12774. * Initializes the gamepad x and y control stick values
  12775. * @param x The x component of the gamepad control stick value
  12776. * @param y The y component of the gamepad control stick value
  12777. */
  12778. constructor(
  12779. /**
  12780. * The x component of the control stick
  12781. */
  12782. x: number,
  12783. /**
  12784. * The y component of the control stick
  12785. */
  12786. y: number);
  12787. }
  12788. /**
  12789. * An interface which manages callbacks for gamepad button changes
  12790. */
  12791. export interface GamepadButtonChanges {
  12792. /**
  12793. * Called when a gamepad has been changed
  12794. */
  12795. changed: boolean;
  12796. /**
  12797. * Called when a gamepad press event has been triggered
  12798. */
  12799. pressChanged: boolean;
  12800. /**
  12801. * Called when a touch event has been triggered
  12802. */
  12803. touchChanged: boolean;
  12804. /**
  12805. * Called when a value has changed
  12806. */
  12807. valueChanged: boolean;
  12808. }
  12809. /**
  12810. * Represents a gamepad
  12811. */
  12812. export class Gamepad {
  12813. /**
  12814. * The id of the gamepad
  12815. */
  12816. id: string;
  12817. /**
  12818. * The index of the gamepad
  12819. */
  12820. index: number;
  12821. /**
  12822. * The browser gamepad
  12823. */
  12824. browserGamepad: any;
  12825. /**
  12826. * Specifies what type of gamepad this represents
  12827. */
  12828. type: number;
  12829. private _leftStick;
  12830. private _rightStick;
  12831. /** @hidden */
  12832. _isConnected: boolean;
  12833. private _leftStickAxisX;
  12834. private _leftStickAxisY;
  12835. private _rightStickAxisX;
  12836. private _rightStickAxisY;
  12837. /**
  12838. * Triggered when the left control stick has been changed
  12839. */
  12840. private _onleftstickchanged;
  12841. /**
  12842. * Triggered when the right control stick has been changed
  12843. */
  12844. private _onrightstickchanged;
  12845. /**
  12846. * Represents a gamepad controller
  12847. */
  12848. static GAMEPAD: number;
  12849. /**
  12850. * Represents a generic controller
  12851. */
  12852. static GENERIC: number;
  12853. /**
  12854. * Represents an XBox controller
  12855. */
  12856. static XBOX: number;
  12857. /**
  12858. * Represents a pose-enabled controller
  12859. */
  12860. static POSE_ENABLED: number;
  12861. /**
  12862. * Specifies whether the left control stick should be Y-inverted
  12863. */
  12864. protected _invertLeftStickY: boolean;
  12865. /**
  12866. * Specifies if the gamepad has been connected
  12867. */
  12868. readonly isConnected: boolean;
  12869. /**
  12870. * Initializes the gamepad
  12871. * @param id The id of the gamepad
  12872. * @param index The index of the gamepad
  12873. * @param browserGamepad The browser gamepad
  12874. * @param leftStickX The x component of the left joystick
  12875. * @param leftStickY The y component of the left joystick
  12876. * @param rightStickX The x component of the right joystick
  12877. * @param rightStickY The y component of the right joystick
  12878. */
  12879. constructor(
  12880. /**
  12881. * The id of the gamepad
  12882. */
  12883. id: string,
  12884. /**
  12885. * The index of the gamepad
  12886. */
  12887. index: number,
  12888. /**
  12889. * The browser gamepad
  12890. */
  12891. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12892. /**
  12893. * Callback triggered when the left joystick has changed
  12894. * @param callback
  12895. */
  12896. onleftstickchanged(callback: (values: StickValues) => void): void;
  12897. /**
  12898. * Callback triggered when the right joystick has changed
  12899. * @param callback
  12900. */
  12901. onrightstickchanged(callback: (values: StickValues) => void): void;
  12902. /**
  12903. * Gets the left joystick
  12904. */
  12905. /**
  12906. * Sets the left joystick values
  12907. */
  12908. leftStick: StickValues;
  12909. /**
  12910. * Gets the right joystick
  12911. */
  12912. /**
  12913. * Sets the right joystick value
  12914. */
  12915. rightStick: StickValues;
  12916. /**
  12917. * Updates the gamepad joystick positions
  12918. */
  12919. update(): void;
  12920. /**
  12921. * Disposes the gamepad
  12922. */
  12923. dispose(): void;
  12924. }
  12925. /**
  12926. * Represents a generic gamepad
  12927. */
  12928. export class GenericPad extends Gamepad {
  12929. private _buttons;
  12930. private _onbuttondown;
  12931. private _onbuttonup;
  12932. /**
  12933. * Observable triggered when a button has been pressed
  12934. */
  12935. onButtonDownObservable: Observable<number>;
  12936. /**
  12937. * Observable triggered when a button has been released
  12938. */
  12939. onButtonUpObservable: Observable<number>;
  12940. /**
  12941. * Callback triggered when a button has been pressed
  12942. * @param callback Called when a button has been pressed
  12943. */
  12944. onbuttondown(callback: (buttonPressed: number) => void): void;
  12945. /**
  12946. * Callback triggered when a button has been released
  12947. * @param callback Called when a button has been released
  12948. */
  12949. onbuttonup(callback: (buttonReleased: number) => void): void;
  12950. /**
  12951. * Initializes the generic gamepad
  12952. * @param id The id of the generic gamepad
  12953. * @param index The index of the generic gamepad
  12954. * @param browserGamepad The browser gamepad
  12955. */
  12956. constructor(id: string, index: number, browserGamepad: any);
  12957. private _setButtonValue;
  12958. /**
  12959. * Updates the generic gamepad
  12960. */
  12961. update(): void;
  12962. /**
  12963. * Disposes the generic gamepad
  12964. */
  12965. dispose(): void;
  12966. }
  12967. }
  12968. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12969. import { Observable } from "babylonjs/Misc/observable";
  12970. import { Nullable } from "babylonjs/types";
  12971. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12972. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12974. import { Ray } from "babylonjs/Culling/ray";
  12975. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12976. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12977. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12978. /**
  12979. * Defines the types of pose enabled controllers that are supported
  12980. */
  12981. export enum PoseEnabledControllerType {
  12982. /**
  12983. * HTC Vive
  12984. */
  12985. VIVE = 0,
  12986. /**
  12987. * Oculus Rift
  12988. */
  12989. OCULUS = 1,
  12990. /**
  12991. * Windows mixed reality
  12992. */
  12993. WINDOWS = 2,
  12994. /**
  12995. * Samsung gear VR
  12996. */
  12997. GEAR_VR = 3,
  12998. /**
  12999. * Google Daydream
  13000. */
  13001. DAYDREAM = 4,
  13002. /**
  13003. * Generic
  13004. */
  13005. GENERIC = 5
  13006. }
  13007. /**
  13008. * Defines the MutableGamepadButton interface for the state of a gamepad button
  13009. */
  13010. export interface MutableGamepadButton {
  13011. /**
  13012. * Value of the button/trigger
  13013. */
  13014. value: number;
  13015. /**
  13016. * If the button/trigger is currently touched
  13017. */
  13018. touched: boolean;
  13019. /**
  13020. * If the button/trigger is currently pressed
  13021. */
  13022. pressed: boolean;
  13023. }
  13024. /**
  13025. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13026. * @hidden
  13027. */
  13028. export interface ExtendedGamepadButton extends GamepadButton {
  13029. /**
  13030. * If the button/trigger is currently pressed
  13031. */
  13032. readonly pressed: boolean;
  13033. /**
  13034. * If the button/trigger is currently touched
  13035. */
  13036. readonly touched: boolean;
  13037. /**
  13038. * Value of the button/trigger
  13039. */
  13040. readonly value: number;
  13041. }
  13042. /** @hidden */
  13043. export interface _GamePadFactory {
  13044. /**
  13045. * Returns wether or not the current gamepad can be created for this type of controller.
  13046. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13047. * @returns true if it can be created, otherwise false
  13048. */
  13049. canCreate(gamepadInfo: any): boolean;
  13050. /**
  13051. * Creates a new instance of the Gamepad.
  13052. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13053. * @returns the new gamepad instance
  13054. */
  13055. create(gamepadInfo: any): Gamepad;
  13056. }
  13057. /**
  13058. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13059. */
  13060. export class PoseEnabledControllerHelper {
  13061. /** @hidden */
  13062. static _ControllerFactories: _GamePadFactory[];
  13063. /** @hidden */
  13064. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13065. /**
  13066. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13067. * @param vrGamepad the gamepad to initialized
  13068. * @returns a vr controller of the type the gamepad identified as
  13069. */
  13070. static InitiateController(vrGamepad: any): Gamepad;
  13071. }
  13072. /**
  13073. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13074. */
  13075. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13076. private _deviceRoomPosition;
  13077. private _deviceRoomRotationQuaternion;
  13078. /**
  13079. * The device position in babylon space
  13080. */
  13081. devicePosition: Vector3;
  13082. /**
  13083. * The device rotation in babylon space
  13084. */
  13085. deviceRotationQuaternion: Quaternion;
  13086. /**
  13087. * The scale factor of the device in babylon space
  13088. */
  13089. deviceScaleFactor: number;
  13090. /**
  13091. * (Likely devicePosition should be used instead) The device position in its room space
  13092. */
  13093. position: Vector3;
  13094. /**
  13095. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13096. */
  13097. rotationQuaternion: Quaternion;
  13098. /**
  13099. * The type of controller (Eg. Windows mixed reality)
  13100. */
  13101. controllerType: PoseEnabledControllerType;
  13102. protected _calculatedPosition: Vector3;
  13103. private _calculatedRotation;
  13104. /**
  13105. * The raw pose from the device
  13106. */
  13107. rawPose: DevicePose;
  13108. private _trackPosition;
  13109. private _maxRotationDistFromHeadset;
  13110. private _draggedRoomRotation;
  13111. /**
  13112. * @hidden
  13113. */
  13114. _disableTrackPosition(fixedPosition: Vector3): void;
  13115. /**
  13116. * Internal, the mesh attached to the controller
  13117. * @hidden
  13118. */
  13119. _mesh: Nullable<AbstractMesh>;
  13120. private _poseControlledCamera;
  13121. private _leftHandSystemQuaternion;
  13122. /**
  13123. * Internal, matrix used to convert room space to babylon space
  13124. * @hidden
  13125. */
  13126. _deviceToWorld: Matrix;
  13127. /**
  13128. * Node to be used when casting a ray from the controller
  13129. * @hidden
  13130. */
  13131. _pointingPoseNode: Nullable<TransformNode>;
  13132. /**
  13133. * Name of the child mesh that can be used to cast a ray from the controller
  13134. */
  13135. static readonly POINTING_POSE: string;
  13136. /**
  13137. * Creates a new PoseEnabledController from a gamepad
  13138. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13139. */
  13140. constructor(browserGamepad: any);
  13141. private _workingMatrix;
  13142. /**
  13143. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13144. */
  13145. update(): void;
  13146. /**
  13147. * Updates only the pose device and mesh without doing any button event checking
  13148. */
  13149. protected _updatePoseAndMesh(): void;
  13150. /**
  13151. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13152. * @param poseData raw pose fromthe device
  13153. */
  13154. updateFromDevice(poseData: DevicePose): void;
  13155. /**
  13156. * @hidden
  13157. */
  13158. _meshAttachedObservable: Observable<AbstractMesh>;
  13159. /**
  13160. * Attaches a mesh to the controller
  13161. * @param mesh the mesh to be attached
  13162. */
  13163. attachToMesh(mesh: AbstractMesh): void;
  13164. /**
  13165. * Attaches the controllers mesh to a camera
  13166. * @param camera the camera the mesh should be attached to
  13167. */
  13168. attachToPoseControlledCamera(camera: TargetCamera): void;
  13169. /**
  13170. * Disposes of the controller
  13171. */
  13172. dispose(): void;
  13173. /**
  13174. * The mesh that is attached to the controller
  13175. */
  13176. readonly mesh: Nullable<AbstractMesh>;
  13177. /**
  13178. * Gets the ray of the controller in the direction the controller is pointing
  13179. * @param length the length the resulting ray should be
  13180. * @returns a ray in the direction the controller is pointing
  13181. */
  13182. getForwardRay(length?: number): Ray;
  13183. }
  13184. }
  13185. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13186. import { Observable } from "babylonjs/Misc/observable";
  13187. import { Scene } from "babylonjs/scene";
  13188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13189. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13190. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13191. /**
  13192. * Defines the WebVRController object that represents controllers tracked in 3D space
  13193. */
  13194. export abstract class WebVRController extends PoseEnabledController {
  13195. /**
  13196. * Internal, the default controller model for the controller
  13197. */
  13198. protected _defaultModel: AbstractMesh;
  13199. /**
  13200. * Fired when the trigger state has changed
  13201. */
  13202. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13203. /**
  13204. * Fired when the main button state has changed
  13205. */
  13206. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13207. /**
  13208. * Fired when the secondary button state has changed
  13209. */
  13210. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13211. /**
  13212. * Fired when the pad state has changed
  13213. */
  13214. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13215. /**
  13216. * Fired when controllers stick values have changed
  13217. */
  13218. onPadValuesChangedObservable: Observable<StickValues>;
  13219. /**
  13220. * Array of button availible on the controller
  13221. */
  13222. protected _buttons: Array<MutableGamepadButton>;
  13223. private _onButtonStateChange;
  13224. /**
  13225. * Fired when a controller button's state has changed
  13226. * @param callback the callback containing the button that was modified
  13227. */
  13228. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13229. /**
  13230. * X and Y axis corrisponding to the controllers joystick
  13231. */
  13232. pad: StickValues;
  13233. /**
  13234. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13235. */
  13236. hand: string;
  13237. /**
  13238. * The default controller model for the controller
  13239. */
  13240. readonly defaultModel: AbstractMesh;
  13241. /**
  13242. * Creates a new WebVRController from a gamepad
  13243. * @param vrGamepad the gamepad that the WebVRController should be created from
  13244. */
  13245. constructor(vrGamepad: any);
  13246. /**
  13247. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13248. */
  13249. update(): void;
  13250. /**
  13251. * Function to be called when a button is modified
  13252. */
  13253. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13254. /**
  13255. * Loads a mesh and attaches it to the controller
  13256. * @param scene the scene the mesh should be added to
  13257. * @param meshLoaded callback for when the mesh has been loaded
  13258. */
  13259. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13260. private _setButtonValue;
  13261. private _changes;
  13262. private _checkChanges;
  13263. /**
  13264. * Disposes of th webVRCOntroller
  13265. */
  13266. dispose(): void;
  13267. }
  13268. }
  13269. declare module "babylonjs/Lights/hemisphericLight" {
  13270. import { Nullable } from "babylonjs/types";
  13271. import { Scene } from "babylonjs/scene";
  13272. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13273. import { Effect } from "babylonjs/Materials/effect";
  13274. import { Light } from "babylonjs/Lights/light";
  13275. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13276. /**
  13277. * The HemisphericLight simulates the ambient environment light,
  13278. * so the passed direction is the light reflection direction, not the incoming direction.
  13279. */
  13280. export class HemisphericLight extends Light {
  13281. /**
  13282. * The groundColor is the light in the opposite direction to the one specified during creation.
  13283. * 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.
  13284. */
  13285. groundColor: Color3;
  13286. /**
  13287. * The light reflection direction, not the incoming direction.
  13288. */
  13289. direction: Vector3;
  13290. /**
  13291. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13292. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13293. * The HemisphericLight can't cast shadows.
  13294. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13295. * @param name The friendly name of the light
  13296. * @param direction The direction of the light reflection
  13297. * @param scene The scene the light belongs to
  13298. */
  13299. constructor(name: string, direction: Vector3, scene: Scene);
  13300. protected _buildUniformLayout(): void;
  13301. /**
  13302. * Returns the string "HemisphericLight".
  13303. * @return The class name
  13304. */
  13305. getClassName(): string;
  13306. /**
  13307. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13308. * Returns the updated direction.
  13309. * @param target The target the direction should point to
  13310. * @return The computed direction
  13311. */
  13312. setDirectionToTarget(target: Vector3): Vector3;
  13313. /**
  13314. * Returns the shadow generator associated to the light.
  13315. * @returns Always null for hemispheric lights because it does not support shadows.
  13316. */
  13317. getShadowGenerator(): Nullable<IShadowGenerator>;
  13318. /**
  13319. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13320. * @param effect The effect to update
  13321. * @param lightIndex The index of the light in the effect to update
  13322. * @returns The hemispheric light
  13323. */
  13324. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13325. /**
  13326. * Computes the world matrix of the node
  13327. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13328. * @param useWasUpdatedFlag defines a reserved property
  13329. * @returns the world matrix
  13330. */
  13331. computeWorldMatrix(): Matrix;
  13332. /**
  13333. * Returns the integer 3.
  13334. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13335. */
  13336. getTypeID(): number;
  13337. /**
  13338. * Prepares the list of defines specific to the light type.
  13339. * @param defines the list of defines
  13340. * @param lightIndex defines the index of the light for the effect
  13341. */
  13342. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13343. }
  13344. }
  13345. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13346. /** @hidden */
  13347. export var vrMultiviewToSingleviewPixelShader: {
  13348. name: string;
  13349. shader: string;
  13350. };
  13351. }
  13352. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13353. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13354. import { Scene } from "babylonjs/scene";
  13355. /**
  13356. * Renders to multiple views with a single draw call
  13357. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13358. */
  13359. export class MultiviewRenderTarget extends RenderTargetTexture {
  13360. /**
  13361. * Creates a multiview render target
  13362. * @param scene scene used with the render target
  13363. * @param size the size of the render target (used for each view)
  13364. */
  13365. constructor(scene: Scene, size?: number | {
  13366. width: number;
  13367. height: number;
  13368. } | {
  13369. ratio: number;
  13370. });
  13371. /**
  13372. * @hidden
  13373. * @param faceIndex the face index, if its a cube texture
  13374. */
  13375. _bindFrameBuffer(faceIndex?: number): void;
  13376. /**
  13377. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13378. * @returns the view count
  13379. */
  13380. getViewCount(): number;
  13381. }
  13382. }
  13383. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13384. import { Camera } from "babylonjs/Cameras/camera";
  13385. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13386. import { Nullable } from "babylonjs/types";
  13387. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13388. import { Matrix } from "babylonjs/Maths/math";
  13389. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13390. module "babylonjs/Engines/engine" {
  13391. interface Engine {
  13392. /**
  13393. * Creates a new multiview render target
  13394. * @param width defines the width of the texture
  13395. * @param height defines the height of the texture
  13396. * @returns the created multiview texture
  13397. */
  13398. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13399. /**
  13400. * Binds a multiview framebuffer to be drawn to
  13401. * @param multiviewTexture texture to bind
  13402. */
  13403. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13404. }
  13405. }
  13406. module "babylonjs/Cameras/camera" {
  13407. interface Camera {
  13408. /**
  13409. * @hidden
  13410. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  13411. */
  13412. _useMultiviewToSingleView: boolean;
  13413. /**
  13414. * @hidden
  13415. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  13416. */
  13417. _multiviewTexture: Nullable<RenderTargetTexture>;
  13418. /**
  13419. * @hidden
  13420. * ensures the multiview texture of the camera exists and has the specified width/height
  13421. * @param width height to set on the multiview texture
  13422. * @param height width to set on the multiview texture
  13423. */
  13424. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13425. }
  13426. }
  13427. module "babylonjs/scene" {
  13428. interface Scene {
  13429. /** @hidden */
  13430. _transformMatrixR: Matrix;
  13431. /** @hidden */
  13432. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13433. /** @hidden */
  13434. _createMultiviewUbo(): void;
  13435. /** @hidden */
  13436. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13437. /** @hidden */
  13438. _renderMultiviewToSingleView(camera: Camera): void;
  13439. }
  13440. }
  13441. }
  13442. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13443. import { Camera } from "babylonjs/Cameras/camera";
  13444. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13445. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13446. import "babylonjs/Engines/Extensions/engine.multiview";
  13447. /**
  13448. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13449. * This will not be used for webXR as it supports displaying texture arrays directly
  13450. */
  13451. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13452. /**
  13453. * Initializes a VRMultiviewToSingleview
  13454. * @param name name of the post process
  13455. * @param camera camera to be applied to
  13456. * @param scaleFactor scaling factor to the size of the output texture
  13457. */
  13458. constructor(name: string, camera: Camera, scaleFactor: number);
  13459. }
  13460. }
  13461. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13462. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  13463. import { Nullable } from "babylonjs/types";
  13464. import { Size } from "babylonjs/Maths/math";
  13465. import { Observable } from "babylonjs/Misc/observable";
  13466. module "babylonjs/Engines/engine" {
  13467. /**
  13468. * Defines the interface used by display changed events
  13469. */
  13470. interface IDisplayChangedEventArgs {
  13471. /** Gets the vrDisplay object (if any) */
  13472. vrDisplay: Nullable<any>;
  13473. /** Gets a boolean indicating if webVR is supported */
  13474. vrSupported: boolean;
  13475. }
  13476. interface Engine {
  13477. /** @hidden */
  13478. _vrDisplay: any;
  13479. /** @hidden */
  13480. _vrSupported: boolean;
  13481. /** @hidden */
  13482. _oldSize: Size;
  13483. /** @hidden */
  13484. _oldHardwareScaleFactor: number;
  13485. /** @hidden */
  13486. _vrExclusivePointerMode: boolean;
  13487. /** @hidden */
  13488. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13489. /** @hidden */
  13490. _onVRDisplayPointerRestricted: () => void;
  13491. /** @hidden */
  13492. _onVRDisplayPointerUnrestricted: () => void;
  13493. /** @hidden */
  13494. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13495. /** @hidden */
  13496. _onVrDisplayDisconnect: Nullable<() => void>;
  13497. /** @hidden */
  13498. _onVrDisplayPresentChange: Nullable<() => void>;
  13499. /**
  13500. * Observable signaled when VR display mode changes
  13501. */
  13502. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13503. /**
  13504. * Observable signaled when VR request present is complete
  13505. */
  13506. onVRRequestPresentComplete: Observable<boolean>;
  13507. /**
  13508. * Observable signaled when VR request present starts
  13509. */
  13510. onVRRequestPresentStart: Observable<Engine>;
  13511. /**
  13512. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13513. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13514. */
  13515. isInVRExclusivePointerMode: boolean;
  13516. /**
  13517. * Gets a boolean indicating if a webVR device was detected
  13518. * @returns true if a webVR device was detected
  13519. */
  13520. isVRDevicePresent(): boolean;
  13521. /**
  13522. * Gets the current webVR device
  13523. * @returns the current webVR device (or null)
  13524. */
  13525. getVRDevice(): any;
  13526. /**
  13527. * Initializes a webVR display and starts listening to display change events
  13528. * The onVRDisplayChangedObservable will be notified upon these changes
  13529. * @returns A promise containing a VRDisplay and if vr is supported
  13530. */
  13531. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13532. /** @hidden */
  13533. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13534. /**
  13535. * Call this function to switch to webVR mode
  13536. * Will do nothing if webVR is not supported or if there is no webVR device
  13537. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13538. */
  13539. enableVR(): void;
  13540. /** @hidden */
  13541. _onVRFullScreenTriggered(): void;
  13542. }
  13543. }
  13544. }
  13545. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13546. import { Nullable } from "babylonjs/types";
  13547. import { Observable } from "babylonjs/Misc/observable";
  13548. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13549. import { Scene } from "babylonjs/scene";
  13550. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13551. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13552. import { Node } from "babylonjs/node";
  13553. import { Ray } from "babylonjs/Culling/ray";
  13554. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13555. import "babylonjs/Engines/Extensions/engine.webVR";
  13556. /**
  13557. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13558. * IMPORTANT!! The data is right-hand data.
  13559. * @export
  13560. * @interface DevicePose
  13561. */
  13562. export interface DevicePose {
  13563. /**
  13564. * The position of the device, values in array are [x,y,z].
  13565. */
  13566. readonly position: Nullable<Float32Array>;
  13567. /**
  13568. * The linearVelocity of the device, values in array are [x,y,z].
  13569. */
  13570. readonly linearVelocity: Nullable<Float32Array>;
  13571. /**
  13572. * The linearAcceleration of the device, values in array are [x,y,z].
  13573. */
  13574. readonly linearAcceleration: Nullable<Float32Array>;
  13575. /**
  13576. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13577. */
  13578. readonly orientation: Nullable<Float32Array>;
  13579. /**
  13580. * The angularVelocity of the device, values in array are [x,y,z].
  13581. */
  13582. readonly angularVelocity: Nullable<Float32Array>;
  13583. /**
  13584. * The angularAcceleration of the device, values in array are [x,y,z].
  13585. */
  13586. readonly angularAcceleration: Nullable<Float32Array>;
  13587. }
  13588. /**
  13589. * Interface representing a pose controlled object in Babylon.
  13590. * A pose controlled object has both regular pose values as well as pose values
  13591. * from an external device such as a VR head mounted display
  13592. */
  13593. export interface PoseControlled {
  13594. /**
  13595. * The position of the object in babylon space.
  13596. */
  13597. position: Vector3;
  13598. /**
  13599. * The rotation quaternion of the object in babylon space.
  13600. */
  13601. rotationQuaternion: Quaternion;
  13602. /**
  13603. * The position of the device in babylon space.
  13604. */
  13605. devicePosition?: Vector3;
  13606. /**
  13607. * The rotation quaternion of the device in babylon space.
  13608. */
  13609. deviceRotationQuaternion: Quaternion;
  13610. /**
  13611. * The raw pose coming from the device.
  13612. */
  13613. rawPose: Nullable<DevicePose>;
  13614. /**
  13615. * The scale of the device to be used when translating from device space to babylon space.
  13616. */
  13617. deviceScaleFactor: number;
  13618. /**
  13619. * Updates the poseControlled values based on the input device pose.
  13620. * @param poseData the pose data to update the object with
  13621. */
  13622. updateFromDevice(poseData: DevicePose): void;
  13623. }
  13624. /**
  13625. * Set of options to customize the webVRCamera
  13626. */
  13627. export interface WebVROptions {
  13628. /**
  13629. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13630. */
  13631. trackPosition?: boolean;
  13632. /**
  13633. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13634. */
  13635. positionScale?: number;
  13636. /**
  13637. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13638. */
  13639. displayName?: string;
  13640. /**
  13641. * Should the native controller meshes be initialized. (default: true)
  13642. */
  13643. controllerMeshes?: boolean;
  13644. /**
  13645. * Creating a default HemiLight only on controllers. (default: true)
  13646. */
  13647. defaultLightingOnControllers?: boolean;
  13648. /**
  13649. * If you don't want to use the default VR button of the helper. (default: false)
  13650. */
  13651. useCustomVRButton?: boolean;
  13652. /**
  13653. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13654. */
  13655. customVRButton?: HTMLButtonElement;
  13656. /**
  13657. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13658. */
  13659. rayLength?: number;
  13660. /**
  13661. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13662. */
  13663. defaultHeight?: number;
  13664. /**
  13665. * If multiview should be used if availible (default: false)
  13666. */
  13667. useMultiview?: boolean;
  13668. }
  13669. /**
  13670. * This represents a WebVR camera.
  13671. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13672. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13673. */
  13674. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13675. private webVROptions;
  13676. /**
  13677. * @hidden
  13678. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13679. */
  13680. _vrDevice: any;
  13681. /**
  13682. * The rawPose of the vrDevice.
  13683. */
  13684. rawPose: Nullable<DevicePose>;
  13685. private _onVREnabled;
  13686. private _specsVersion;
  13687. private _attached;
  13688. private _frameData;
  13689. protected _descendants: Array<Node>;
  13690. private _deviceRoomPosition;
  13691. /** @hidden */
  13692. _deviceRoomRotationQuaternion: Quaternion;
  13693. private _standingMatrix;
  13694. /**
  13695. * Represents device position in babylon space.
  13696. */
  13697. devicePosition: Vector3;
  13698. /**
  13699. * Represents device rotation in babylon space.
  13700. */
  13701. deviceRotationQuaternion: Quaternion;
  13702. /**
  13703. * The scale of the device to be used when translating from device space to babylon space.
  13704. */
  13705. deviceScaleFactor: number;
  13706. private _deviceToWorld;
  13707. private _worldToDevice;
  13708. /**
  13709. * References to the webVR controllers for the vrDevice.
  13710. */
  13711. controllers: Array<WebVRController>;
  13712. /**
  13713. * Emits an event when a controller is attached.
  13714. */
  13715. onControllersAttachedObservable: Observable<WebVRController[]>;
  13716. /**
  13717. * Emits an event when a controller's mesh has been loaded;
  13718. */
  13719. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13720. /**
  13721. * Emits an event when the HMD's pose has been updated.
  13722. */
  13723. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13724. private _poseSet;
  13725. /**
  13726. * If the rig cameras be used as parent instead of this camera.
  13727. */
  13728. rigParenting: boolean;
  13729. private _lightOnControllers;
  13730. private _defaultHeight?;
  13731. /**
  13732. * Instantiates a WebVRFreeCamera.
  13733. * @param name The name of the WebVRFreeCamera
  13734. * @param position The starting anchor position for the camera
  13735. * @param scene The scene the camera belongs to
  13736. * @param webVROptions a set of customizable options for the webVRCamera
  13737. */
  13738. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13739. /**
  13740. * Gets the device distance from the ground in meters.
  13741. * @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.
  13742. */
  13743. deviceDistanceToRoomGround(): number;
  13744. /**
  13745. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13746. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13747. */
  13748. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13749. /**
  13750. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13751. * @returns A promise with a boolean set to if the standing matrix is supported.
  13752. */
  13753. useStandingMatrixAsync(): Promise<boolean>;
  13754. /**
  13755. * Disposes the camera
  13756. */
  13757. dispose(): void;
  13758. /**
  13759. * Gets a vrController by name.
  13760. * @param name The name of the controller to retreive
  13761. * @returns the controller matching the name specified or null if not found
  13762. */
  13763. getControllerByName(name: string): Nullable<WebVRController>;
  13764. private _leftController;
  13765. /**
  13766. * The controller corrisponding to the users left hand.
  13767. */
  13768. readonly leftController: Nullable<WebVRController>;
  13769. private _rightController;
  13770. /**
  13771. * The controller corrisponding to the users right hand.
  13772. */
  13773. readonly rightController: Nullable<WebVRController>;
  13774. /**
  13775. * Casts a ray forward from the vrCamera's gaze.
  13776. * @param length Length of the ray (default: 100)
  13777. * @returns the ray corrisponding to the gaze
  13778. */
  13779. getForwardRay(length?: number): Ray;
  13780. /**
  13781. * @hidden
  13782. * Updates the camera based on device's frame data
  13783. */
  13784. _checkInputs(): void;
  13785. /**
  13786. * Updates the poseControlled values based on the input device pose.
  13787. * @param poseData Pose coming from the device
  13788. */
  13789. updateFromDevice(poseData: DevicePose): void;
  13790. private _htmlElementAttached;
  13791. private _detachIfAttached;
  13792. /**
  13793. * WebVR's attach control will start broadcasting frames to the device.
  13794. * Note that in certain browsers (chrome for example) this function must be called
  13795. * within a user-interaction callback. Example:
  13796. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13797. *
  13798. * @param element html element to attach the vrDevice to
  13799. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13800. */
  13801. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13802. /**
  13803. * Detaches the camera from the html element and disables VR
  13804. *
  13805. * @param element html element to detach from
  13806. */
  13807. detachControl(element: HTMLElement): void;
  13808. /**
  13809. * @returns the name of this class
  13810. */
  13811. getClassName(): string;
  13812. /**
  13813. * Calls resetPose on the vrDisplay
  13814. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13815. */
  13816. resetToCurrentRotation(): void;
  13817. /**
  13818. * @hidden
  13819. * Updates the rig cameras (left and right eye)
  13820. */
  13821. _updateRigCameras(): void;
  13822. private _workingVector;
  13823. private _oneVector;
  13824. private _workingMatrix;
  13825. private updateCacheCalled;
  13826. private _correctPositionIfNotTrackPosition;
  13827. /**
  13828. * @hidden
  13829. * Updates the cached values of the camera
  13830. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13831. */
  13832. _updateCache(ignoreParentClass?: boolean): void;
  13833. /**
  13834. * @hidden
  13835. * Get current device position in babylon world
  13836. */
  13837. _computeDevicePosition(): void;
  13838. /**
  13839. * Updates the current device position and rotation in the babylon world
  13840. */
  13841. update(): void;
  13842. /**
  13843. * @hidden
  13844. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13845. * @returns an identity matrix
  13846. */
  13847. _getViewMatrix(): Matrix;
  13848. private _tmpMatrix;
  13849. /**
  13850. * This function is called by the two RIG cameras.
  13851. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13852. * @hidden
  13853. */
  13854. _getWebVRViewMatrix(): Matrix;
  13855. /** @hidden */
  13856. _getWebVRProjectionMatrix(): Matrix;
  13857. private _onGamepadConnectedObserver;
  13858. private _onGamepadDisconnectedObserver;
  13859. private _updateCacheWhenTrackingDisabledObserver;
  13860. /**
  13861. * Initializes the controllers and their meshes
  13862. */
  13863. initControllers(): void;
  13864. }
  13865. }
  13866. declare module "babylonjs/PostProcesses/postProcess" {
  13867. import { Nullable } from "babylonjs/types";
  13868. import { SmartArray } from "babylonjs/Misc/smartArray";
  13869. import { Observable } from "babylonjs/Misc/observable";
  13870. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13871. import { Camera } from "babylonjs/Cameras/camera";
  13872. import { Effect } from "babylonjs/Materials/effect";
  13873. import "babylonjs/Shaders/postprocess.vertex";
  13874. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13875. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13876. import { Engine } from "babylonjs/Engines/engine";
  13877. /**
  13878. * Size options for a post process
  13879. */
  13880. export type PostProcessOptions = {
  13881. width: number;
  13882. height: number;
  13883. };
  13884. /**
  13885. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13886. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13887. */
  13888. export class PostProcess {
  13889. /** Name of the PostProcess. */
  13890. name: string;
  13891. /**
  13892. * Gets or sets the unique id of the post process
  13893. */
  13894. uniqueId: number;
  13895. /**
  13896. * Width of the texture to apply the post process on
  13897. */
  13898. width: number;
  13899. /**
  13900. * Height of the texture to apply the post process on
  13901. */
  13902. height: number;
  13903. /**
  13904. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13905. * @hidden
  13906. */
  13907. _outputTexture: Nullable<InternalTexture>;
  13908. /**
  13909. * Sampling mode used by the shader
  13910. * See https://doc.babylonjs.com/classes/3.1/texture
  13911. */
  13912. renderTargetSamplingMode: number;
  13913. /**
  13914. * Clear color to use when screen clearing
  13915. */
  13916. clearColor: Color4;
  13917. /**
  13918. * If the buffer needs to be cleared before applying the post process. (default: true)
  13919. * Should be set to false if shader will overwrite all previous pixels.
  13920. */
  13921. autoClear: boolean;
  13922. /**
  13923. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13924. */
  13925. alphaMode: number;
  13926. /**
  13927. * Sets the setAlphaBlendConstants of the babylon engine
  13928. */
  13929. alphaConstants: Color4;
  13930. /**
  13931. * Animations to be used for the post processing
  13932. */
  13933. animations: import("babylonjs/Animations/animation").Animation[];
  13934. /**
  13935. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13936. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13937. */
  13938. enablePixelPerfectMode: boolean;
  13939. /**
  13940. * Force the postprocess to be applied without taking in account viewport
  13941. */
  13942. forceFullscreenViewport: boolean;
  13943. /**
  13944. * List of inspectable custom properties (used by the Inspector)
  13945. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13946. */
  13947. inspectableCustomProperties: IInspectable[];
  13948. /**
  13949. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13950. *
  13951. * | Value | Type | Description |
  13952. * | ----- | ----------------------------------- | ----------- |
  13953. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13954. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13955. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13956. *
  13957. */
  13958. scaleMode: number;
  13959. /**
  13960. * Force textures to be a power of two (default: false)
  13961. */
  13962. alwaysForcePOT: boolean;
  13963. private _samples;
  13964. /**
  13965. * Number of sample textures (default: 1)
  13966. */
  13967. samples: number;
  13968. /**
  13969. * Modify the scale of the post process to be the same as the viewport (default: false)
  13970. */
  13971. adaptScaleToCurrentViewport: boolean;
  13972. private _camera;
  13973. private _scene;
  13974. private _engine;
  13975. private _options;
  13976. private _reusable;
  13977. private _textureType;
  13978. /**
  13979. * Smart array of input and output textures for the post process.
  13980. * @hidden
  13981. */
  13982. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13983. /**
  13984. * The index in _textures that corresponds to the output texture.
  13985. * @hidden
  13986. */
  13987. _currentRenderTextureInd: number;
  13988. private _effect;
  13989. private _samplers;
  13990. private _fragmentUrl;
  13991. private _vertexUrl;
  13992. private _parameters;
  13993. private _scaleRatio;
  13994. protected _indexParameters: any;
  13995. private _shareOutputWithPostProcess;
  13996. private _texelSize;
  13997. private _forcedOutputTexture;
  13998. /**
  13999. * Returns the fragment url or shader name used in the post process.
  14000. * @returns the fragment url or name in the shader store.
  14001. */
  14002. getEffectName(): string;
  14003. /**
  14004. * An event triggered when the postprocess is activated.
  14005. */
  14006. onActivateObservable: Observable<Camera>;
  14007. private _onActivateObserver;
  14008. /**
  14009. * A function that is added to the onActivateObservable
  14010. */
  14011. onActivate: Nullable<(camera: Camera) => void>;
  14012. /**
  14013. * An event triggered when the postprocess changes its size.
  14014. */
  14015. onSizeChangedObservable: Observable<PostProcess>;
  14016. private _onSizeChangedObserver;
  14017. /**
  14018. * A function that is added to the onSizeChangedObservable
  14019. */
  14020. onSizeChanged: (postProcess: PostProcess) => void;
  14021. /**
  14022. * An event triggered when the postprocess applies its effect.
  14023. */
  14024. onApplyObservable: Observable<Effect>;
  14025. private _onApplyObserver;
  14026. /**
  14027. * A function that is added to the onApplyObservable
  14028. */
  14029. onApply: (effect: Effect) => void;
  14030. /**
  14031. * An event triggered before rendering the postprocess
  14032. */
  14033. onBeforeRenderObservable: Observable<Effect>;
  14034. private _onBeforeRenderObserver;
  14035. /**
  14036. * A function that is added to the onBeforeRenderObservable
  14037. */
  14038. onBeforeRender: (effect: Effect) => void;
  14039. /**
  14040. * An event triggered after rendering the postprocess
  14041. */
  14042. onAfterRenderObservable: Observable<Effect>;
  14043. private _onAfterRenderObserver;
  14044. /**
  14045. * A function that is added to the onAfterRenderObservable
  14046. */
  14047. onAfterRender: (efect: Effect) => void;
  14048. /**
  14049. * 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
  14050. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  14051. */
  14052. inputTexture: InternalTexture;
  14053. /**
  14054. * Gets the camera which post process is applied to.
  14055. * @returns The camera the post process is applied to.
  14056. */
  14057. getCamera(): Camera;
  14058. /**
  14059. * Gets the texel size of the postprocess.
  14060. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  14061. */
  14062. readonly texelSize: Vector2;
  14063. /**
  14064. * Creates a new instance PostProcess
  14065. * @param name The name of the PostProcess.
  14066. * @param fragmentUrl The url of the fragment shader to be used.
  14067. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  14068. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  14069. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  14070. * @param camera The camera to apply the render pass to.
  14071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  14072. * @param engine The engine which the post process will be applied. (default: current engine)
  14073. * @param reusable If the post process can be reused on the same frame. (default: false)
  14074. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  14075. * @param textureType Type of textures used when performing the post process. (default: 0)
  14076. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  14077. * @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
  14078. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  14079. */
  14080. constructor(
  14081. /** Name of the PostProcess. */
  14082. 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);
  14083. /**
  14084. * Gets a string idenfifying the name of the class
  14085. * @returns "PostProcess" string
  14086. */
  14087. getClassName(): string;
  14088. /**
  14089. * Gets the engine which this post process belongs to.
  14090. * @returns The engine the post process was enabled with.
  14091. */
  14092. getEngine(): Engine;
  14093. /**
  14094. * The effect that is created when initializing the post process.
  14095. * @returns The created effect corrisponding the the postprocess.
  14096. */
  14097. getEffect(): Effect;
  14098. /**
  14099. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  14100. * @param postProcess The post process to share the output with.
  14101. * @returns This post process.
  14102. */
  14103. shareOutputWith(postProcess: PostProcess): PostProcess;
  14104. /**
  14105. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  14106. * This should be called if the post process that shares output with this post process is disabled/disposed.
  14107. */
  14108. useOwnOutput(): void;
  14109. /**
  14110. * Updates the effect with the current post process compile time values and recompiles the shader.
  14111. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  14112. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  14113. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  14114. * @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
  14115. * @param onCompiled Called when the shader has been compiled.
  14116. * @param onError Called if there is an error when compiling a shader.
  14117. */
  14118. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  14119. /**
  14120. * The post process is reusable if it can be used multiple times within one frame.
  14121. * @returns If the post process is reusable
  14122. */
  14123. isReusable(): boolean;
  14124. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  14125. markTextureDirty(): void;
  14126. /**
  14127. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  14128. * 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.
  14129. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  14130. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  14131. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  14132. * @returns The target texture that was bound to be written to.
  14133. */
  14134. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  14135. /**
  14136. * If the post process is supported.
  14137. */
  14138. readonly isSupported: boolean;
  14139. /**
  14140. * The aspect ratio of the output texture.
  14141. */
  14142. readonly aspectRatio: number;
  14143. /**
  14144. * Get a value indicating if the post-process is ready to be used
  14145. * @returns true if the post-process is ready (shader is compiled)
  14146. */
  14147. isReady(): boolean;
  14148. /**
  14149. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14150. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14151. */
  14152. apply(): Nullable<Effect>;
  14153. private _disposeTextures;
  14154. /**
  14155. * Disposes the post process.
  14156. * @param camera The camera to dispose the post process on.
  14157. */
  14158. dispose(camera?: Camera): void;
  14159. }
  14160. }
  14161. declare module "babylonjs/PostProcesses/postProcessManager" {
  14162. import { Nullable } from "babylonjs/types";
  14163. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14164. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14165. import { Scene } from "babylonjs/scene";
  14166. /**
  14167. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14168. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14169. */
  14170. export class PostProcessManager {
  14171. private _scene;
  14172. private _indexBuffer;
  14173. private _vertexBuffers;
  14174. /**
  14175. * Creates a new instance PostProcess
  14176. * @param scene The scene that the post process is associated with.
  14177. */
  14178. constructor(scene: Scene);
  14179. private _prepareBuffers;
  14180. private _buildIndexBuffer;
  14181. /**
  14182. * Rebuilds the vertex buffers of the manager.
  14183. * @hidden
  14184. */
  14185. _rebuild(): void;
  14186. /**
  14187. * Prepares a frame to be run through a post process.
  14188. * @param sourceTexture The input texture to the post procesess. (default: null)
  14189. * @param postProcesses An array of post processes to be run. (default: null)
  14190. * @returns True if the post processes were able to be run.
  14191. * @hidden
  14192. */
  14193. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14194. /**
  14195. * Manually render a set of post processes to a texture.
  14196. * @param postProcesses An array of post processes to be run.
  14197. * @param targetTexture The target texture to render to.
  14198. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14199. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14200. * @param lodLevel defines which lod of the texture to render to
  14201. */
  14202. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14203. /**
  14204. * Finalize the result of the output of the postprocesses.
  14205. * @param doNotPresent If true the result will not be displayed to the screen.
  14206. * @param targetTexture The target texture to render to.
  14207. * @param faceIndex The index of the face to bind the target texture to.
  14208. * @param postProcesses The array of post processes to render.
  14209. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14210. * @hidden
  14211. */
  14212. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14213. /**
  14214. * Disposes of the post process manager.
  14215. */
  14216. dispose(): void;
  14217. }
  14218. }
  14219. declare module "babylonjs/Layers/layerSceneComponent" {
  14220. import { Scene } from "babylonjs/scene";
  14221. import { ISceneComponent } from "babylonjs/sceneComponent";
  14222. import { Layer } from "babylonjs/Layers/layer";
  14223. module "babylonjs/abstractScene" {
  14224. interface AbstractScene {
  14225. /**
  14226. * The list of layers (background and foreground) of the scene
  14227. */
  14228. layers: Array<Layer>;
  14229. }
  14230. }
  14231. /**
  14232. * Defines the layer scene component responsible to manage any layers
  14233. * in a given scene.
  14234. */
  14235. export class LayerSceneComponent implements ISceneComponent {
  14236. /**
  14237. * The component name helpfull to identify the component in the list of scene components.
  14238. */
  14239. readonly name: string;
  14240. /**
  14241. * The scene the component belongs to.
  14242. */
  14243. scene: Scene;
  14244. private _engine;
  14245. /**
  14246. * Creates a new instance of the component for the given scene
  14247. * @param scene Defines the scene to register the component in
  14248. */
  14249. constructor(scene: Scene);
  14250. /**
  14251. * Registers the component in a given scene
  14252. */
  14253. register(): void;
  14254. /**
  14255. * Rebuilds the elements related to this component in case of
  14256. * context lost for instance.
  14257. */
  14258. rebuild(): void;
  14259. /**
  14260. * Disposes the component and the associated ressources.
  14261. */
  14262. dispose(): void;
  14263. private _draw;
  14264. private _drawCameraPredicate;
  14265. private _drawCameraBackground;
  14266. private _drawCameraForeground;
  14267. private _drawRenderTargetPredicate;
  14268. private _drawRenderTargetBackground;
  14269. private _drawRenderTargetForeground;
  14270. }
  14271. }
  14272. declare module "babylonjs/Shaders/layer.fragment" {
  14273. /** @hidden */
  14274. export var layerPixelShader: {
  14275. name: string;
  14276. shader: string;
  14277. };
  14278. }
  14279. declare module "babylonjs/Shaders/layer.vertex" {
  14280. /** @hidden */
  14281. export var layerVertexShader: {
  14282. name: string;
  14283. shader: string;
  14284. };
  14285. }
  14286. declare module "babylonjs/Layers/layer" {
  14287. import { Observable } from "babylonjs/Misc/observable";
  14288. import { Nullable } from "babylonjs/types";
  14289. import { Scene } from "babylonjs/scene";
  14290. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14291. import { Texture } from "babylonjs/Materials/Textures/texture";
  14292. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14293. import "babylonjs/Shaders/layer.fragment";
  14294. import "babylonjs/Shaders/layer.vertex";
  14295. /**
  14296. * This represents a full screen 2d layer.
  14297. * This can be useful to display a picture in the background of your scene for instance.
  14298. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14299. */
  14300. export class Layer {
  14301. /**
  14302. * Define the name of the layer.
  14303. */
  14304. name: string;
  14305. /**
  14306. * Define the texture the layer should display.
  14307. */
  14308. texture: Nullable<Texture>;
  14309. /**
  14310. * Is the layer in background or foreground.
  14311. */
  14312. isBackground: boolean;
  14313. /**
  14314. * Define the color of the layer (instead of texture).
  14315. */
  14316. color: Color4;
  14317. /**
  14318. * Define the scale of the layer in order to zoom in out of the texture.
  14319. */
  14320. scale: Vector2;
  14321. /**
  14322. * Define an offset for the layer in order to shift the texture.
  14323. */
  14324. offset: Vector2;
  14325. /**
  14326. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14327. */
  14328. alphaBlendingMode: number;
  14329. /**
  14330. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14331. * Alpha test will not mix with the background color in case of transparency.
  14332. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14333. */
  14334. alphaTest: boolean;
  14335. /**
  14336. * Define a mask to restrict the layer to only some of the scene cameras.
  14337. */
  14338. layerMask: number;
  14339. /**
  14340. * Define the list of render target the layer is visible into.
  14341. */
  14342. renderTargetTextures: RenderTargetTexture[];
  14343. /**
  14344. * Define if the layer is only used in renderTarget or if it also
  14345. * renders in the main frame buffer of the canvas.
  14346. */
  14347. renderOnlyInRenderTargetTextures: boolean;
  14348. private _scene;
  14349. private _vertexBuffers;
  14350. private _indexBuffer;
  14351. private _effect;
  14352. private _alphaTestEffect;
  14353. /**
  14354. * An event triggered when the layer is disposed.
  14355. */
  14356. onDisposeObservable: Observable<Layer>;
  14357. private _onDisposeObserver;
  14358. /**
  14359. * Back compatibility with callback before the onDisposeObservable existed.
  14360. * The set callback will be triggered when the layer has been disposed.
  14361. */
  14362. onDispose: () => void;
  14363. /**
  14364. * An event triggered before rendering the scene
  14365. */
  14366. onBeforeRenderObservable: Observable<Layer>;
  14367. private _onBeforeRenderObserver;
  14368. /**
  14369. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14370. * The set callback will be triggered just before rendering the layer.
  14371. */
  14372. onBeforeRender: () => void;
  14373. /**
  14374. * An event triggered after rendering the scene
  14375. */
  14376. onAfterRenderObservable: Observable<Layer>;
  14377. private _onAfterRenderObserver;
  14378. /**
  14379. * Back compatibility with callback before the onAfterRenderObservable existed.
  14380. * The set callback will be triggered just after rendering the layer.
  14381. */
  14382. onAfterRender: () => void;
  14383. /**
  14384. * Instantiates a new layer.
  14385. * This represents a full screen 2d layer.
  14386. * This can be useful to display a picture in the background of your scene for instance.
  14387. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14388. * @param name Define the name of the layer in the scene
  14389. * @param imgUrl Define the url of the texture to display in the layer
  14390. * @param scene Define the scene the layer belongs to
  14391. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14392. * @param color Defines a color for the layer
  14393. */
  14394. constructor(
  14395. /**
  14396. * Define the name of the layer.
  14397. */
  14398. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14399. private _createIndexBuffer;
  14400. /** @hidden */
  14401. _rebuild(): void;
  14402. /**
  14403. * Renders the layer in the scene.
  14404. */
  14405. render(): void;
  14406. /**
  14407. * Disposes and releases the associated ressources.
  14408. */
  14409. dispose(): void;
  14410. }
  14411. }
  14412. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14413. import { Scene } from "babylonjs/scene";
  14414. import { ISceneComponent } from "babylonjs/sceneComponent";
  14415. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14416. module "babylonjs/abstractScene" {
  14417. interface AbstractScene {
  14418. /**
  14419. * The list of procedural textures added to the scene
  14420. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14421. */
  14422. proceduralTextures: Array<ProceduralTexture>;
  14423. }
  14424. }
  14425. /**
  14426. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14427. * in a given scene.
  14428. */
  14429. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14430. /**
  14431. * The component name helpfull to identify the component in the list of scene components.
  14432. */
  14433. readonly name: string;
  14434. /**
  14435. * The scene the component belongs to.
  14436. */
  14437. scene: Scene;
  14438. /**
  14439. * Creates a new instance of the component for the given scene
  14440. * @param scene Defines the scene to register the component in
  14441. */
  14442. constructor(scene: Scene);
  14443. /**
  14444. * Registers the component in a given scene
  14445. */
  14446. register(): void;
  14447. /**
  14448. * Rebuilds the elements related to this component in case of
  14449. * context lost for instance.
  14450. */
  14451. rebuild(): void;
  14452. /**
  14453. * Disposes the component and the associated ressources.
  14454. */
  14455. dispose(): void;
  14456. private _beforeClear;
  14457. }
  14458. }
  14459. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  14460. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14461. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14462. module "babylonjs/Engines/engine" {
  14463. interface Engine {
  14464. /**
  14465. * Creates a new render target cube texture
  14466. * @param size defines the size of the texture
  14467. * @param options defines the options used to create the texture
  14468. * @returns a new render target cube texture stored in an InternalTexture
  14469. */
  14470. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14471. }
  14472. }
  14473. }
  14474. declare module "babylonjs/Shaders/procedural.vertex" {
  14475. /** @hidden */
  14476. export var proceduralVertexShader: {
  14477. name: string;
  14478. shader: string;
  14479. };
  14480. }
  14481. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14482. import { Observable } from "babylonjs/Misc/observable";
  14483. import { Nullable } from "babylonjs/types";
  14484. import { Scene } from "babylonjs/scene";
  14485. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14486. import { Effect } from "babylonjs/Materials/effect";
  14487. import { Texture } from "babylonjs/Materials/Textures/texture";
  14488. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14489. import "babylonjs/Shaders/procedural.vertex";
  14490. /**
  14491. * 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.
  14492. * This is the base class of any Procedural texture and contains most of the shareable code.
  14493. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14494. */
  14495. export class ProceduralTexture extends Texture {
  14496. isCube: boolean;
  14497. /**
  14498. * Define if the texture is enabled or not (disabled texture will not render)
  14499. */
  14500. isEnabled: boolean;
  14501. /**
  14502. * Define if the texture must be cleared before rendering (default is true)
  14503. */
  14504. autoClear: boolean;
  14505. /**
  14506. * Callback called when the texture is generated
  14507. */
  14508. onGenerated: () => void;
  14509. /**
  14510. * Event raised when the texture is generated
  14511. */
  14512. onGeneratedObservable: Observable<ProceduralTexture>;
  14513. /** @hidden */
  14514. _generateMipMaps: boolean;
  14515. /** @hidden **/
  14516. _effect: Effect;
  14517. /** @hidden */
  14518. _textures: {
  14519. [key: string]: Texture;
  14520. };
  14521. private _size;
  14522. private _currentRefreshId;
  14523. private _refreshRate;
  14524. private _vertexBuffers;
  14525. private _indexBuffer;
  14526. private _uniforms;
  14527. private _samplers;
  14528. private _fragment;
  14529. private _floats;
  14530. private _ints;
  14531. private _floatsArrays;
  14532. private _colors3;
  14533. private _colors4;
  14534. private _vectors2;
  14535. private _vectors3;
  14536. private _matrices;
  14537. private _fallbackTexture;
  14538. private _fallbackTextureUsed;
  14539. private _engine;
  14540. private _cachedDefines;
  14541. private _contentUpdateId;
  14542. private _contentData;
  14543. /**
  14544. * Instantiates a new procedural texture.
  14545. * 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.
  14546. * This is the base class of any Procedural texture and contains most of the shareable code.
  14547. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14548. * @param name Define the name of the texture
  14549. * @param size Define the size of the texture to create
  14550. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14551. * @param scene Define the scene the texture belongs to
  14552. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14553. * @param generateMipMaps Define if the texture should creates mip maps or not
  14554. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14555. */
  14556. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14557. /**
  14558. * The effect that is created when initializing the post process.
  14559. * @returns The created effect corrisponding the the postprocess.
  14560. */
  14561. getEffect(): Effect;
  14562. /**
  14563. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14564. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14565. */
  14566. getContent(): Nullable<ArrayBufferView>;
  14567. private _createIndexBuffer;
  14568. /** @hidden */
  14569. _rebuild(): void;
  14570. /**
  14571. * Resets the texture in order to recreate its associated resources.
  14572. * This can be called in case of context loss
  14573. */
  14574. reset(): void;
  14575. protected _getDefines(): string;
  14576. /**
  14577. * Is the texture ready to be used ? (rendered at least once)
  14578. * @returns true if ready, otherwise, false.
  14579. */
  14580. isReady(): boolean;
  14581. /**
  14582. * Resets the refresh counter of the texture and start bak from scratch.
  14583. * Could be useful to regenerate the texture if it is setup to render only once.
  14584. */
  14585. resetRefreshCounter(): void;
  14586. /**
  14587. * Set the fragment shader to use in order to render the texture.
  14588. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14589. */
  14590. setFragment(fragment: any): void;
  14591. /**
  14592. * Define the refresh rate of the texture or the rendering frequency.
  14593. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14594. */
  14595. refreshRate: number;
  14596. /** @hidden */
  14597. _shouldRender(): boolean;
  14598. /**
  14599. * Get the size the texture is rendering at.
  14600. * @returns the size (texture is always squared)
  14601. */
  14602. getRenderSize(): number;
  14603. /**
  14604. * Resize the texture to new value.
  14605. * @param size Define the new size the texture should have
  14606. * @param generateMipMaps Define whether the new texture should create mip maps
  14607. */
  14608. resize(size: number, generateMipMaps: boolean): void;
  14609. private _checkUniform;
  14610. /**
  14611. * Set a texture in the shader program used to render.
  14612. * @param name Define the name of the uniform samplers as defined in the shader
  14613. * @param texture Define the texture to bind to this sampler
  14614. * @return the texture itself allowing "fluent" like uniform updates
  14615. */
  14616. setTexture(name: string, texture: Texture): ProceduralTexture;
  14617. /**
  14618. * Set a float in the shader.
  14619. * @param name Define the name of the uniform as defined in the shader
  14620. * @param value Define the value to give to the uniform
  14621. * @return the texture itself allowing "fluent" like uniform updates
  14622. */
  14623. setFloat(name: string, value: number): ProceduralTexture;
  14624. /**
  14625. * Set a int in the shader.
  14626. * @param name Define the name of the uniform as defined in the shader
  14627. * @param value Define the value to give to the uniform
  14628. * @return the texture itself allowing "fluent" like uniform updates
  14629. */
  14630. setInt(name: string, value: number): ProceduralTexture;
  14631. /**
  14632. * Set an array of floats in the shader.
  14633. * @param name Define the name of the uniform as defined in the shader
  14634. * @param value Define the value to give to the uniform
  14635. * @return the texture itself allowing "fluent" like uniform updates
  14636. */
  14637. setFloats(name: string, value: number[]): ProceduralTexture;
  14638. /**
  14639. * Set a vec3 in the shader from a Color3.
  14640. * @param name Define the name of the uniform as defined in the shader
  14641. * @param value Define the value to give to the uniform
  14642. * @return the texture itself allowing "fluent" like uniform updates
  14643. */
  14644. setColor3(name: string, value: Color3): ProceduralTexture;
  14645. /**
  14646. * Set a vec4 in the shader from a Color4.
  14647. * @param name Define the name of the uniform as defined in the shader
  14648. * @param value Define the value to give to the uniform
  14649. * @return the texture itself allowing "fluent" like uniform updates
  14650. */
  14651. setColor4(name: string, value: Color4): ProceduralTexture;
  14652. /**
  14653. * Set a vec2 in the shader from a Vector2.
  14654. * @param name Define the name of the uniform as defined in the shader
  14655. * @param value Define the value to give to the uniform
  14656. * @return the texture itself allowing "fluent" like uniform updates
  14657. */
  14658. setVector2(name: string, value: Vector2): ProceduralTexture;
  14659. /**
  14660. * Set a vec3 in the shader from a Vector3.
  14661. * @param name Define the name of the uniform as defined in the shader
  14662. * @param value Define the value to give to the uniform
  14663. * @return the texture itself allowing "fluent" like uniform updates
  14664. */
  14665. setVector3(name: string, value: Vector3): ProceduralTexture;
  14666. /**
  14667. * Set a mat4 in the shader from a MAtrix.
  14668. * @param name Define the name of the uniform as defined in the shader
  14669. * @param value Define the value to give to the uniform
  14670. * @return the texture itself allowing "fluent" like uniform updates
  14671. */
  14672. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14673. /**
  14674. * Render the texture to its associated render target.
  14675. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14676. */
  14677. render(useCameraPostProcess?: boolean): void;
  14678. /**
  14679. * Clone the texture.
  14680. * @returns the cloned texture
  14681. */
  14682. clone(): ProceduralTexture;
  14683. /**
  14684. * Dispose the texture and release its asoociated resources.
  14685. */
  14686. dispose(): void;
  14687. }
  14688. }
  14689. declare module "babylonjs/Particles/baseParticleSystem" {
  14690. import { Nullable } from "babylonjs/types";
  14691. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14693. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14694. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14695. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14696. import { Scene } from "babylonjs/scene";
  14697. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14698. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14699. import { Texture } from "babylonjs/Materials/Textures/texture";
  14700. import { Animation } from "babylonjs/Animations/animation";
  14701. /**
  14702. * This represents the base class for particle system in Babylon.
  14703. * 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.
  14704. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14705. * @example https://doc.babylonjs.com/babylon101/particles
  14706. */
  14707. export class BaseParticleSystem {
  14708. /**
  14709. * Source color is added to the destination color without alpha affecting the result
  14710. */
  14711. static BLENDMODE_ONEONE: number;
  14712. /**
  14713. * Blend current color and particle color using particle’s alpha
  14714. */
  14715. static BLENDMODE_STANDARD: number;
  14716. /**
  14717. * Add current color and particle color multiplied by particle’s alpha
  14718. */
  14719. static BLENDMODE_ADD: number;
  14720. /**
  14721. * Multiply current color with particle color
  14722. */
  14723. static BLENDMODE_MULTIPLY: number;
  14724. /**
  14725. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14726. */
  14727. static BLENDMODE_MULTIPLYADD: number;
  14728. /**
  14729. * List of animations used by the particle system.
  14730. */
  14731. animations: Animation[];
  14732. /**
  14733. * The id of the Particle system.
  14734. */
  14735. id: string;
  14736. /**
  14737. * The friendly name of the Particle system.
  14738. */
  14739. name: string;
  14740. /**
  14741. * The rendering group used by the Particle system to chose when to render.
  14742. */
  14743. renderingGroupId: number;
  14744. /**
  14745. * The emitter represents the Mesh or position we are attaching the particle system to.
  14746. */
  14747. emitter: Nullable<AbstractMesh | Vector3>;
  14748. /**
  14749. * The maximum number of particles to emit per frame
  14750. */
  14751. emitRate: number;
  14752. /**
  14753. * If you want to launch only a few particles at once, that can be done, as well.
  14754. */
  14755. manualEmitCount: number;
  14756. /**
  14757. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14758. */
  14759. updateSpeed: number;
  14760. /**
  14761. * The amount of time the particle system is running (depends of the overall update speed).
  14762. */
  14763. targetStopDuration: number;
  14764. /**
  14765. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14766. */
  14767. disposeOnStop: boolean;
  14768. /**
  14769. * Minimum power of emitting particles.
  14770. */
  14771. minEmitPower: number;
  14772. /**
  14773. * Maximum power of emitting particles.
  14774. */
  14775. maxEmitPower: number;
  14776. /**
  14777. * Minimum life time of emitting particles.
  14778. */
  14779. minLifeTime: number;
  14780. /**
  14781. * Maximum life time of emitting particles.
  14782. */
  14783. maxLifeTime: number;
  14784. /**
  14785. * Minimum Size of emitting particles.
  14786. */
  14787. minSize: number;
  14788. /**
  14789. * Maximum Size of emitting particles.
  14790. */
  14791. maxSize: number;
  14792. /**
  14793. * Minimum scale of emitting particles on X axis.
  14794. */
  14795. minScaleX: number;
  14796. /**
  14797. * Maximum scale of emitting particles on X axis.
  14798. */
  14799. maxScaleX: number;
  14800. /**
  14801. * Minimum scale of emitting particles on Y axis.
  14802. */
  14803. minScaleY: number;
  14804. /**
  14805. * Maximum scale of emitting particles on Y axis.
  14806. */
  14807. maxScaleY: number;
  14808. /**
  14809. * Gets or sets the minimal initial rotation in radians.
  14810. */
  14811. minInitialRotation: number;
  14812. /**
  14813. * Gets or sets the maximal initial rotation in radians.
  14814. */
  14815. maxInitialRotation: number;
  14816. /**
  14817. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14818. */
  14819. minAngularSpeed: number;
  14820. /**
  14821. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14822. */
  14823. maxAngularSpeed: number;
  14824. /**
  14825. * The texture used to render each particle. (this can be a spritesheet)
  14826. */
  14827. particleTexture: Nullable<Texture>;
  14828. /**
  14829. * The layer mask we are rendering the particles through.
  14830. */
  14831. layerMask: number;
  14832. /**
  14833. * This can help using your own shader to render the particle system.
  14834. * The according effect will be created
  14835. */
  14836. customShader: any;
  14837. /**
  14838. * By default particle system starts as soon as they are created. This prevents the
  14839. * automatic start to happen and let you decide when to start emitting particles.
  14840. */
  14841. preventAutoStart: boolean;
  14842. private _noiseTexture;
  14843. /**
  14844. * Gets or sets a texture used to add random noise to particle positions
  14845. */
  14846. noiseTexture: Nullable<ProceduralTexture>;
  14847. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14848. noiseStrength: Vector3;
  14849. /**
  14850. * Callback triggered when the particle animation is ending.
  14851. */
  14852. onAnimationEnd: Nullable<() => void>;
  14853. /**
  14854. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14855. */
  14856. blendMode: number;
  14857. /**
  14858. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14859. * to override the particles.
  14860. */
  14861. forceDepthWrite: boolean;
  14862. /** 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 */
  14863. preWarmCycles: number;
  14864. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14865. preWarmStepOffset: number;
  14866. /**
  14867. * 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)
  14868. */
  14869. spriteCellChangeSpeed: number;
  14870. /**
  14871. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14872. */
  14873. startSpriteCellID: number;
  14874. /**
  14875. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14876. */
  14877. endSpriteCellID: number;
  14878. /**
  14879. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14880. */
  14881. spriteCellWidth: number;
  14882. /**
  14883. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14884. */
  14885. spriteCellHeight: number;
  14886. /**
  14887. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14888. */
  14889. spriteRandomStartCell: boolean;
  14890. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14891. translationPivot: Vector2;
  14892. /** @hidden */
  14893. protected _isAnimationSheetEnabled: boolean;
  14894. /**
  14895. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14896. */
  14897. beginAnimationOnStart: boolean;
  14898. /**
  14899. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14900. */
  14901. beginAnimationFrom: number;
  14902. /**
  14903. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14904. */
  14905. beginAnimationTo: number;
  14906. /**
  14907. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14908. */
  14909. beginAnimationLoop: boolean;
  14910. /**
  14911. * Gets or sets a world offset applied to all particles
  14912. */
  14913. worldOffset: Vector3;
  14914. /**
  14915. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14916. */
  14917. isAnimationSheetEnabled: boolean;
  14918. /**
  14919. * Get hosting scene
  14920. * @returns the scene
  14921. */
  14922. getScene(): Scene;
  14923. /**
  14924. * You can use gravity if you want to give an orientation to your particles.
  14925. */
  14926. gravity: Vector3;
  14927. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14928. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14929. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14930. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14931. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14932. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14933. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14934. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14935. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14936. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14937. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14938. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14939. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14940. /**
  14941. * Defines the delay in milliseconds before starting the system (0 by default)
  14942. */
  14943. startDelay: number;
  14944. /**
  14945. * Gets the current list of drag gradients.
  14946. * You must use addDragGradient and removeDragGradient to udpate this list
  14947. * @returns the list of drag gradients
  14948. */
  14949. getDragGradients(): Nullable<Array<FactorGradient>>;
  14950. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14951. limitVelocityDamping: number;
  14952. /**
  14953. * Gets the current list of limit velocity gradients.
  14954. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14955. * @returns the list of limit velocity gradients
  14956. */
  14957. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14958. /**
  14959. * Gets the current list of color gradients.
  14960. * You must use addColorGradient and removeColorGradient to udpate this list
  14961. * @returns the list of color gradients
  14962. */
  14963. getColorGradients(): Nullable<Array<ColorGradient>>;
  14964. /**
  14965. * Gets the current list of size gradients.
  14966. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14967. * @returns the list of size gradients
  14968. */
  14969. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14970. /**
  14971. * Gets the current list of color remap gradients.
  14972. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14973. * @returns the list of color remap gradients
  14974. */
  14975. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14976. /**
  14977. * Gets the current list of alpha remap gradients.
  14978. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14979. * @returns the list of alpha remap gradients
  14980. */
  14981. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14982. /**
  14983. * Gets the current list of life time gradients.
  14984. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14985. * @returns the list of life time gradients
  14986. */
  14987. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14988. /**
  14989. * Gets the current list of angular speed gradients.
  14990. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14991. * @returns the list of angular speed gradients
  14992. */
  14993. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14994. /**
  14995. * Gets the current list of velocity gradients.
  14996. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14997. * @returns the list of velocity gradients
  14998. */
  14999. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15000. /**
  15001. * Gets the current list of start size gradients.
  15002. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15003. * @returns the list of start size gradients
  15004. */
  15005. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15006. /**
  15007. * Gets the current list of emit rate gradients.
  15008. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15009. * @returns the list of emit rate gradients
  15010. */
  15011. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15012. /**
  15013. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15014. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15015. */
  15016. direction1: Vector3;
  15017. /**
  15018. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15019. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15020. */
  15021. direction2: Vector3;
  15022. /**
  15023. * 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.
  15024. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15025. */
  15026. minEmitBox: Vector3;
  15027. /**
  15028. * 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.
  15029. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15030. */
  15031. maxEmitBox: Vector3;
  15032. /**
  15033. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15034. */
  15035. color1: Color4;
  15036. /**
  15037. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15038. */
  15039. color2: Color4;
  15040. /**
  15041. * Color the particle will have at the end of its lifetime
  15042. */
  15043. colorDead: Color4;
  15044. /**
  15045. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15046. */
  15047. textureMask: Color4;
  15048. /**
  15049. * The particle emitter type defines the emitter used by the particle system.
  15050. * It can be for example box, sphere, or cone...
  15051. */
  15052. particleEmitterType: IParticleEmitterType;
  15053. /** @hidden */
  15054. _isSubEmitter: boolean;
  15055. /**
  15056. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15057. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15058. */
  15059. billboardMode: number;
  15060. protected _isBillboardBased: boolean;
  15061. /**
  15062. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15063. */
  15064. isBillboardBased: boolean;
  15065. /**
  15066. * The scene the particle system belongs to.
  15067. */
  15068. protected _scene: Scene;
  15069. /**
  15070. * Local cache of defines for image processing.
  15071. */
  15072. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15073. /**
  15074. * Default configuration related to image processing available in the standard Material.
  15075. */
  15076. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15077. /**
  15078. * Gets the image processing configuration used either in this material.
  15079. */
  15080. /**
  15081. * Sets the Default image processing configuration used either in the this material.
  15082. *
  15083. * If sets to null, the scene one is in use.
  15084. */
  15085. imageProcessingConfiguration: ImageProcessingConfiguration;
  15086. /**
  15087. * Attaches a new image processing configuration to the Standard Material.
  15088. * @param configuration
  15089. */
  15090. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15091. /** @hidden */
  15092. protected _reset(): void;
  15093. /** @hidden */
  15094. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15095. /**
  15096. * Instantiates a particle system.
  15097. * 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.
  15098. * @param name The name of the particle system
  15099. */
  15100. constructor(name: string);
  15101. /**
  15102. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15103. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15104. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15105. * @returns the emitter
  15106. */
  15107. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15108. /**
  15109. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15110. * @param radius The radius of the hemisphere to emit from
  15111. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15112. * @returns the emitter
  15113. */
  15114. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15115. /**
  15116. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15117. * @param radius The radius of the sphere to emit from
  15118. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15119. * @returns the emitter
  15120. */
  15121. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15122. /**
  15123. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15124. * @param radius The radius of the sphere to emit from
  15125. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15126. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15127. * @returns the emitter
  15128. */
  15129. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15130. /**
  15131. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15132. * @param radius The radius of the emission cylinder
  15133. * @param height The height of the emission cylinder
  15134. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15135. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15136. * @returns the emitter
  15137. */
  15138. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15139. /**
  15140. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15141. * @param radius The radius of the cylinder to emit from
  15142. * @param height The height of the emission cylinder
  15143. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15144. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15145. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15146. * @returns the emitter
  15147. */
  15148. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15149. /**
  15150. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15151. * @param radius The radius of the cone to emit from
  15152. * @param angle The base angle of the cone
  15153. * @returns the emitter
  15154. */
  15155. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15156. /**
  15157. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15158. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15159. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15160. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15161. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15162. * @returns the emitter
  15163. */
  15164. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15165. }
  15166. }
  15167. declare module "babylonjs/Particles/subEmitter" {
  15168. import { Scene } from "babylonjs/scene";
  15169. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15170. /**
  15171. * Type of sub emitter
  15172. */
  15173. export enum SubEmitterType {
  15174. /**
  15175. * Attached to the particle over it's lifetime
  15176. */
  15177. ATTACHED = 0,
  15178. /**
  15179. * Created when the particle dies
  15180. */
  15181. END = 1
  15182. }
  15183. /**
  15184. * Sub emitter class used to emit particles from an existing particle
  15185. */
  15186. export class SubEmitter {
  15187. /**
  15188. * the particle system to be used by the sub emitter
  15189. */
  15190. particleSystem: ParticleSystem;
  15191. /**
  15192. * Type of the submitter (Default: END)
  15193. */
  15194. type: SubEmitterType;
  15195. /**
  15196. * 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)
  15197. * Note: This only is supported when using an emitter of type Mesh
  15198. */
  15199. inheritDirection: boolean;
  15200. /**
  15201. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15202. */
  15203. inheritedVelocityAmount: number;
  15204. /**
  15205. * Creates a sub emitter
  15206. * @param particleSystem the particle system to be used by the sub emitter
  15207. */
  15208. constructor(
  15209. /**
  15210. * the particle system to be used by the sub emitter
  15211. */
  15212. particleSystem: ParticleSystem);
  15213. /**
  15214. * Clones the sub emitter
  15215. * @returns the cloned sub emitter
  15216. */
  15217. clone(): SubEmitter;
  15218. /**
  15219. * Serialize current object to a JSON object
  15220. * @returns the serialized object
  15221. */
  15222. serialize(): any;
  15223. /** @hidden */
  15224. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15225. /**
  15226. * Creates a new SubEmitter from a serialized JSON version
  15227. * @param serializationObject defines the JSON object to read from
  15228. * @param scene defines the hosting scene
  15229. * @param rootUrl defines the rootUrl for data loading
  15230. * @returns a new SubEmitter
  15231. */
  15232. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15233. /** Release associated resources */
  15234. dispose(): void;
  15235. }
  15236. }
  15237. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15238. /** @hidden */
  15239. export var clipPlaneFragmentDeclaration: {
  15240. name: string;
  15241. shader: string;
  15242. };
  15243. }
  15244. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15245. /** @hidden */
  15246. export var imageProcessingDeclaration: {
  15247. name: string;
  15248. shader: string;
  15249. };
  15250. }
  15251. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15252. /** @hidden */
  15253. export var imageProcessingFunctions: {
  15254. name: string;
  15255. shader: string;
  15256. };
  15257. }
  15258. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15259. /** @hidden */
  15260. export var clipPlaneFragment: {
  15261. name: string;
  15262. shader: string;
  15263. };
  15264. }
  15265. declare module "babylonjs/Shaders/particles.fragment" {
  15266. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15267. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15268. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15269. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15270. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15271. /** @hidden */
  15272. export var particlesPixelShader: {
  15273. name: string;
  15274. shader: string;
  15275. };
  15276. }
  15277. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15278. /** @hidden */
  15279. export var clipPlaneVertexDeclaration: {
  15280. name: string;
  15281. shader: string;
  15282. };
  15283. }
  15284. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15285. /** @hidden */
  15286. export var clipPlaneVertex: {
  15287. name: string;
  15288. shader: string;
  15289. };
  15290. }
  15291. declare module "babylonjs/Shaders/particles.vertex" {
  15292. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15293. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15294. /** @hidden */
  15295. export var particlesVertexShader: {
  15296. name: string;
  15297. shader: string;
  15298. };
  15299. }
  15300. declare module "babylonjs/Particles/particleSystem" {
  15301. import { Nullable } from "babylonjs/types";
  15302. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15303. import { Observable } from "babylonjs/Misc/observable";
  15304. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15305. import { Effect } from "babylonjs/Materials/effect";
  15306. import { Scene, IDisposable } from "babylonjs/scene";
  15307. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15308. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15309. import { Particle } from "babylonjs/Particles/particle";
  15310. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15311. import "babylonjs/Shaders/particles.fragment";
  15312. import "babylonjs/Shaders/particles.vertex";
  15313. /**
  15314. * This represents a particle system in Babylon.
  15315. * 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.
  15316. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15317. * @example https://doc.babylonjs.com/babylon101/particles
  15318. */
  15319. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15320. /**
  15321. * Billboard mode will only apply to Y axis
  15322. */
  15323. static readonly BILLBOARDMODE_Y: number;
  15324. /**
  15325. * Billboard mode will apply to all axes
  15326. */
  15327. static readonly BILLBOARDMODE_ALL: number;
  15328. /**
  15329. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15330. */
  15331. static readonly BILLBOARDMODE_STRETCHED: number;
  15332. /**
  15333. * This function can be defined to provide custom update for active particles.
  15334. * This function will be called instead of regular update (age, position, color, etc.).
  15335. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15336. */
  15337. updateFunction: (particles: Particle[]) => void;
  15338. private _emitterWorldMatrix;
  15339. /**
  15340. * This function can be defined to specify initial direction for every new particle.
  15341. * It by default use the emitterType defined function
  15342. */
  15343. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15344. /**
  15345. * This function can be defined to specify initial position for every new particle.
  15346. * It by default use the emitterType defined function
  15347. */
  15348. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15349. /**
  15350. * @hidden
  15351. */
  15352. _inheritedVelocityOffset: Vector3;
  15353. /**
  15354. * An event triggered when the system is disposed
  15355. */
  15356. onDisposeObservable: Observable<ParticleSystem>;
  15357. private _onDisposeObserver;
  15358. /**
  15359. * Sets a callback that will be triggered when the system is disposed
  15360. */
  15361. onDispose: () => void;
  15362. private _particles;
  15363. private _epsilon;
  15364. private _capacity;
  15365. private _stockParticles;
  15366. private _newPartsExcess;
  15367. private _vertexData;
  15368. private _vertexBuffer;
  15369. private _vertexBuffers;
  15370. private _spriteBuffer;
  15371. private _indexBuffer;
  15372. private _effect;
  15373. private _customEffect;
  15374. private _cachedDefines;
  15375. private _scaledColorStep;
  15376. private _colorDiff;
  15377. private _scaledDirection;
  15378. private _scaledGravity;
  15379. private _currentRenderId;
  15380. private _alive;
  15381. private _useInstancing;
  15382. private _started;
  15383. private _stopped;
  15384. private _actualFrame;
  15385. private _scaledUpdateSpeed;
  15386. private _vertexBufferSize;
  15387. /** @hidden */
  15388. _currentEmitRateGradient: Nullable<FactorGradient>;
  15389. /** @hidden */
  15390. _currentEmitRate1: number;
  15391. /** @hidden */
  15392. _currentEmitRate2: number;
  15393. /** @hidden */
  15394. _currentStartSizeGradient: Nullable<FactorGradient>;
  15395. /** @hidden */
  15396. _currentStartSize1: number;
  15397. /** @hidden */
  15398. _currentStartSize2: number;
  15399. private readonly _rawTextureWidth;
  15400. private _rampGradientsTexture;
  15401. private _useRampGradients;
  15402. /** Gets or sets a boolean indicating that ramp gradients must be used
  15403. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15404. */
  15405. useRampGradients: boolean;
  15406. /**
  15407. * 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.
  15408. * 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: [])
  15409. */
  15410. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15411. private _subEmitters;
  15412. /**
  15413. * @hidden
  15414. * If the particle systems emitter should be disposed when the particle system is disposed
  15415. */
  15416. _disposeEmitterOnDispose: boolean;
  15417. /**
  15418. * The current active Sub-systems, this property is used by the root particle system only.
  15419. */
  15420. activeSubSystems: Array<ParticleSystem>;
  15421. private _rootParticleSystem;
  15422. /**
  15423. * Gets the current list of active particles
  15424. */
  15425. readonly particles: Particle[];
  15426. /**
  15427. * Returns the string "ParticleSystem"
  15428. * @returns a string containing the class name
  15429. */
  15430. getClassName(): string;
  15431. /**
  15432. * Instantiates a particle system.
  15433. * 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.
  15434. * @param name The name of the particle system
  15435. * @param capacity The max number of particles alive at the same time
  15436. * @param scene The scene the particle system belongs to
  15437. * @param customEffect a custom effect used to change the way particles are rendered by default
  15438. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15439. * @param epsilon Offset used to render the particles
  15440. */
  15441. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15442. private _addFactorGradient;
  15443. private _removeFactorGradient;
  15444. /**
  15445. * Adds a new life time gradient
  15446. * @param gradient defines the gradient to use (between 0 and 1)
  15447. * @param factor defines the life time factor to affect to the specified gradient
  15448. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15449. * @returns the current particle system
  15450. */
  15451. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15452. /**
  15453. * Remove a specific life time gradient
  15454. * @param gradient defines the gradient to remove
  15455. * @returns the current particle system
  15456. */
  15457. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15458. /**
  15459. * Adds a new size gradient
  15460. * @param gradient defines the gradient to use (between 0 and 1)
  15461. * @param factor defines the size factor to affect to the specified gradient
  15462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15463. * @returns the current particle system
  15464. */
  15465. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15466. /**
  15467. * Remove a specific size gradient
  15468. * @param gradient defines the gradient to remove
  15469. * @returns the current particle system
  15470. */
  15471. removeSizeGradient(gradient: number): IParticleSystem;
  15472. /**
  15473. * Adds a new color remap gradient
  15474. * @param gradient defines the gradient to use (between 0 and 1)
  15475. * @param min defines the color remap minimal range
  15476. * @param max defines the color remap maximal range
  15477. * @returns the current particle system
  15478. */
  15479. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15480. /**
  15481. * Remove a specific color remap gradient
  15482. * @param gradient defines the gradient to remove
  15483. * @returns the current particle system
  15484. */
  15485. removeColorRemapGradient(gradient: number): IParticleSystem;
  15486. /**
  15487. * Adds a new alpha remap gradient
  15488. * @param gradient defines the gradient to use (between 0 and 1)
  15489. * @param min defines the alpha remap minimal range
  15490. * @param max defines the alpha remap maximal range
  15491. * @returns the current particle system
  15492. */
  15493. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15494. /**
  15495. * Remove a specific alpha remap gradient
  15496. * @param gradient defines the gradient to remove
  15497. * @returns the current particle system
  15498. */
  15499. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15500. /**
  15501. * Adds a new angular speed gradient
  15502. * @param gradient defines the gradient to use (between 0 and 1)
  15503. * @param factor defines the angular speed to affect to the specified gradient
  15504. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15505. * @returns the current particle system
  15506. */
  15507. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15508. /**
  15509. * Remove a specific angular speed gradient
  15510. * @param gradient defines the gradient to remove
  15511. * @returns the current particle system
  15512. */
  15513. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15514. /**
  15515. * Adds a new velocity gradient
  15516. * @param gradient defines the gradient to use (between 0 and 1)
  15517. * @param factor defines the velocity to affect to the specified gradient
  15518. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15519. * @returns the current particle system
  15520. */
  15521. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15522. /**
  15523. * Remove a specific velocity gradient
  15524. * @param gradient defines the gradient to remove
  15525. * @returns the current particle system
  15526. */
  15527. removeVelocityGradient(gradient: number): IParticleSystem;
  15528. /**
  15529. * Adds a new limit velocity gradient
  15530. * @param gradient defines the gradient to use (between 0 and 1)
  15531. * @param factor defines the limit velocity value to affect to the specified gradient
  15532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15533. * @returns the current particle system
  15534. */
  15535. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15536. /**
  15537. * Remove a specific limit velocity gradient
  15538. * @param gradient defines the gradient to remove
  15539. * @returns the current particle system
  15540. */
  15541. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15542. /**
  15543. * Adds a new drag gradient
  15544. * @param gradient defines the gradient to use (between 0 and 1)
  15545. * @param factor defines the drag value to affect to the specified gradient
  15546. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15547. * @returns the current particle system
  15548. */
  15549. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15550. /**
  15551. * Remove a specific drag gradient
  15552. * @param gradient defines the gradient to remove
  15553. * @returns the current particle system
  15554. */
  15555. removeDragGradient(gradient: number): IParticleSystem;
  15556. /**
  15557. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15558. * @param gradient defines the gradient to use (between 0 and 1)
  15559. * @param factor defines the emit rate value to affect to the specified gradient
  15560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15561. * @returns the current particle system
  15562. */
  15563. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15564. /**
  15565. * Remove a specific emit rate gradient
  15566. * @param gradient defines the gradient to remove
  15567. * @returns the current particle system
  15568. */
  15569. removeEmitRateGradient(gradient: number): IParticleSystem;
  15570. /**
  15571. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15572. * @param gradient defines the gradient to use (between 0 and 1)
  15573. * @param factor defines the start size value to affect to the specified gradient
  15574. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15575. * @returns the current particle system
  15576. */
  15577. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15578. /**
  15579. * Remove a specific start size gradient
  15580. * @param gradient defines the gradient to remove
  15581. * @returns the current particle system
  15582. */
  15583. removeStartSizeGradient(gradient: number): IParticleSystem;
  15584. private _createRampGradientTexture;
  15585. /**
  15586. * Gets the current list of ramp gradients.
  15587. * You must use addRampGradient and removeRampGradient to udpate this list
  15588. * @returns the list of ramp gradients
  15589. */
  15590. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15591. /**
  15592. * Adds a new ramp gradient used to remap particle colors
  15593. * @param gradient defines the gradient to use (between 0 and 1)
  15594. * @param color defines the color to affect to the specified gradient
  15595. * @returns the current particle system
  15596. */
  15597. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15598. /**
  15599. * Remove a specific ramp gradient
  15600. * @param gradient defines the gradient to remove
  15601. * @returns the current particle system
  15602. */
  15603. removeRampGradient(gradient: number): ParticleSystem;
  15604. /**
  15605. * Adds a new color gradient
  15606. * @param gradient defines the gradient to use (between 0 and 1)
  15607. * @param color1 defines the color to affect to the specified gradient
  15608. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15609. * @returns this particle system
  15610. */
  15611. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15612. /**
  15613. * Remove a specific color gradient
  15614. * @param gradient defines the gradient to remove
  15615. * @returns this particle system
  15616. */
  15617. removeColorGradient(gradient: number): IParticleSystem;
  15618. private _fetchR;
  15619. protected _reset(): void;
  15620. private _resetEffect;
  15621. private _createVertexBuffers;
  15622. private _createIndexBuffer;
  15623. /**
  15624. * Gets the maximum number of particles active at the same time.
  15625. * @returns The max number of active particles.
  15626. */
  15627. getCapacity(): number;
  15628. /**
  15629. * Gets whether there are still active particles in the system.
  15630. * @returns True if it is alive, otherwise false.
  15631. */
  15632. isAlive(): boolean;
  15633. /**
  15634. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15635. * @returns True if it has been started, otherwise false.
  15636. */
  15637. isStarted(): boolean;
  15638. private _prepareSubEmitterInternalArray;
  15639. /**
  15640. * Starts the particle system and begins to emit
  15641. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15642. */
  15643. start(delay?: number): void;
  15644. /**
  15645. * Stops the particle system.
  15646. * @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.
  15647. */
  15648. stop(stopSubEmitters?: boolean): void;
  15649. /**
  15650. * Remove all active particles
  15651. */
  15652. reset(): void;
  15653. /**
  15654. * @hidden (for internal use only)
  15655. */
  15656. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15657. /**
  15658. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15659. * Its lifetime will start back at 0.
  15660. */
  15661. recycleParticle: (particle: Particle) => void;
  15662. private _stopSubEmitters;
  15663. private _createParticle;
  15664. private _removeFromRoot;
  15665. private _emitFromParticle;
  15666. private _update;
  15667. /** @hidden */
  15668. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15669. /** @hidden */
  15670. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15671. /** @hidden */
  15672. private _getEffect;
  15673. /**
  15674. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15675. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15676. */
  15677. animate(preWarmOnly?: boolean): void;
  15678. private _appendParticleVertices;
  15679. /**
  15680. * Rebuilds the particle system.
  15681. */
  15682. rebuild(): void;
  15683. /**
  15684. * Is this system ready to be used/rendered
  15685. * @return true if the system is ready
  15686. */
  15687. isReady(): boolean;
  15688. private _render;
  15689. /**
  15690. * Renders the particle system in its current state.
  15691. * @returns the current number of particles
  15692. */
  15693. render(): number;
  15694. /**
  15695. * Disposes the particle system and free the associated resources
  15696. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15697. */
  15698. dispose(disposeTexture?: boolean): void;
  15699. /**
  15700. * Clones the particle system.
  15701. * @param name The name of the cloned object
  15702. * @param newEmitter The new emitter to use
  15703. * @returns the cloned particle system
  15704. */
  15705. clone(name: string, newEmitter: any): ParticleSystem;
  15706. /**
  15707. * Serializes the particle system to a JSON object.
  15708. * @returns the JSON object
  15709. */
  15710. serialize(): any;
  15711. /** @hidden */
  15712. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15713. /** @hidden */
  15714. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15715. /**
  15716. * Parses a JSON object to create a particle system.
  15717. * @param parsedParticleSystem The JSON object to parse
  15718. * @param scene The scene to create the particle system in
  15719. * @param rootUrl The root url to use to load external dependencies like texture
  15720. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15721. * @returns the Parsed particle system
  15722. */
  15723. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15724. }
  15725. }
  15726. declare module "babylonjs/Particles/particle" {
  15727. import { Nullable } from "babylonjs/types";
  15728. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15729. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15730. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15731. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15732. /**
  15733. * A particle represents one of the element emitted by a particle system.
  15734. * This is mainly define by its coordinates, direction, velocity and age.
  15735. */
  15736. export class Particle {
  15737. /**
  15738. * The particle system the particle belongs to.
  15739. */
  15740. particleSystem: ParticleSystem;
  15741. private static _Count;
  15742. /**
  15743. * Unique ID of the particle
  15744. */
  15745. id: number;
  15746. /**
  15747. * The world position of the particle in the scene.
  15748. */
  15749. position: Vector3;
  15750. /**
  15751. * The world direction of the particle in the scene.
  15752. */
  15753. direction: Vector3;
  15754. /**
  15755. * The color of the particle.
  15756. */
  15757. color: Color4;
  15758. /**
  15759. * The color change of the particle per step.
  15760. */
  15761. colorStep: Color4;
  15762. /**
  15763. * Defines how long will the life of the particle be.
  15764. */
  15765. lifeTime: number;
  15766. /**
  15767. * The current age of the particle.
  15768. */
  15769. age: number;
  15770. /**
  15771. * The current size of the particle.
  15772. */
  15773. size: number;
  15774. /**
  15775. * The current scale of the particle.
  15776. */
  15777. scale: Vector2;
  15778. /**
  15779. * The current angle of the particle.
  15780. */
  15781. angle: number;
  15782. /**
  15783. * Defines how fast is the angle changing.
  15784. */
  15785. angularSpeed: number;
  15786. /**
  15787. * Defines the cell index used by the particle to be rendered from a sprite.
  15788. */
  15789. cellIndex: number;
  15790. /**
  15791. * The information required to support color remapping
  15792. */
  15793. remapData: Vector4;
  15794. /** @hidden */
  15795. _randomCellOffset?: number;
  15796. /** @hidden */
  15797. _initialDirection: Nullable<Vector3>;
  15798. /** @hidden */
  15799. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15800. /** @hidden */
  15801. _initialStartSpriteCellID: number;
  15802. /** @hidden */
  15803. _initialEndSpriteCellID: number;
  15804. /** @hidden */
  15805. _currentColorGradient: Nullable<ColorGradient>;
  15806. /** @hidden */
  15807. _currentColor1: Color4;
  15808. /** @hidden */
  15809. _currentColor2: Color4;
  15810. /** @hidden */
  15811. _currentSizeGradient: Nullable<FactorGradient>;
  15812. /** @hidden */
  15813. _currentSize1: number;
  15814. /** @hidden */
  15815. _currentSize2: number;
  15816. /** @hidden */
  15817. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15818. /** @hidden */
  15819. _currentAngularSpeed1: number;
  15820. /** @hidden */
  15821. _currentAngularSpeed2: number;
  15822. /** @hidden */
  15823. _currentVelocityGradient: Nullable<FactorGradient>;
  15824. /** @hidden */
  15825. _currentVelocity1: number;
  15826. /** @hidden */
  15827. _currentVelocity2: number;
  15828. /** @hidden */
  15829. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15830. /** @hidden */
  15831. _currentLimitVelocity1: number;
  15832. /** @hidden */
  15833. _currentLimitVelocity2: number;
  15834. /** @hidden */
  15835. _currentDragGradient: Nullable<FactorGradient>;
  15836. /** @hidden */
  15837. _currentDrag1: number;
  15838. /** @hidden */
  15839. _currentDrag2: number;
  15840. /** @hidden */
  15841. _randomNoiseCoordinates1: Vector3;
  15842. /** @hidden */
  15843. _randomNoiseCoordinates2: Vector3;
  15844. /**
  15845. * Creates a new instance Particle
  15846. * @param particleSystem the particle system the particle belongs to
  15847. */
  15848. constructor(
  15849. /**
  15850. * The particle system the particle belongs to.
  15851. */
  15852. particleSystem: ParticleSystem);
  15853. private updateCellInfoFromSystem;
  15854. /**
  15855. * Defines how the sprite cell index is updated for the particle
  15856. */
  15857. updateCellIndex(): void;
  15858. /** @hidden */
  15859. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15860. /** @hidden */
  15861. _inheritParticleInfoToSubEmitters(): void;
  15862. /** @hidden */
  15863. _reset(): void;
  15864. /**
  15865. * Copy the properties of particle to another one.
  15866. * @param other the particle to copy the information to.
  15867. */
  15868. copyTo(other: Particle): void;
  15869. }
  15870. }
  15871. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15872. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15873. import { Effect } from "babylonjs/Materials/effect";
  15874. import { Particle } from "babylonjs/Particles/particle";
  15875. /**
  15876. * Particle emitter represents a volume emitting particles.
  15877. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15878. */
  15879. export interface IParticleEmitterType {
  15880. /**
  15881. * Called by the particle System when the direction is computed for the created particle.
  15882. * @param worldMatrix is the world matrix of the particle system
  15883. * @param directionToUpdate is the direction vector to update with the result
  15884. * @param particle is the particle we are computed the direction for
  15885. */
  15886. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15887. /**
  15888. * Called by the particle System when the position is computed for the created particle.
  15889. * @param worldMatrix is the world matrix of the particle system
  15890. * @param positionToUpdate is the position vector to update with the result
  15891. * @param particle is the particle we are computed the position for
  15892. */
  15893. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15894. /**
  15895. * Clones the current emitter and returns a copy of it
  15896. * @returns the new emitter
  15897. */
  15898. clone(): IParticleEmitterType;
  15899. /**
  15900. * Called by the GPUParticleSystem to setup the update shader
  15901. * @param effect defines the update shader
  15902. */
  15903. applyToShader(effect: Effect): void;
  15904. /**
  15905. * Returns a string to use to update the GPU particles update shader
  15906. * @returns the effect defines string
  15907. */
  15908. getEffectDefines(): string;
  15909. /**
  15910. * Returns a string representing the class name
  15911. * @returns a string containing the class name
  15912. */
  15913. getClassName(): string;
  15914. /**
  15915. * Serializes the particle system to a JSON object.
  15916. * @returns the JSON object
  15917. */
  15918. serialize(): any;
  15919. /**
  15920. * Parse properties from a JSON object
  15921. * @param serializationObject defines the JSON object
  15922. */
  15923. parse(serializationObject: any): void;
  15924. }
  15925. }
  15926. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15927. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15928. import { Effect } from "babylonjs/Materials/effect";
  15929. import { Particle } from "babylonjs/Particles/particle";
  15930. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15931. /**
  15932. * Particle emitter emitting particles from the inside of a box.
  15933. * It emits the particles randomly between 2 given directions.
  15934. */
  15935. export class BoxParticleEmitter implements IParticleEmitterType {
  15936. /**
  15937. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15938. */
  15939. direction1: Vector3;
  15940. /**
  15941. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15942. */
  15943. direction2: Vector3;
  15944. /**
  15945. * 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.
  15946. */
  15947. minEmitBox: Vector3;
  15948. /**
  15949. * 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.
  15950. */
  15951. maxEmitBox: Vector3;
  15952. /**
  15953. * Creates a new instance BoxParticleEmitter
  15954. */
  15955. constructor();
  15956. /**
  15957. * Called by the particle System when the direction is computed for the created particle.
  15958. * @param worldMatrix is the world matrix of the particle system
  15959. * @param directionToUpdate is the direction vector to update with the result
  15960. * @param particle is the particle we are computed the direction for
  15961. */
  15962. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15963. /**
  15964. * Called by the particle System when the position is computed for the created particle.
  15965. * @param worldMatrix is the world matrix of the particle system
  15966. * @param positionToUpdate is the position vector to update with the result
  15967. * @param particle is the particle we are computed the position for
  15968. */
  15969. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15970. /**
  15971. * Clones the current emitter and returns a copy of it
  15972. * @returns the new emitter
  15973. */
  15974. clone(): BoxParticleEmitter;
  15975. /**
  15976. * Called by the GPUParticleSystem to setup the update shader
  15977. * @param effect defines the update shader
  15978. */
  15979. applyToShader(effect: Effect): void;
  15980. /**
  15981. * Returns a string to use to update the GPU particles update shader
  15982. * @returns a string containng the defines string
  15983. */
  15984. getEffectDefines(): string;
  15985. /**
  15986. * Returns the string "BoxParticleEmitter"
  15987. * @returns a string containing the class name
  15988. */
  15989. getClassName(): string;
  15990. /**
  15991. * Serializes the particle system to a JSON object.
  15992. * @returns the JSON object
  15993. */
  15994. serialize(): any;
  15995. /**
  15996. * Parse properties from a JSON object
  15997. * @param serializationObject defines the JSON object
  15998. */
  15999. parse(serializationObject: any): void;
  16000. }
  16001. }
  16002. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16003. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16004. import { Effect } from "babylonjs/Materials/effect";
  16005. import { Particle } from "babylonjs/Particles/particle";
  16006. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16007. /**
  16008. * Particle emitter emitting particles from the inside of a cone.
  16009. * It emits the particles alongside the cone volume from the base to the particle.
  16010. * The emission direction might be randomized.
  16011. */
  16012. export class ConeParticleEmitter implements IParticleEmitterType {
  16013. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16014. directionRandomizer: number;
  16015. private _radius;
  16016. private _angle;
  16017. private _height;
  16018. /**
  16019. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16020. */
  16021. radiusRange: number;
  16022. /**
  16023. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16024. */
  16025. heightRange: number;
  16026. /**
  16027. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16028. */
  16029. emitFromSpawnPointOnly: boolean;
  16030. /**
  16031. * Gets or sets the radius of the emission cone
  16032. */
  16033. radius: number;
  16034. /**
  16035. * Gets or sets the angle of the emission cone
  16036. */
  16037. angle: number;
  16038. private _buildHeight;
  16039. /**
  16040. * Creates a new instance ConeParticleEmitter
  16041. * @param radius the radius of the emission cone (1 by default)
  16042. * @param angle the cone base angle (PI by default)
  16043. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16044. */
  16045. constructor(radius?: number, angle?: number,
  16046. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16047. directionRandomizer?: number);
  16048. /**
  16049. * Called by the particle System when the direction is computed for the created particle.
  16050. * @param worldMatrix is the world matrix of the particle system
  16051. * @param directionToUpdate is the direction vector to update with the result
  16052. * @param particle is the particle we are computed the direction for
  16053. */
  16054. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16055. /**
  16056. * Called by the particle System when the position is computed for the created particle.
  16057. * @param worldMatrix is the world matrix of the particle system
  16058. * @param positionToUpdate is the position vector to update with the result
  16059. * @param particle is the particle we are computed the position for
  16060. */
  16061. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16062. /**
  16063. * Clones the current emitter and returns a copy of it
  16064. * @returns the new emitter
  16065. */
  16066. clone(): ConeParticleEmitter;
  16067. /**
  16068. * Called by the GPUParticleSystem to setup the update shader
  16069. * @param effect defines the update shader
  16070. */
  16071. applyToShader(effect: Effect): void;
  16072. /**
  16073. * Returns a string to use to update the GPU particles update shader
  16074. * @returns a string containng the defines string
  16075. */
  16076. getEffectDefines(): string;
  16077. /**
  16078. * Returns the string "ConeParticleEmitter"
  16079. * @returns a string containing the class name
  16080. */
  16081. getClassName(): string;
  16082. /**
  16083. * Serializes the particle system to a JSON object.
  16084. * @returns the JSON object
  16085. */
  16086. serialize(): any;
  16087. /**
  16088. * Parse properties from a JSON object
  16089. * @param serializationObject defines the JSON object
  16090. */
  16091. parse(serializationObject: any): void;
  16092. }
  16093. }
  16094. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16095. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16096. import { Effect } from "babylonjs/Materials/effect";
  16097. import { Particle } from "babylonjs/Particles/particle";
  16098. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16099. /**
  16100. * Particle emitter emitting particles from the inside of a cylinder.
  16101. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16102. */
  16103. export class CylinderParticleEmitter implements IParticleEmitterType {
  16104. /**
  16105. * The radius of the emission cylinder.
  16106. */
  16107. radius: number;
  16108. /**
  16109. * The height of the emission cylinder.
  16110. */
  16111. height: number;
  16112. /**
  16113. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16114. */
  16115. radiusRange: number;
  16116. /**
  16117. * How much to randomize the particle direction [0-1].
  16118. */
  16119. directionRandomizer: number;
  16120. /**
  16121. * Creates a new instance CylinderParticleEmitter
  16122. * @param radius the radius of the emission cylinder (1 by default)
  16123. * @param height the height of the emission cylinder (1 by default)
  16124. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16125. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16126. */
  16127. constructor(
  16128. /**
  16129. * The radius of the emission cylinder.
  16130. */
  16131. radius?: number,
  16132. /**
  16133. * The height of the emission cylinder.
  16134. */
  16135. height?: number,
  16136. /**
  16137. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16138. */
  16139. radiusRange?: number,
  16140. /**
  16141. * How much to randomize the particle direction [0-1].
  16142. */
  16143. directionRandomizer?: number);
  16144. /**
  16145. * Called by the particle System when the direction is computed for the created particle.
  16146. * @param worldMatrix is the world matrix of the particle system
  16147. * @param directionToUpdate is the direction vector to update with the result
  16148. * @param particle is the particle we are computed the direction for
  16149. */
  16150. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16151. /**
  16152. * Called by the particle System when the position is computed for the created particle.
  16153. * @param worldMatrix is the world matrix of the particle system
  16154. * @param positionToUpdate is the position vector to update with the result
  16155. * @param particle is the particle we are computed the position for
  16156. */
  16157. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16158. /**
  16159. * Clones the current emitter and returns a copy of it
  16160. * @returns the new emitter
  16161. */
  16162. clone(): CylinderParticleEmitter;
  16163. /**
  16164. * Called by the GPUParticleSystem to setup the update shader
  16165. * @param effect defines the update shader
  16166. */
  16167. applyToShader(effect: Effect): void;
  16168. /**
  16169. * Returns a string to use to update the GPU particles update shader
  16170. * @returns a string containng the defines string
  16171. */
  16172. getEffectDefines(): string;
  16173. /**
  16174. * Returns the string "CylinderParticleEmitter"
  16175. * @returns a string containing the class name
  16176. */
  16177. getClassName(): string;
  16178. /**
  16179. * Serializes the particle system to a JSON object.
  16180. * @returns the JSON object
  16181. */
  16182. serialize(): any;
  16183. /**
  16184. * Parse properties from a JSON object
  16185. * @param serializationObject defines the JSON object
  16186. */
  16187. parse(serializationObject: any): void;
  16188. }
  16189. /**
  16190. * Particle emitter emitting particles from the inside of a cylinder.
  16191. * It emits the particles randomly between two vectors.
  16192. */
  16193. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16194. /**
  16195. * The min limit of the emission direction.
  16196. */
  16197. direction1: Vector3;
  16198. /**
  16199. * The max limit of the emission direction.
  16200. */
  16201. direction2: Vector3;
  16202. /**
  16203. * Creates a new instance CylinderDirectedParticleEmitter
  16204. * @param radius the radius of the emission cylinder (1 by default)
  16205. * @param height the height of the emission cylinder (1 by default)
  16206. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16207. * @param direction1 the min limit of the emission direction (up vector by default)
  16208. * @param direction2 the max limit of the emission direction (up vector by default)
  16209. */
  16210. constructor(radius?: number, height?: number, radiusRange?: number,
  16211. /**
  16212. * The min limit of the emission direction.
  16213. */
  16214. direction1?: Vector3,
  16215. /**
  16216. * The max limit of the emission direction.
  16217. */
  16218. direction2?: Vector3);
  16219. /**
  16220. * Called by the particle System when the direction is computed for the created particle.
  16221. * @param worldMatrix is the world matrix of the particle system
  16222. * @param directionToUpdate is the direction vector to update with the result
  16223. * @param particle is the particle we are computed the direction for
  16224. */
  16225. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16226. /**
  16227. * Clones the current emitter and returns a copy of it
  16228. * @returns the new emitter
  16229. */
  16230. clone(): CylinderDirectedParticleEmitter;
  16231. /**
  16232. * Called by the GPUParticleSystem to setup the update shader
  16233. * @param effect defines the update shader
  16234. */
  16235. applyToShader(effect: Effect): void;
  16236. /**
  16237. * Returns a string to use to update the GPU particles update shader
  16238. * @returns a string containng the defines string
  16239. */
  16240. getEffectDefines(): string;
  16241. /**
  16242. * Returns the string "CylinderDirectedParticleEmitter"
  16243. * @returns a string containing the class name
  16244. */
  16245. getClassName(): string;
  16246. /**
  16247. * Serializes the particle system to a JSON object.
  16248. * @returns the JSON object
  16249. */
  16250. serialize(): any;
  16251. /**
  16252. * Parse properties from a JSON object
  16253. * @param serializationObject defines the JSON object
  16254. */
  16255. parse(serializationObject: any): void;
  16256. }
  16257. }
  16258. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16259. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16260. import { Effect } from "babylonjs/Materials/effect";
  16261. import { Particle } from "babylonjs/Particles/particle";
  16262. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16263. /**
  16264. * Particle emitter emitting particles from the inside of a hemisphere.
  16265. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16266. */
  16267. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16268. /**
  16269. * The radius of the emission hemisphere.
  16270. */
  16271. radius: number;
  16272. /**
  16273. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16274. */
  16275. radiusRange: number;
  16276. /**
  16277. * How much to randomize the particle direction [0-1].
  16278. */
  16279. directionRandomizer: number;
  16280. /**
  16281. * Creates a new instance HemisphericParticleEmitter
  16282. * @param radius the radius of the emission hemisphere (1 by default)
  16283. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16284. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16285. */
  16286. constructor(
  16287. /**
  16288. * The radius of the emission hemisphere.
  16289. */
  16290. radius?: number,
  16291. /**
  16292. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16293. */
  16294. radiusRange?: number,
  16295. /**
  16296. * How much to randomize the particle direction [0-1].
  16297. */
  16298. directionRandomizer?: number);
  16299. /**
  16300. * Called by the particle System when the direction is computed for the created particle.
  16301. * @param worldMatrix is the world matrix of the particle system
  16302. * @param directionToUpdate is the direction vector to update with the result
  16303. * @param particle is the particle we are computed the direction for
  16304. */
  16305. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16306. /**
  16307. * Called by the particle System when the position is computed for the created particle.
  16308. * @param worldMatrix is the world matrix of the particle system
  16309. * @param positionToUpdate is the position vector to update with the result
  16310. * @param particle is the particle we are computed the position for
  16311. */
  16312. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16313. /**
  16314. * Clones the current emitter and returns a copy of it
  16315. * @returns the new emitter
  16316. */
  16317. clone(): HemisphericParticleEmitter;
  16318. /**
  16319. * Called by the GPUParticleSystem to setup the update shader
  16320. * @param effect defines the update shader
  16321. */
  16322. applyToShader(effect: Effect): void;
  16323. /**
  16324. * Returns a string to use to update the GPU particles update shader
  16325. * @returns a string containng the defines string
  16326. */
  16327. getEffectDefines(): string;
  16328. /**
  16329. * Returns the string "HemisphericParticleEmitter"
  16330. * @returns a string containing the class name
  16331. */
  16332. getClassName(): string;
  16333. /**
  16334. * Serializes the particle system to a JSON object.
  16335. * @returns the JSON object
  16336. */
  16337. serialize(): any;
  16338. /**
  16339. * Parse properties from a JSON object
  16340. * @param serializationObject defines the JSON object
  16341. */
  16342. parse(serializationObject: any): void;
  16343. }
  16344. }
  16345. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16346. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16347. import { Effect } from "babylonjs/Materials/effect";
  16348. import { Particle } from "babylonjs/Particles/particle";
  16349. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16350. /**
  16351. * Particle emitter emitting particles from a point.
  16352. * It emits the particles randomly between 2 given directions.
  16353. */
  16354. export class PointParticleEmitter implements IParticleEmitterType {
  16355. /**
  16356. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16357. */
  16358. direction1: Vector3;
  16359. /**
  16360. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16361. */
  16362. direction2: Vector3;
  16363. /**
  16364. * Creates a new instance PointParticleEmitter
  16365. */
  16366. constructor();
  16367. /**
  16368. * Called by the particle System when the direction is computed for the created particle.
  16369. * @param worldMatrix is the world matrix of the particle system
  16370. * @param directionToUpdate is the direction vector to update with the result
  16371. * @param particle is the particle we are computed the direction for
  16372. */
  16373. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16374. /**
  16375. * Called by the particle System when the position is computed for the created particle.
  16376. * @param worldMatrix is the world matrix of the particle system
  16377. * @param positionToUpdate is the position vector to update with the result
  16378. * @param particle is the particle we are computed the position for
  16379. */
  16380. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16381. /**
  16382. * Clones the current emitter and returns a copy of it
  16383. * @returns the new emitter
  16384. */
  16385. clone(): PointParticleEmitter;
  16386. /**
  16387. * Called by the GPUParticleSystem to setup the update shader
  16388. * @param effect defines the update shader
  16389. */
  16390. applyToShader(effect: Effect): void;
  16391. /**
  16392. * Returns a string to use to update the GPU particles update shader
  16393. * @returns a string containng the defines string
  16394. */
  16395. getEffectDefines(): string;
  16396. /**
  16397. * Returns the string "PointParticleEmitter"
  16398. * @returns a string containing the class name
  16399. */
  16400. getClassName(): string;
  16401. /**
  16402. * Serializes the particle system to a JSON object.
  16403. * @returns the JSON object
  16404. */
  16405. serialize(): any;
  16406. /**
  16407. * Parse properties from a JSON object
  16408. * @param serializationObject defines the JSON object
  16409. */
  16410. parse(serializationObject: any): void;
  16411. }
  16412. }
  16413. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16414. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16415. import { Effect } from "babylonjs/Materials/effect";
  16416. import { Particle } from "babylonjs/Particles/particle";
  16417. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16418. /**
  16419. * Particle emitter emitting particles from the inside of a sphere.
  16420. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16421. */
  16422. export class SphereParticleEmitter implements IParticleEmitterType {
  16423. /**
  16424. * The radius of the emission sphere.
  16425. */
  16426. radius: number;
  16427. /**
  16428. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16429. */
  16430. radiusRange: number;
  16431. /**
  16432. * How much to randomize the particle direction [0-1].
  16433. */
  16434. directionRandomizer: number;
  16435. /**
  16436. * Creates a new instance SphereParticleEmitter
  16437. * @param radius the radius of the emission sphere (1 by default)
  16438. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16439. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16440. */
  16441. constructor(
  16442. /**
  16443. * The radius of the emission sphere.
  16444. */
  16445. radius?: number,
  16446. /**
  16447. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16448. */
  16449. radiusRange?: number,
  16450. /**
  16451. * How much to randomize the particle direction [0-1].
  16452. */
  16453. directionRandomizer?: number);
  16454. /**
  16455. * Called by the particle System when the direction is computed for the created particle.
  16456. * @param worldMatrix is the world matrix of the particle system
  16457. * @param directionToUpdate is the direction vector to update with the result
  16458. * @param particle is the particle we are computed the direction for
  16459. */
  16460. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16461. /**
  16462. * Called by the particle System when the position is computed for the created particle.
  16463. * @param worldMatrix is the world matrix of the particle system
  16464. * @param positionToUpdate is the position vector to update with the result
  16465. * @param particle is the particle we are computed the position for
  16466. */
  16467. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16468. /**
  16469. * Clones the current emitter and returns a copy of it
  16470. * @returns the new emitter
  16471. */
  16472. clone(): SphereParticleEmitter;
  16473. /**
  16474. * Called by the GPUParticleSystem to setup the update shader
  16475. * @param effect defines the update shader
  16476. */
  16477. applyToShader(effect: Effect): void;
  16478. /**
  16479. * Returns a string to use to update the GPU particles update shader
  16480. * @returns a string containng the defines string
  16481. */
  16482. getEffectDefines(): string;
  16483. /**
  16484. * Returns the string "SphereParticleEmitter"
  16485. * @returns a string containing the class name
  16486. */
  16487. getClassName(): string;
  16488. /**
  16489. * Serializes the particle system to a JSON object.
  16490. * @returns the JSON object
  16491. */
  16492. serialize(): any;
  16493. /**
  16494. * Parse properties from a JSON object
  16495. * @param serializationObject defines the JSON object
  16496. */
  16497. parse(serializationObject: any): void;
  16498. }
  16499. /**
  16500. * Particle emitter emitting particles from the inside of a sphere.
  16501. * It emits the particles randomly between two vectors.
  16502. */
  16503. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16504. /**
  16505. * The min limit of the emission direction.
  16506. */
  16507. direction1: Vector3;
  16508. /**
  16509. * The max limit of the emission direction.
  16510. */
  16511. direction2: Vector3;
  16512. /**
  16513. * Creates a new instance SphereDirectedParticleEmitter
  16514. * @param radius the radius of the emission sphere (1 by default)
  16515. * @param direction1 the min limit of the emission direction (up vector by default)
  16516. * @param direction2 the max limit of the emission direction (up vector by default)
  16517. */
  16518. constructor(radius?: number,
  16519. /**
  16520. * The min limit of the emission direction.
  16521. */
  16522. direction1?: Vector3,
  16523. /**
  16524. * The max limit of the emission direction.
  16525. */
  16526. direction2?: Vector3);
  16527. /**
  16528. * Called by the particle System when the direction is computed for the created particle.
  16529. * @param worldMatrix is the world matrix of the particle system
  16530. * @param directionToUpdate is the direction vector to update with the result
  16531. * @param particle is the particle we are computed the direction for
  16532. */
  16533. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16534. /**
  16535. * Clones the current emitter and returns a copy of it
  16536. * @returns the new emitter
  16537. */
  16538. clone(): SphereDirectedParticleEmitter;
  16539. /**
  16540. * Called by the GPUParticleSystem to setup the update shader
  16541. * @param effect defines the update shader
  16542. */
  16543. applyToShader(effect: Effect): void;
  16544. /**
  16545. * Returns a string to use to update the GPU particles update shader
  16546. * @returns a string containng the defines string
  16547. */
  16548. getEffectDefines(): string;
  16549. /**
  16550. * Returns the string "SphereDirectedParticleEmitter"
  16551. * @returns a string containing the class name
  16552. */
  16553. getClassName(): string;
  16554. /**
  16555. * Serializes the particle system to a JSON object.
  16556. * @returns the JSON object
  16557. */
  16558. serialize(): any;
  16559. /**
  16560. * Parse properties from a JSON object
  16561. * @param serializationObject defines the JSON object
  16562. */
  16563. parse(serializationObject: any): void;
  16564. }
  16565. }
  16566. declare module "babylonjs/Particles/EmitterTypes/index" {
  16567. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16568. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16569. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16570. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16571. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16572. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16573. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16574. }
  16575. declare module "babylonjs/Particles/IParticleSystem" {
  16576. import { Nullable } from "babylonjs/types";
  16577. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16579. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16580. import { Texture } from "babylonjs/Materials/Textures/texture";
  16581. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16582. import { Scene } from "babylonjs/scene";
  16583. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16584. import { Animation } from "babylonjs/Animations/animation";
  16585. /**
  16586. * Interface representing a particle system in Babylon.js.
  16587. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16588. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16589. */
  16590. export interface IParticleSystem {
  16591. /**
  16592. * List of animations used by the particle system.
  16593. */
  16594. animations: Animation[];
  16595. /**
  16596. * The id of the Particle system.
  16597. */
  16598. id: string;
  16599. /**
  16600. * The name of the Particle system.
  16601. */
  16602. name: string;
  16603. /**
  16604. * The emitter represents the Mesh or position we are attaching the particle system to.
  16605. */
  16606. emitter: Nullable<AbstractMesh | Vector3>;
  16607. /**
  16608. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16609. */
  16610. isBillboardBased: boolean;
  16611. /**
  16612. * The rendering group used by the Particle system to chose when to render.
  16613. */
  16614. renderingGroupId: number;
  16615. /**
  16616. * The layer mask we are rendering the particles through.
  16617. */
  16618. layerMask: number;
  16619. /**
  16620. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16621. */
  16622. updateSpeed: number;
  16623. /**
  16624. * The amount of time the particle system is running (depends of the overall update speed).
  16625. */
  16626. targetStopDuration: number;
  16627. /**
  16628. * The texture used to render each particle. (this can be a spritesheet)
  16629. */
  16630. particleTexture: Nullable<Texture>;
  16631. /**
  16632. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16633. */
  16634. blendMode: number;
  16635. /**
  16636. * Minimum life time of emitting particles.
  16637. */
  16638. minLifeTime: number;
  16639. /**
  16640. * Maximum life time of emitting particles.
  16641. */
  16642. maxLifeTime: number;
  16643. /**
  16644. * Minimum Size of emitting particles.
  16645. */
  16646. minSize: number;
  16647. /**
  16648. * Maximum Size of emitting particles.
  16649. */
  16650. maxSize: number;
  16651. /**
  16652. * Minimum scale of emitting particles on X axis.
  16653. */
  16654. minScaleX: number;
  16655. /**
  16656. * Maximum scale of emitting particles on X axis.
  16657. */
  16658. maxScaleX: number;
  16659. /**
  16660. * Minimum scale of emitting particles on Y axis.
  16661. */
  16662. minScaleY: number;
  16663. /**
  16664. * Maximum scale of emitting particles on Y axis.
  16665. */
  16666. maxScaleY: number;
  16667. /**
  16668. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16669. */
  16670. color1: Color4;
  16671. /**
  16672. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16673. */
  16674. color2: Color4;
  16675. /**
  16676. * Color the particle will have at the end of its lifetime.
  16677. */
  16678. colorDead: Color4;
  16679. /**
  16680. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16681. */
  16682. emitRate: number;
  16683. /**
  16684. * You can use gravity if you want to give an orientation to your particles.
  16685. */
  16686. gravity: Vector3;
  16687. /**
  16688. * Minimum power of emitting particles.
  16689. */
  16690. minEmitPower: number;
  16691. /**
  16692. * Maximum power of emitting particles.
  16693. */
  16694. maxEmitPower: number;
  16695. /**
  16696. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16697. */
  16698. minAngularSpeed: number;
  16699. /**
  16700. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16701. */
  16702. maxAngularSpeed: number;
  16703. /**
  16704. * Gets or sets the minimal initial rotation in radians.
  16705. */
  16706. minInitialRotation: number;
  16707. /**
  16708. * Gets or sets the maximal initial rotation in radians.
  16709. */
  16710. maxInitialRotation: number;
  16711. /**
  16712. * The particle emitter type defines the emitter used by the particle system.
  16713. * It can be for example box, sphere, or cone...
  16714. */
  16715. particleEmitterType: Nullable<IParticleEmitterType>;
  16716. /**
  16717. * Defines the delay in milliseconds before starting the system (0 by default)
  16718. */
  16719. startDelay: number;
  16720. /**
  16721. * 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
  16722. */
  16723. preWarmCycles: number;
  16724. /**
  16725. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16726. */
  16727. preWarmStepOffset: number;
  16728. /**
  16729. * 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)
  16730. */
  16731. spriteCellChangeSpeed: number;
  16732. /**
  16733. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16734. */
  16735. startSpriteCellID: number;
  16736. /**
  16737. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16738. */
  16739. endSpriteCellID: number;
  16740. /**
  16741. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16742. */
  16743. spriteCellWidth: number;
  16744. /**
  16745. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16746. */
  16747. spriteCellHeight: number;
  16748. /**
  16749. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16750. */
  16751. spriteRandomStartCell: boolean;
  16752. /**
  16753. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16754. */
  16755. isAnimationSheetEnabled: boolean;
  16756. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16757. translationPivot: Vector2;
  16758. /**
  16759. * Gets or sets a texture used to add random noise to particle positions
  16760. */
  16761. noiseTexture: Nullable<BaseTexture>;
  16762. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16763. noiseStrength: Vector3;
  16764. /**
  16765. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16766. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16767. */
  16768. billboardMode: number;
  16769. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16770. limitVelocityDamping: number;
  16771. /**
  16772. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16773. */
  16774. beginAnimationOnStart: boolean;
  16775. /**
  16776. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16777. */
  16778. beginAnimationFrom: number;
  16779. /**
  16780. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16781. */
  16782. beginAnimationTo: number;
  16783. /**
  16784. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16785. */
  16786. beginAnimationLoop: boolean;
  16787. /**
  16788. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16789. */
  16790. disposeOnStop: boolean;
  16791. /**
  16792. * Gets the maximum number of particles active at the same time.
  16793. * @returns The max number of active particles.
  16794. */
  16795. getCapacity(): number;
  16796. /**
  16797. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16798. * @returns True if it has been started, otherwise false.
  16799. */
  16800. isStarted(): boolean;
  16801. /**
  16802. * Animates the particle system for this frame.
  16803. */
  16804. animate(): void;
  16805. /**
  16806. * Renders the particle system in its current state.
  16807. * @returns the current number of particles
  16808. */
  16809. render(): number;
  16810. /**
  16811. * Dispose the particle system and frees its associated resources.
  16812. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16813. */
  16814. dispose(disposeTexture?: boolean): void;
  16815. /**
  16816. * Clones the particle system.
  16817. * @param name The name of the cloned object
  16818. * @param newEmitter The new emitter to use
  16819. * @returns the cloned particle system
  16820. */
  16821. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16822. /**
  16823. * Serializes the particle system to a JSON object.
  16824. * @returns the JSON object
  16825. */
  16826. serialize(): any;
  16827. /**
  16828. * Rebuild the particle system
  16829. */
  16830. rebuild(): void;
  16831. /**
  16832. * Starts the particle system and begins to emit
  16833. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16834. */
  16835. start(delay?: number): void;
  16836. /**
  16837. * Stops the particle system.
  16838. */
  16839. stop(): void;
  16840. /**
  16841. * Remove all active particles
  16842. */
  16843. reset(): void;
  16844. /**
  16845. * Is this system ready to be used/rendered
  16846. * @return true if the system is ready
  16847. */
  16848. isReady(): boolean;
  16849. /**
  16850. * Adds a new color gradient
  16851. * @param gradient defines the gradient to use (between 0 and 1)
  16852. * @param color1 defines the color to affect to the specified gradient
  16853. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16854. * @returns the current particle system
  16855. */
  16856. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16857. /**
  16858. * Remove a specific color gradient
  16859. * @param gradient defines the gradient to remove
  16860. * @returns the current particle system
  16861. */
  16862. removeColorGradient(gradient: number): IParticleSystem;
  16863. /**
  16864. * Adds a new size gradient
  16865. * @param gradient defines the gradient to use (between 0 and 1)
  16866. * @param factor defines the size factor to affect to the specified gradient
  16867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16868. * @returns the current particle system
  16869. */
  16870. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16871. /**
  16872. * Remove a specific size gradient
  16873. * @param gradient defines the gradient to remove
  16874. * @returns the current particle system
  16875. */
  16876. removeSizeGradient(gradient: number): IParticleSystem;
  16877. /**
  16878. * Gets the current list of color gradients.
  16879. * You must use addColorGradient and removeColorGradient to udpate this list
  16880. * @returns the list of color gradients
  16881. */
  16882. getColorGradients(): Nullable<Array<ColorGradient>>;
  16883. /**
  16884. * Gets the current list of size gradients.
  16885. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16886. * @returns the list of size gradients
  16887. */
  16888. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16889. /**
  16890. * Gets the current list of angular speed gradients.
  16891. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16892. * @returns the list of angular speed gradients
  16893. */
  16894. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16895. /**
  16896. * Adds a new angular speed gradient
  16897. * @param gradient defines the gradient to use (between 0 and 1)
  16898. * @param factor defines the angular speed to affect to the specified gradient
  16899. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16900. * @returns the current particle system
  16901. */
  16902. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16903. /**
  16904. * Remove a specific angular speed gradient
  16905. * @param gradient defines the gradient to remove
  16906. * @returns the current particle system
  16907. */
  16908. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16909. /**
  16910. * Gets the current list of velocity gradients.
  16911. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16912. * @returns the list of velocity gradients
  16913. */
  16914. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16915. /**
  16916. * Adds a new velocity gradient
  16917. * @param gradient defines the gradient to use (between 0 and 1)
  16918. * @param factor defines the velocity to affect to the specified gradient
  16919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16920. * @returns the current particle system
  16921. */
  16922. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16923. /**
  16924. * Remove a specific velocity gradient
  16925. * @param gradient defines the gradient to remove
  16926. * @returns the current particle system
  16927. */
  16928. removeVelocityGradient(gradient: number): IParticleSystem;
  16929. /**
  16930. * Gets the current list of limit velocity gradients.
  16931. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16932. * @returns the list of limit velocity gradients
  16933. */
  16934. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16935. /**
  16936. * Adds a new limit velocity gradient
  16937. * @param gradient defines the gradient to use (between 0 and 1)
  16938. * @param factor defines the limit velocity to affect to the specified gradient
  16939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16940. * @returns the current particle system
  16941. */
  16942. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16943. /**
  16944. * Remove a specific limit velocity gradient
  16945. * @param gradient defines the gradient to remove
  16946. * @returns the current particle system
  16947. */
  16948. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16949. /**
  16950. * Adds a new drag gradient
  16951. * @param gradient defines the gradient to use (between 0 and 1)
  16952. * @param factor defines the drag to affect to the specified gradient
  16953. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16954. * @returns the current particle system
  16955. */
  16956. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16957. /**
  16958. * Remove a specific drag gradient
  16959. * @param gradient defines the gradient to remove
  16960. * @returns the current particle system
  16961. */
  16962. removeDragGradient(gradient: number): IParticleSystem;
  16963. /**
  16964. * Gets the current list of drag gradients.
  16965. * You must use addDragGradient and removeDragGradient to udpate this list
  16966. * @returns the list of drag gradients
  16967. */
  16968. getDragGradients(): Nullable<Array<FactorGradient>>;
  16969. /**
  16970. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16971. * @param gradient defines the gradient to use (between 0 and 1)
  16972. * @param factor defines the emit rate to affect to the specified gradient
  16973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16974. * @returns the current particle system
  16975. */
  16976. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16977. /**
  16978. * Remove a specific emit rate gradient
  16979. * @param gradient defines the gradient to remove
  16980. * @returns the current particle system
  16981. */
  16982. removeEmitRateGradient(gradient: number): IParticleSystem;
  16983. /**
  16984. * Gets the current list of emit rate gradients.
  16985. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16986. * @returns the list of emit rate gradients
  16987. */
  16988. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16989. /**
  16990. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16991. * @param gradient defines the gradient to use (between 0 and 1)
  16992. * @param factor defines the start size to affect to the specified gradient
  16993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16994. * @returns the current particle system
  16995. */
  16996. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16997. /**
  16998. * Remove a specific start size gradient
  16999. * @param gradient defines the gradient to remove
  17000. * @returns the current particle system
  17001. */
  17002. removeStartSizeGradient(gradient: number): IParticleSystem;
  17003. /**
  17004. * Gets the current list of start size gradients.
  17005. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17006. * @returns the list of start size gradients
  17007. */
  17008. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17009. /**
  17010. * Adds a new life time gradient
  17011. * @param gradient defines the gradient to use (between 0 and 1)
  17012. * @param factor defines the life time factor to affect to the specified gradient
  17013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17014. * @returns the current particle system
  17015. */
  17016. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17017. /**
  17018. * Remove a specific life time gradient
  17019. * @param gradient defines the gradient to remove
  17020. * @returns the current particle system
  17021. */
  17022. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17023. /**
  17024. * Gets the current list of life time gradients.
  17025. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17026. * @returns the list of life time gradients
  17027. */
  17028. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17029. /**
  17030. * Gets the current list of color gradients.
  17031. * You must use addColorGradient and removeColorGradient to udpate this list
  17032. * @returns the list of color gradients
  17033. */
  17034. getColorGradients(): Nullable<Array<ColorGradient>>;
  17035. /**
  17036. * Adds a new ramp gradient used to remap particle colors
  17037. * @param gradient defines the gradient to use (between 0 and 1)
  17038. * @param color defines the color to affect to the specified gradient
  17039. * @returns the current particle system
  17040. */
  17041. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17042. /**
  17043. * Gets the current list of ramp gradients.
  17044. * You must use addRampGradient and removeRampGradient to udpate this list
  17045. * @returns the list of ramp gradients
  17046. */
  17047. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17048. /** Gets or sets a boolean indicating that ramp gradients must be used
  17049. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17050. */
  17051. useRampGradients: boolean;
  17052. /**
  17053. * Adds a new color remap gradient
  17054. * @param gradient defines the gradient to use (between 0 and 1)
  17055. * @param min defines the color remap minimal range
  17056. * @param max defines the color remap maximal range
  17057. * @returns the current particle system
  17058. */
  17059. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17060. /**
  17061. * Gets the current list of color remap gradients.
  17062. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17063. * @returns the list of color remap gradients
  17064. */
  17065. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17066. /**
  17067. * Adds a new alpha remap gradient
  17068. * @param gradient defines the gradient to use (between 0 and 1)
  17069. * @param min defines the alpha remap minimal range
  17070. * @param max defines the alpha remap maximal range
  17071. * @returns the current particle system
  17072. */
  17073. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17074. /**
  17075. * Gets the current list of alpha remap gradients.
  17076. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17077. * @returns the list of alpha remap gradients
  17078. */
  17079. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17080. /**
  17081. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17082. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17083. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17084. * @returns the emitter
  17085. */
  17086. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17087. /**
  17088. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17089. * @param radius The radius of the hemisphere to emit from
  17090. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17091. * @returns the emitter
  17092. */
  17093. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17094. /**
  17095. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17096. * @param radius The radius of the sphere to emit from
  17097. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17098. * @returns the emitter
  17099. */
  17100. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17101. /**
  17102. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17103. * @param radius The radius of the sphere to emit from
  17104. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17105. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17106. * @returns the emitter
  17107. */
  17108. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17109. /**
  17110. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17111. * @param radius The radius of the emission cylinder
  17112. * @param height The height of the emission cylinder
  17113. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17114. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17115. * @returns the emitter
  17116. */
  17117. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17118. /**
  17119. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17120. * @param radius The radius of the cylinder to emit from
  17121. * @param height The height of the emission cylinder
  17122. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17123. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17124. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17125. * @returns the emitter
  17126. */
  17127. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17128. /**
  17129. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17130. * @param radius The radius of the cone to emit from
  17131. * @param angle The base angle of the cone
  17132. * @returns the emitter
  17133. */
  17134. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17135. /**
  17136. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17137. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17138. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17139. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17140. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17141. * @returns the emitter
  17142. */
  17143. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17144. /**
  17145. * Get hosting scene
  17146. * @returns the scene
  17147. */
  17148. getScene(): Scene;
  17149. }
  17150. }
  17151. declare module "babylonjs/Meshes/instancedMesh" {
  17152. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  17153. import { Vector3, Matrix } from "babylonjs/Maths/math";
  17154. import { Camera } from "babylonjs/Cameras/camera";
  17155. import { Node } from "babylonjs/node";
  17156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17157. import { Mesh } from "babylonjs/Meshes/mesh";
  17158. import { Material } from "babylonjs/Materials/material";
  17159. import { Skeleton } from "babylonjs/Bones/skeleton";
  17160. import { Light } from "babylonjs/Lights/light";
  17161. /**
  17162. * Creates an instance based on a source mesh.
  17163. */
  17164. export class InstancedMesh extends AbstractMesh {
  17165. private _sourceMesh;
  17166. private _currentLOD;
  17167. /** @hidden */
  17168. _indexInSourceMeshInstanceArray: number;
  17169. constructor(name: string, source: Mesh);
  17170. /**
  17171. * Returns the string "InstancedMesh".
  17172. */
  17173. getClassName(): string;
  17174. /** Gets the list of lights affecting that mesh */
  17175. readonly lightSources: Light[];
  17176. _resyncLightSources(): void;
  17177. _resyncLighSource(light: Light): void;
  17178. _removeLightSource(light: Light): void;
  17179. /**
  17180. * If the source mesh receives shadows
  17181. */
  17182. readonly receiveShadows: boolean;
  17183. /**
  17184. * The material of the source mesh
  17185. */
  17186. readonly material: Nullable<Material>;
  17187. /**
  17188. * Visibility of the source mesh
  17189. */
  17190. readonly visibility: number;
  17191. /**
  17192. * Skeleton of the source mesh
  17193. */
  17194. readonly skeleton: Nullable<Skeleton>;
  17195. /**
  17196. * Rendering ground id of the source mesh
  17197. */
  17198. renderingGroupId: number;
  17199. /**
  17200. * Returns the total number of vertices (integer).
  17201. */
  17202. getTotalVertices(): number;
  17203. /**
  17204. * Returns a positive integer : the total number of indices in this mesh geometry.
  17205. * @returns the numner of indices or zero if the mesh has no geometry.
  17206. */
  17207. getTotalIndices(): number;
  17208. /**
  17209. * The source mesh of the instance
  17210. */
  17211. readonly sourceMesh: Mesh;
  17212. /**
  17213. * Is this node ready to be used/rendered
  17214. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17215. * @return {boolean} is it ready
  17216. */
  17217. isReady(completeCheck?: boolean): boolean;
  17218. /**
  17219. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17220. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  17221. * @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.
  17222. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17223. */
  17224. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17225. /**
  17226. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17227. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17228. * The `data` are either a numeric array either a Float32Array.
  17229. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17230. * 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).
  17231. * Note that a new underlying VertexBuffer object is created each call.
  17232. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17233. *
  17234. * Possible `kind` values :
  17235. * - VertexBuffer.PositionKind
  17236. * - VertexBuffer.UVKind
  17237. * - VertexBuffer.UV2Kind
  17238. * - VertexBuffer.UV3Kind
  17239. * - VertexBuffer.UV4Kind
  17240. * - VertexBuffer.UV5Kind
  17241. * - VertexBuffer.UV6Kind
  17242. * - VertexBuffer.ColorKind
  17243. * - VertexBuffer.MatricesIndicesKind
  17244. * - VertexBuffer.MatricesIndicesExtraKind
  17245. * - VertexBuffer.MatricesWeightsKind
  17246. * - VertexBuffer.MatricesWeightsExtraKind
  17247. *
  17248. * Returns the Mesh.
  17249. */
  17250. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17251. /**
  17252. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17253. * If the mesh has no geometry, it is simply returned as it is.
  17254. * The `data` are either a numeric array either a Float32Array.
  17255. * No new underlying VertexBuffer object is created.
  17256. * 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.
  17257. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17258. *
  17259. * Possible `kind` values :
  17260. * - VertexBuffer.PositionKind
  17261. * - VertexBuffer.UVKind
  17262. * - VertexBuffer.UV2Kind
  17263. * - VertexBuffer.UV3Kind
  17264. * - VertexBuffer.UV4Kind
  17265. * - VertexBuffer.UV5Kind
  17266. * - VertexBuffer.UV6Kind
  17267. * - VertexBuffer.ColorKind
  17268. * - VertexBuffer.MatricesIndicesKind
  17269. * - VertexBuffer.MatricesIndicesExtraKind
  17270. * - VertexBuffer.MatricesWeightsKind
  17271. * - VertexBuffer.MatricesWeightsExtraKind
  17272. *
  17273. * Returns the Mesh.
  17274. */
  17275. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17276. /**
  17277. * Sets the mesh indices.
  17278. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17279. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17280. * This method creates a new index buffer each call.
  17281. * Returns the Mesh.
  17282. */
  17283. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17284. /**
  17285. * Boolean : True if the mesh owns the requested kind of data.
  17286. */
  17287. isVerticesDataPresent(kind: string): boolean;
  17288. /**
  17289. * Returns an array of indices (IndicesArray).
  17290. */
  17291. getIndices(): Nullable<IndicesArray>;
  17292. readonly _positions: Nullable<Vector3[]>;
  17293. /**
  17294. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17295. * This means the mesh underlying bounding box and sphere are recomputed.
  17296. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17297. * @returns the current mesh
  17298. */
  17299. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17300. /** @hidden */
  17301. _preActivate(): InstancedMesh;
  17302. /** @hidden */
  17303. _activate(renderId: number, intermediateRendering: boolean): boolean;
  17304. /** @hidden */
  17305. _postActivate(): void;
  17306. getWorldMatrix(): Matrix;
  17307. readonly isAnInstance: boolean;
  17308. /**
  17309. * Returns the current associated LOD AbstractMesh.
  17310. */
  17311. getLOD(camera: Camera): AbstractMesh;
  17312. /** @hidden */
  17313. _syncSubMeshes(): InstancedMesh;
  17314. /** @hidden */
  17315. _generatePointsArray(): boolean;
  17316. /**
  17317. * Creates a new InstancedMesh from the current mesh.
  17318. * - name (string) : the cloned mesh name
  17319. * - newParent (optional Node) : the optional Node to parent the clone to.
  17320. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17321. *
  17322. * Returns the clone.
  17323. */
  17324. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17325. /**
  17326. * Disposes the InstancedMesh.
  17327. * Returns nothing.
  17328. */
  17329. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17330. }
  17331. }
  17332. declare module "babylonjs/Materials/shaderMaterial" {
  17333. import { Scene } from "babylonjs/scene";
  17334. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17336. import { Mesh } from "babylonjs/Meshes/mesh";
  17337. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17339. import { Texture } from "babylonjs/Materials/Textures/texture";
  17340. import { Material } from "babylonjs/Materials/material";
  17341. /**
  17342. * Defines the options associated with the creation of a shader material.
  17343. */
  17344. export interface IShaderMaterialOptions {
  17345. /**
  17346. * Does the material work in alpha blend mode
  17347. */
  17348. needAlphaBlending: boolean;
  17349. /**
  17350. * Does the material work in alpha test mode
  17351. */
  17352. needAlphaTesting: boolean;
  17353. /**
  17354. * The list of attribute names used in the shader
  17355. */
  17356. attributes: string[];
  17357. /**
  17358. * The list of unifrom names used in the shader
  17359. */
  17360. uniforms: string[];
  17361. /**
  17362. * The list of UBO names used in the shader
  17363. */
  17364. uniformBuffers: string[];
  17365. /**
  17366. * The list of sampler names used in the shader
  17367. */
  17368. samplers: string[];
  17369. /**
  17370. * The list of defines used in the shader
  17371. */
  17372. defines: string[];
  17373. }
  17374. /**
  17375. * 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.
  17376. *
  17377. * This returned material effects how the mesh will look based on the code in the shaders.
  17378. *
  17379. * @see http://doc.babylonjs.com/how_to/shader_material
  17380. */
  17381. export class ShaderMaterial extends Material {
  17382. private _shaderPath;
  17383. private _options;
  17384. private _textures;
  17385. private _textureArrays;
  17386. private _floats;
  17387. private _ints;
  17388. private _floatsArrays;
  17389. private _colors3;
  17390. private _colors3Arrays;
  17391. private _colors4;
  17392. private _vectors2;
  17393. private _vectors3;
  17394. private _vectors4;
  17395. private _matrices;
  17396. private _matrices3x3;
  17397. private _matrices2x2;
  17398. private _vectors2Arrays;
  17399. private _vectors3Arrays;
  17400. private _cachedWorldViewMatrix;
  17401. private _renderId;
  17402. /**
  17403. * Instantiate a new shader material.
  17404. * 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.
  17405. * This returned material effects how the mesh will look based on the code in the shaders.
  17406. * @see http://doc.babylonjs.com/how_to/shader_material
  17407. * @param name Define the name of the material in the scene
  17408. * @param scene Define the scene the material belongs to
  17409. * @param shaderPath Defines the route to the shader code in one of three ways:
  17410. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17411. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17412. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17413. * @param options Define the options used to create the shader
  17414. */
  17415. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17416. /**
  17417. * Gets the options used to compile the shader.
  17418. * They can be modified to trigger a new compilation
  17419. */
  17420. readonly options: IShaderMaterialOptions;
  17421. /**
  17422. * Gets the current class name of the material e.g. "ShaderMaterial"
  17423. * Mainly use in serialization.
  17424. * @returns the class name
  17425. */
  17426. getClassName(): string;
  17427. /**
  17428. * Specifies if the material will require alpha blending
  17429. * @returns a boolean specifying if alpha blending is needed
  17430. */
  17431. needAlphaBlending(): boolean;
  17432. /**
  17433. * Specifies if this material should be rendered in alpha test mode
  17434. * @returns a boolean specifying if an alpha test is needed.
  17435. */
  17436. needAlphaTesting(): boolean;
  17437. private _checkUniform;
  17438. /**
  17439. * Set a texture in the shader.
  17440. * @param name Define the name of the uniform samplers as defined in the shader
  17441. * @param texture Define the texture to bind to this sampler
  17442. * @return the material itself allowing "fluent" like uniform updates
  17443. */
  17444. setTexture(name: string, texture: Texture): ShaderMaterial;
  17445. /**
  17446. * Set a texture array in the shader.
  17447. * @param name Define the name of the uniform sampler array as defined in the shader
  17448. * @param textures Define the list of textures to bind to this sampler
  17449. * @return the material itself allowing "fluent" like uniform updates
  17450. */
  17451. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17452. /**
  17453. * Set a float in the shader.
  17454. * @param name Define the name of the uniform as defined in the shader
  17455. * @param value Define the value to give to the uniform
  17456. * @return the material itself allowing "fluent" like uniform updates
  17457. */
  17458. setFloat(name: string, value: number): ShaderMaterial;
  17459. /**
  17460. * Set a int in the shader.
  17461. * @param name Define the name of the uniform as defined in the shader
  17462. * @param value Define the value to give to the uniform
  17463. * @return the material itself allowing "fluent" like uniform updates
  17464. */
  17465. setInt(name: string, value: number): ShaderMaterial;
  17466. /**
  17467. * Set an array of floats in the shader.
  17468. * @param name Define the name of the uniform as defined in the shader
  17469. * @param value Define the value to give to the uniform
  17470. * @return the material itself allowing "fluent" like uniform updates
  17471. */
  17472. setFloats(name: string, value: number[]): ShaderMaterial;
  17473. /**
  17474. * Set a vec3 in the shader from a Color3.
  17475. * @param name Define the name of the uniform as defined in the shader
  17476. * @param value Define the value to give to the uniform
  17477. * @return the material itself allowing "fluent" like uniform updates
  17478. */
  17479. setColor3(name: string, value: Color3): ShaderMaterial;
  17480. /**
  17481. * Set a vec3 array in the shader from a Color3 array.
  17482. * @param name Define the name of the uniform as defined in the shader
  17483. * @param value Define the value to give to the uniform
  17484. * @return the material itself allowing "fluent" like uniform updates
  17485. */
  17486. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17487. /**
  17488. * Set a vec4 in the shader from a Color4.
  17489. * @param name Define the name of the uniform as defined in the shader
  17490. * @param value Define the value to give to the uniform
  17491. * @return the material itself allowing "fluent" like uniform updates
  17492. */
  17493. setColor4(name: string, value: Color4): ShaderMaterial;
  17494. /**
  17495. * Set a vec2 in the shader from a Vector2.
  17496. * @param name Define the name of the uniform as defined in the shader
  17497. * @param value Define the value to give to the uniform
  17498. * @return the material itself allowing "fluent" like uniform updates
  17499. */
  17500. setVector2(name: string, value: Vector2): ShaderMaterial;
  17501. /**
  17502. * Set a vec3 in the shader from a Vector3.
  17503. * @param name Define the name of the uniform as defined in the shader
  17504. * @param value Define the value to give to the uniform
  17505. * @return the material itself allowing "fluent" like uniform updates
  17506. */
  17507. setVector3(name: string, value: Vector3): ShaderMaterial;
  17508. /**
  17509. * Set a vec4 in the shader from a Vector4.
  17510. * @param name Define the name of the uniform as defined in the shader
  17511. * @param value Define the value to give to the uniform
  17512. * @return the material itself allowing "fluent" like uniform updates
  17513. */
  17514. setVector4(name: string, value: Vector4): ShaderMaterial;
  17515. /**
  17516. * Set a mat4 in the shader from a Matrix.
  17517. * @param name Define the name of the uniform as defined in the shader
  17518. * @param value Define the value to give to the uniform
  17519. * @return the material itself allowing "fluent" like uniform updates
  17520. */
  17521. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17522. /**
  17523. * Set a mat3 in the shader from a Float32Array.
  17524. * @param name Define the name of the uniform as defined in the shader
  17525. * @param value Define the value to give to the uniform
  17526. * @return the material itself allowing "fluent" like uniform updates
  17527. */
  17528. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17529. /**
  17530. * Set a mat2 in the shader from a Float32Array.
  17531. * @param name Define the name of the uniform as defined in the shader
  17532. * @param value Define the value to give to the uniform
  17533. * @return the material itself allowing "fluent" like uniform updates
  17534. */
  17535. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17536. /**
  17537. * Set a vec2 array in the shader from a number array.
  17538. * @param name Define the name of the uniform as defined in the shader
  17539. * @param value Define the value to give to the uniform
  17540. * @return the material itself allowing "fluent" like uniform updates
  17541. */
  17542. setArray2(name: string, value: number[]): ShaderMaterial;
  17543. /**
  17544. * Set a vec3 array in the shader from a number array.
  17545. * @param name Define the name of the uniform as defined in the shader
  17546. * @param value Define the value to give to the uniform
  17547. * @return the material itself allowing "fluent" like uniform updates
  17548. */
  17549. setArray3(name: string, value: number[]): ShaderMaterial;
  17550. private _checkCache;
  17551. /**
  17552. * Specifies that the submesh is ready to be used
  17553. * @param mesh defines the mesh to check
  17554. * @param subMesh defines which submesh to check
  17555. * @param useInstances specifies that instances should be used
  17556. * @returns a boolean indicating that the submesh is ready or not
  17557. */
  17558. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17559. /**
  17560. * Checks if the material is ready to render the requested mesh
  17561. * @param mesh Define the mesh to render
  17562. * @param useInstances Define whether or not the material is used with instances
  17563. * @returns true if ready, otherwise false
  17564. */
  17565. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17566. /**
  17567. * Binds the world matrix to the material
  17568. * @param world defines the world transformation matrix
  17569. */
  17570. bindOnlyWorldMatrix(world: Matrix): void;
  17571. /**
  17572. * Binds the material to the mesh
  17573. * @param world defines the world transformation matrix
  17574. * @param mesh defines the mesh to bind the material to
  17575. */
  17576. bind(world: Matrix, mesh?: Mesh): void;
  17577. /**
  17578. * Gets the active textures from the material
  17579. * @returns an array of textures
  17580. */
  17581. getActiveTextures(): BaseTexture[];
  17582. /**
  17583. * Specifies if the material uses a texture
  17584. * @param texture defines the texture to check against the material
  17585. * @returns a boolean specifying if the material uses the texture
  17586. */
  17587. hasTexture(texture: BaseTexture): boolean;
  17588. /**
  17589. * Makes a duplicate of the material, and gives it a new name
  17590. * @param name defines the new name for the duplicated material
  17591. * @returns the cloned material
  17592. */
  17593. clone(name: string): ShaderMaterial;
  17594. /**
  17595. * Disposes the material
  17596. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17597. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17598. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17599. */
  17600. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17601. /**
  17602. * Serializes this material in a JSON representation
  17603. * @returns the serialized material object
  17604. */
  17605. serialize(): any;
  17606. /**
  17607. * Creates a shader material from parsed shader material data
  17608. * @param source defines the JSON represnetation of the material
  17609. * @param scene defines the hosting scene
  17610. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17611. * @returns a new material
  17612. */
  17613. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17614. }
  17615. }
  17616. declare module "babylonjs/Shaders/color.fragment" {
  17617. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17618. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17619. /** @hidden */
  17620. export var colorPixelShader: {
  17621. name: string;
  17622. shader: string;
  17623. };
  17624. }
  17625. declare module "babylonjs/Shaders/color.vertex" {
  17626. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17627. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17628. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17629. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17630. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17631. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17632. /** @hidden */
  17633. export var colorVertexShader: {
  17634. name: string;
  17635. shader: string;
  17636. };
  17637. }
  17638. declare module "babylonjs/Meshes/linesMesh" {
  17639. import { Nullable } from "babylonjs/types";
  17640. import { Scene } from "babylonjs/scene";
  17641. import { Color3 } from "babylonjs/Maths/math";
  17642. import { Node } from "babylonjs/node";
  17643. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17644. import { Mesh } from "babylonjs/Meshes/mesh";
  17645. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17646. import { Effect } from "babylonjs/Materials/effect";
  17647. import { Material } from "babylonjs/Materials/material";
  17648. import "babylonjs/Shaders/color.fragment";
  17649. import "babylonjs/Shaders/color.vertex";
  17650. /**
  17651. * Line mesh
  17652. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17653. */
  17654. export class LinesMesh extends Mesh {
  17655. /**
  17656. * If vertex color should be applied to the mesh
  17657. */
  17658. useVertexColor?: boolean | undefined;
  17659. /**
  17660. * If vertex alpha should be applied to the mesh
  17661. */
  17662. useVertexAlpha?: boolean | undefined;
  17663. /**
  17664. * Color of the line (Default: White)
  17665. */
  17666. color: Color3;
  17667. /**
  17668. * Alpha of the line (Default: 1)
  17669. */
  17670. alpha: number;
  17671. /**
  17672. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17673. * This margin is expressed in world space coordinates, so its value may vary.
  17674. * Default value is 0.1
  17675. */
  17676. intersectionThreshold: number;
  17677. private _colorShader;
  17678. /**
  17679. * Creates a new LinesMesh
  17680. * @param name defines the name
  17681. * @param scene defines the hosting scene
  17682. * @param parent defines the parent mesh if any
  17683. * @param source defines the optional source LinesMesh used to clone data from
  17684. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17685. * When false, achieved by calling a clone(), also passing False.
  17686. * This will make creation of children, recursive.
  17687. * @param useVertexColor defines if this LinesMesh supports vertex color
  17688. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17689. */
  17690. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17691. /**
  17692. * If vertex color should be applied to the mesh
  17693. */
  17694. useVertexColor?: boolean | undefined,
  17695. /**
  17696. * If vertex alpha should be applied to the mesh
  17697. */
  17698. useVertexAlpha?: boolean | undefined);
  17699. private _addClipPlaneDefine;
  17700. private _removeClipPlaneDefine;
  17701. isReady(): boolean;
  17702. /**
  17703. * Returns the string "LineMesh"
  17704. */
  17705. getClassName(): string;
  17706. /**
  17707. * @hidden
  17708. */
  17709. /**
  17710. * @hidden
  17711. */
  17712. material: Material;
  17713. /**
  17714. * @hidden
  17715. */
  17716. readonly checkCollisions: boolean;
  17717. /** @hidden */
  17718. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17719. /** @hidden */
  17720. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17721. /**
  17722. * Disposes of the line mesh
  17723. * @param doNotRecurse If children should be disposed
  17724. */
  17725. dispose(doNotRecurse?: boolean): void;
  17726. /**
  17727. * Returns a new LineMesh object cloned from the current one.
  17728. */
  17729. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17730. /**
  17731. * Creates a new InstancedLinesMesh object from the mesh model.
  17732. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17733. * @param name defines the name of the new instance
  17734. * @returns a new InstancedLinesMesh
  17735. */
  17736. createInstance(name: string): InstancedLinesMesh;
  17737. }
  17738. /**
  17739. * Creates an instance based on a source LinesMesh
  17740. */
  17741. export class InstancedLinesMesh extends InstancedMesh {
  17742. /**
  17743. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17744. * This margin is expressed in world space coordinates, so its value may vary.
  17745. * Initilized with the intersectionThreshold value of the source LinesMesh
  17746. */
  17747. intersectionThreshold: number;
  17748. constructor(name: string, source: LinesMesh);
  17749. /**
  17750. * Returns the string "InstancedLinesMesh".
  17751. */
  17752. getClassName(): string;
  17753. }
  17754. }
  17755. declare module "babylonjs/Shaders/line.fragment" {
  17756. /** @hidden */
  17757. export var linePixelShader: {
  17758. name: string;
  17759. shader: string;
  17760. };
  17761. }
  17762. declare module "babylonjs/Shaders/line.vertex" {
  17763. /** @hidden */
  17764. export var lineVertexShader: {
  17765. name: string;
  17766. shader: string;
  17767. };
  17768. }
  17769. declare module "babylonjs/Rendering/edgesRenderer" {
  17770. import { Nullable } from "babylonjs/types";
  17771. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17773. import { Vector3 } from "babylonjs/Maths/math";
  17774. import { IDisposable } from "babylonjs/scene";
  17775. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17776. import "babylonjs/Shaders/line.fragment";
  17777. import "babylonjs/Shaders/line.vertex";
  17778. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17779. module "babylonjs/Meshes/abstractMesh" {
  17780. interface AbstractMesh {
  17781. /**
  17782. * Gets the edgesRenderer associated with the mesh
  17783. */
  17784. edgesRenderer: Nullable<EdgesRenderer>;
  17785. }
  17786. }
  17787. module "babylonjs/Meshes/linesMesh" {
  17788. interface LinesMesh {
  17789. /**
  17790. * Enables the edge rendering mode on the mesh.
  17791. * This mode makes the mesh edges visible
  17792. * @param epsilon defines the maximal distance between two angles to detect a face
  17793. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17794. * @returns the currentAbstractMesh
  17795. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17796. */
  17797. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17798. }
  17799. }
  17800. module "babylonjs/Meshes/linesMesh" {
  17801. interface InstancedLinesMesh {
  17802. /**
  17803. * Enables the edge rendering mode on the mesh.
  17804. * This mode makes the mesh edges visible
  17805. * @param epsilon defines the maximal distance between two angles to detect a face
  17806. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17807. * @returns the current InstancedLinesMesh
  17808. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17809. */
  17810. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17811. }
  17812. }
  17813. /**
  17814. * Defines the minimum contract an Edges renderer should follow.
  17815. */
  17816. export interface IEdgesRenderer extends IDisposable {
  17817. /**
  17818. * Gets or sets a boolean indicating if the edgesRenderer is active
  17819. */
  17820. isEnabled: boolean;
  17821. /**
  17822. * Renders the edges of the attached mesh,
  17823. */
  17824. render(): void;
  17825. /**
  17826. * Checks wether or not the edges renderer is ready to render.
  17827. * @return true if ready, otherwise false.
  17828. */
  17829. isReady(): boolean;
  17830. }
  17831. /**
  17832. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17833. */
  17834. export class EdgesRenderer implements IEdgesRenderer {
  17835. /**
  17836. * Define the size of the edges with an orthographic camera
  17837. */
  17838. edgesWidthScalerForOrthographic: number;
  17839. /**
  17840. * Define the size of the edges with a perspective camera
  17841. */
  17842. edgesWidthScalerForPerspective: number;
  17843. protected _source: AbstractMesh;
  17844. protected _linesPositions: number[];
  17845. protected _linesNormals: number[];
  17846. protected _linesIndices: number[];
  17847. protected _epsilon: number;
  17848. protected _indicesCount: number;
  17849. protected _lineShader: ShaderMaterial;
  17850. protected _ib: DataBuffer;
  17851. protected _buffers: {
  17852. [key: string]: Nullable<VertexBuffer>;
  17853. };
  17854. protected _checkVerticesInsteadOfIndices: boolean;
  17855. private _meshRebuildObserver;
  17856. private _meshDisposeObserver;
  17857. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17858. isEnabled: boolean;
  17859. /**
  17860. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17861. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17862. * @param source Mesh used to create edges
  17863. * @param epsilon sum of angles in adjacency to check for edge
  17864. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17865. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17866. */
  17867. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17868. protected _prepareRessources(): void;
  17869. /** @hidden */
  17870. _rebuild(): void;
  17871. /**
  17872. * Releases the required resources for the edges renderer
  17873. */
  17874. dispose(): void;
  17875. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17876. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17877. /**
  17878. * Checks if the pair of p0 and p1 is en edge
  17879. * @param faceIndex
  17880. * @param edge
  17881. * @param faceNormals
  17882. * @param p0
  17883. * @param p1
  17884. * @private
  17885. */
  17886. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17887. /**
  17888. * push line into the position, normal and index buffer
  17889. * @protected
  17890. */
  17891. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17892. /**
  17893. * Generates lines edges from adjacencjes
  17894. * @private
  17895. */
  17896. _generateEdgesLines(): void;
  17897. /**
  17898. * Checks wether or not the edges renderer is ready to render.
  17899. * @return true if ready, otherwise false.
  17900. */
  17901. isReady(): boolean;
  17902. /**
  17903. * Renders the edges of the attached mesh,
  17904. */
  17905. render(): void;
  17906. }
  17907. /**
  17908. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17909. */
  17910. export class LineEdgesRenderer extends EdgesRenderer {
  17911. /**
  17912. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17913. * @param source LineMesh used to generate edges
  17914. * @param epsilon not important (specified angle for edge detection)
  17915. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17916. */
  17917. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17918. /**
  17919. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17920. */
  17921. _generateEdgesLines(): void;
  17922. }
  17923. }
  17924. declare module "babylonjs/Rendering/renderingGroup" {
  17925. import { SmartArray } from "babylonjs/Misc/smartArray";
  17926. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17928. import { Nullable } from "babylonjs/types";
  17929. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17930. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17931. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17932. import { Material } from "babylonjs/Materials/material";
  17933. import { Scene } from "babylonjs/scene";
  17934. /**
  17935. * This represents the object necessary to create a rendering group.
  17936. * This is exclusively used and created by the rendering manager.
  17937. * To modify the behavior, you use the available helpers in your scene or meshes.
  17938. * @hidden
  17939. */
  17940. export class RenderingGroup {
  17941. index: number;
  17942. private _scene;
  17943. private _opaqueSubMeshes;
  17944. private _transparentSubMeshes;
  17945. private _alphaTestSubMeshes;
  17946. private _depthOnlySubMeshes;
  17947. private _particleSystems;
  17948. private _spriteManagers;
  17949. private _opaqueSortCompareFn;
  17950. private _alphaTestSortCompareFn;
  17951. private _transparentSortCompareFn;
  17952. private _renderOpaque;
  17953. private _renderAlphaTest;
  17954. private _renderTransparent;
  17955. /** @hidden */
  17956. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17957. onBeforeTransparentRendering: () => void;
  17958. /**
  17959. * Set the opaque sort comparison function.
  17960. * If null the sub meshes will be render in the order they were created
  17961. */
  17962. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17963. /**
  17964. * Set the alpha test sort comparison function.
  17965. * If null the sub meshes will be render in the order they were created
  17966. */
  17967. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17968. /**
  17969. * Set the transparent sort comparison function.
  17970. * If null the sub meshes will be render in the order they were created
  17971. */
  17972. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17973. /**
  17974. * Creates a new rendering group.
  17975. * @param index The rendering group index
  17976. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17977. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17978. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17979. */
  17980. 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>);
  17981. /**
  17982. * Render all the sub meshes contained in the group.
  17983. * @param customRenderFunction Used to override the default render behaviour of the group.
  17984. * @returns true if rendered some submeshes.
  17985. */
  17986. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17987. /**
  17988. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17989. * @param subMeshes The submeshes to render
  17990. */
  17991. private renderOpaqueSorted;
  17992. /**
  17993. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17994. * @param subMeshes The submeshes to render
  17995. */
  17996. private renderAlphaTestSorted;
  17997. /**
  17998. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17999. * @param subMeshes The submeshes to render
  18000. */
  18001. private renderTransparentSorted;
  18002. /**
  18003. * Renders the submeshes in a specified order.
  18004. * @param subMeshes The submeshes to sort before render
  18005. * @param sortCompareFn The comparison function use to sort
  18006. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  18007. * @param transparent Specifies to activate blending if true
  18008. */
  18009. private static renderSorted;
  18010. /**
  18011. * Renders the submeshes in the order they were dispatched (no sort applied).
  18012. * @param subMeshes The submeshes to render
  18013. */
  18014. private static renderUnsorted;
  18015. /**
  18016. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18017. * are rendered back to front if in the same alpha index.
  18018. *
  18019. * @param a The first submesh
  18020. * @param b The second submesh
  18021. * @returns The result of the comparison
  18022. */
  18023. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  18024. /**
  18025. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18026. * are rendered back to front.
  18027. *
  18028. * @param a The first submesh
  18029. * @param b The second submesh
  18030. * @returns The result of the comparison
  18031. */
  18032. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  18033. /**
  18034. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18035. * are rendered front to back (prevent overdraw).
  18036. *
  18037. * @param a The first submesh
  18038. * @param b The second submesh
  18039. * @returns The result of the comparison
  18040. */
  18041. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  18042. /**
  18043. * Resets the different lists of submeshes to prepare a new frame.
  18044. */
  18045. prepare(): void;
  18046. dispose(): void;
  18047. /**
  18048. * Inserts the submesh in its correct queue depending on its material.
  18049. * @param subMesh The submesh to dispatch
  18050. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18051. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18052. */
  18053. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18054. dispatchSprites(spriteManager: ISpriteManager): void;
  18055. dispatchParticles(particleSystem: IParticleSystem): void;
  18056. private _renderParticles;
  18057. private _renderSprites;
  18058. }
  18059. }
  18060. declare module "babylonjs/Rendering/renderingManager" {
  18061. import { Nullable } from "babylonjs/types";
  18062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18063. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18064. import { SmartArray } from "babylonjs/Misc/smartArray";
  18065. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18066. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  18067. import { Material } from "babylonjs/Materials/material";
  18068. import { Scene } from "babylonjs/scene";
  18069. import { Camera } from "babylonjs/Cameras/camera";
  18070. /**
  18071. * Interface describing the different options available in the rendering manager
  18072. * regarding Auto Clear between groups.
  18073. */
  18074. export interface IRenderingManagerAutoClearSetup {
  18075. /**
  18076. * Defines whether or not autoclear is enable.
  18077. */
  18078. autoClear: boolean;
  18079. /**
  18080. * Defines whether or not to autoclear the depth buffer.
  18081. */
  18082. depth: boolean;
  18083. /**
  18084. * Defines whether or not to autoclear the stencil buffer.
  18085. */
  18086. stencil: boolean;
  18087. }
  18088. /**
  18089. * This class is used by the onRenderingGroupObservable
  18090. */
  18091. export class RenderingGroupInfo {
  18092. /**
  18093. * The Scene that being rendered
  18094. */
  18095. scene: Scene;
  18096. /**
  18097. * The camera currently used for the rendering pass
  18098. */
  18099. camera: Nullable<Camera>;
  18100. /**
  18101. * The ID of the renderingGroup being processed
  18102. */
  18103. renderingGroupId: number;
  18104. }
  18105. /**
  18106. * This is the manager responsible of all the rendering for meshes sprites and particles.
  18107. * It is enable to manage the different groups as well as the different necessary sort functions.
  18108. * This should not be used directly aside of the few static configurations
  18109. */
  18110. export class RenderingManager {
  18111. /**
  18112. * The max id used for rendering groups (not included)
  18113. */
  18114. static MAX_RENDERINGGROUPS: number;
  18115. /**
  18116. * The min id used for rendering groups (included)
  18117. */
  18118. static MIN_RENDERINGGROUPS: number;
  18119. /**
  18120. * Used to globally prevent autoclearing scenes.
  18121. */
  18122. static AUTOCLEAR: boolean;
  18123. /**
  18124. * @hidden
  18125. */
  18126. _useSceneAutoClearSetup: boolean;
  18127. private _scene;
  18128. private _renderingGroups;
  18129. private _depthStencilBufferAlreadyCleaned;
  18130. private _autoClearDepthStencil;
  18131. private _customOpaqueSortCompareFn;
  18132. private _customAlphaTestSortCompareFn;
  18133. private _customTransparentSortCompareFn;
  18134. private _renderingGroupInfo;
  18135. /**
  18136. * Instantiates a new rendering group for a particular scene
  18137. * @param scene Defines the scene the groups belongs to
  18138. */
  18139. constructor(scene: Scene);
  18140. private _clearDepthStencilBuffer;
  18141. /**
  18142. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  18143. * @hidden
  18144. */
  18145. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  18146. /**
  18147. * Resets the different information of the group to prepare a new frame
  18148. * @hidden
  18149. */
  18150. reset(): void;
  18151. /**
  18152. * Dispose and release the group and its associated resources.
  18153. * @hidden
  18154. */
  18155. dispose(): void;
  18156. /**
  18157. * Clear the info related to rendering groups preventing retention points during dispose.
  18158. */
  18159. freeRenderingGroups(): void;
  18160. private _prepareRenderingGroup;
  18161. /**
  18162. * Add a sprite manager to the rendering manager in order to render it this frame.
  18163. * @param spriteManager Define the sprite manager to render
  18164. */
  18165. dispatchSprites(spriteManager: ISpriteManager): void;
  18166. /**
  18167. * Add a particle system to the rendering manager in order to render it this frame.
  18168. * @param particleSystem Define the particle system to render
  18169. */
  18170. dispatchParticles(particleSystem: IParticleSystem): void;
  18171. /**
  18172. * Add a submesh to the manager in order to render it this frame
  18173. * @param subMesh The submesh to dispatch
  18174. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18175. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18176. */
  18177. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18178. /**
  18179. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18180. * This allowed control for front to back rendering or reversly depending of the special needs.
  18181. *
  18182. * @param renderingGroupId The rendering group id corresponding to its index
  18183. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18184. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18185. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18186. */
  18187. 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;
  18188. /**
  18189. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18190. *
  18191. * @param renderingGroupId The rendering group id corresponding to its index
  18192. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18193. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18194. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18195. */
  18196. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18197. /**
  18198. * Gets the current auto clear configuration for one rendering group of the rendering
  18199. * manager.
  18200. * @param index the rendering group index to get the information for
  18201. * @returns The auto clear setup for the requested rendering group
  18202. */
  18203. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18204. }
  18205. }
  18206. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  18207. import { Observable } from "babylonjs/Misc/observable";
  18208. import { SmartArray } from "babylonjs/Misc/smartArray";
  18209. import { Nullable } from "babylonjs/types";
  18210. import { Camera } from "babylonjs/Cameras/camera";
  18211. import { Scene } from "babylonjs/scene";
  18212. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  18213. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  18214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18215. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18216. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18217. import { Texture } from "babylonjs/Materials/Textures/texture";
  18218. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18219. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  18220. import "babylonjs/Engines/Extensions/engine.renderTarget";
  18221. import { Engine } from "babylonjs/Engines/engine";
  18222. /**
  18223. * This Helps creating a texture that will be created from a camera in your scene.
  18224. * It is basically a dynamic texture that could be used to create special effects for instance.
  18225. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  18226. */
  18227. export class RenderTargetTexture extends Texture {
  18228. isCube: boolean;
  18229. /**
  18230. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  18231. */
  18232. static readonly REFRESHRATE_RENDER_ONCE: number;
  18233. /**
  18234. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  18235. */
  18236. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  18237. /**
  18238. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  18239. * the central point of your effect and can save a lot of performances.
  18240. */
  18241. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  18242. /**
  18243. * Use this predicate to dynamically define the list of mesh you want to render.
  18244. * If set, the renderList property will be overwritten.
  18245. */
  18246. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  18247. private _renderList;
  18248. /**
  18249. * Use this list to define the list of mesh you want to render.
  18250. */
  18251. renderList: Nullable<Array<AbstractMesh>>;
  18252. private _hookArray;
  18253. /**
  18254. * Define if particles should be rendered in your texture.
  18255. */
  18256. renderParticles: boolean;
  18257. /**
  18258. * Define if sprites should be rendered in your texture.
  18259. */
  18260. renderSprites: boolean;
  18261. /**
  18262. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  18263. */
  18264. coordinatesMode: number;
  18265. /**
  18266. * Define the camera used to render the texture.
  18267. */
  18268. activeCamera: Nullable<Camera>;
  18269. /**
  18270. * Override the render function of the texture with your own one.
  18271. */
  18272. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  18273. /**
  18274. * Define if camera post processes should be use while rendering the texture.
  18275. */
  18276. useCameraPostProcesses: boolean;
  18277. /**
  18278. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18279. */
  18280. ignoreCameraViewport: boolean;
  18281. private _postProcessManager;
  18282. private _postProcesses;
  18283. private _resizeObserver;
  18284. /**
  18285. * An event triggered when the texture is unbind.
  18286. */
  18287. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18288. /**
  18289. * An event triggered when the texture is unbind.
  18290. */
  18291. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18292. private _onAfterUnbindObserver;
  18293. /**
  18294. * Set a after unbind callback in the texture.
  18295. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18296. */
  18297. onAfterUnbind: () => void;
  18298. /**
  18299. * An event triggered before rendering the texture
  18300. */
  18301. onBeforeRenderObservable: Observable<number>;
  18302. private _onBeforeRenderObserver;
  18303. /**
  18304. * Set a before render callback in the texture.
  18305. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18306. */
  18307. onBeforeRender: (faceIndex: number) => void;
  18308. /**
  18309. * An event triggered after rendering the texture
  18310. */
  18311. onAfterRenderObservable: Observable<number>;
  18312. private _onAfterRenderObserver;
  18313. /**
  18314. * Set a after render callback in the texture.
  18315. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18316. */
  18317. onAfterRender: (faceIndex: number) => void;
  18318. /**
  18319. * An event triggered after the texture clear
  18320. */
  18321. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18322. private _onClearObserver;
  18323. /**
  18324. * Set a clear callback in the texture.
  18325. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18326. */
  18327. onClear: (Engine: Engine) => void;
  18328. /**
  18329. * Define the clear color of the Render Target if it should be different from the scene.
  18330. */
  18331. clearColor: Color4;
  18332. protected _size: number | {
  18333. width: number;
  18334. height: number;
  18335. };
  18336. protected _initialSizeParameter: number | {
  18337. width: number;
  18338. height: number;
  18339. } | {
  18340. ratio: number;
  18341. };
  18342. protected _sizeRatio: Nullable<number>;
  18343. /** @hidden */
  18344. _generateMipMaps: boolean;
  18345. protected _renderingManager: RenderingManager;
  18346. /** @hidden */
  18347. _waitingRenderList: string[];
  18348. protected _doNotChangeAspectRatio: boolean;
  18349. protected _currentRefreshId: number;
  18350. protected _refreshRate: number;
  18351. protected _textureMatrix: Matrix;
  18352. protected _samples: number;
  18353. protected _renderTargetOptions: RenderTargetCreationOptions;
  18354. /**
  18355. * Gets render target creation options that were used.
  18356. */
  18357. readonly renderTargetOptions: RenderTargetCreationOptions;
  18358. protected _engine: Engine;
  18359. protected _onRatioRescale(): void;
  18360. /**
  18361. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18362. * It must define where the camera used to render the texture is set
  18363. */
  18364. boundingBoxPosition: Vector3;
  18365. private _boundingBoxSize;
  18366. /**
  18367. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18368. * When defined, the cubemap will switch to local mode
  18369. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18370. * @example https://www.babylonjs-playground.com/#RNASML
  18371. */
  18372. boundingBoxSize: Vector3;
  18373. /**
  18374. * In case the RTT has been created with a depth texture, get the associated
  18375. * depth texture.
  18376. * Otherwise, return null.
  18377. */
  18378. depthStencilTexture: Nullable<InternalTexture>;
  18379. /**
  18380. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18381. * or used a shadow, depth texture...
  18382. * @param name The friendly name of the texture
  18383. * @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)
  18384. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18385. * @param generateMipMaps True if mip maps need to be generated after render.
  18386. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18387. * @param type The type of the buffer in the RTT (int, half float, float...)
  18388. * @param isCube True if a cube texture needs to be created
  18389. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18390. * @param generateDepthBuffer True to generate a depth buffer
  18391. * @param generateStencilBuffer True to generate a stencil buffer
  18392. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18393. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18394. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18395. */
  18396. constructor(name: string, size: number | {
  18397. width: number;
  18398. height: number;
  18399. } | {
  18400. ratio: number;
  18401. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18402. /**
  18403. * Creates a depth stencil texture.
  18404. * This is only available in WebGL 2 or with the depth texture extension available.
  18405. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18406. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18407. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18408. */
  18409. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18410. private _processSizeParameter;
  18411. /**
  18412. * Define the number of samples to use in case of MSAA.
  18413. * It defaults to one meaning no MSAA has been enabled.
  18414. */
  18415. samples: number;
  18416. /**
  18417. * Resets the refresh counter of the texture and start bak from scratch.
  18418. * Could be useful to regenerate the texture if it is setup to render only once.
  18419. */
  18420. resetRefreshCounter(): void;
  18421. /**
  18422. * Define the refresh rate of the texture or the rendering frequency.
  18423. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18424. */
  18425. refreshRate: number;
  18426. /**
  18427. * Adds a post process to the render target rendering passes.
  18428. * @param postProcess define the post process to add
  18429. */
  18430. addPostProcess(postProcess: PostProcess): void;
  18431. /**
  18432. * Clear all the post processes attached to the render target
  18433. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18434. */
  18435. clearPostProcesses(dispose?: boolean): void;
  18436. /**
  18437. * Remove one of the post process from the list of attached post processes to the texture
  18438. * @param postProcess define the post process to remove from the list
  18439. */
  18440. removePostProcess(postProcess: PostProcess): void;
  18441. /** @hidden */
  18442. _shouldRender(): boolean;
  18443. /**
  18444. * Gets the actual render size of the texture.
  18445. * @returns the width of the render size
  18446. */
  18447. getRenderSize(): number;
  18448. /**
  18449. * Gets the actual render width of the texture.
  18450. * @returns the width of the render size
  18451. */
  18452. getRenderWidth(): number;
  18453. /**
  18454. * Gets the actual render height of the texture.
  18455. * @returns the height of the render size
  18456. */
  18457. getRenderHeight(): number;
  18458. /**
  18459. * Get if the texture can be rescaled or not.
  18460. */
  18461. readonly canRescale: boolean;
  18462. /**
  18463. * Resize the texture using a ratio.
  18464. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18465. */
  18466. scale(ratio: number): void;
  18467. /**
  18468. * Get the texture reflection matrix used to rotate/transform the reflection.
  18469. * @returns the reflection matrix
  18470. */
  18471. getReflectionTextureMatrix(): Matrix;
  18472. /**
  18473. * Resize the texture to a new desired size.
  18474. * Be carrefull as it will recreate all the data in the new texture.
  18475. * @param size Define the new size. It can be:
  18476. * - a number for squared texture,
  18477. * - an object containing { width: number, height: number }
  18478. * - or an object containing a ratio { ratio: number }
  18479. */
  18480. resize(size: number | {
  18481. width: number;
  18482. height: number;
  18483. } | {
  18484. ratio: number;
  18485. }): void;
  18486. /**
  18487. * Renders all the objects from the render list into the texture.
  18488. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18489. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18490. */
  18491. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18492. private _bestReflectionRenderTargetDimension;
  18493. /**
  18494. * @hidden
  18495. * @param faceIndex face index to bind to if this is a cubetexture
  18496. */
  18497. _bindFrameBuffer(faceIndex?: number): void;
  18498. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18499. private renderToTarget;
  18500. /**
  18501. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18502. * This allowed control for front to back rendering or reversly depending of the special needs.
  18503. *
  18504. * @param renderingGroupId The rendering group id corresponding to its index
  18505. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18506. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18507. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18508. */
  18509. 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;
  18510. /**
  18511. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18512. *
  18513. * @param renderingGroupId The rendering group id corresponding to its index
  18514. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18515. */
  18516. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18517. /**
  18518. * Clones the texture.
  18519. * @returns the cloned texture
  18520. */
  18521. clone(): RenderTargetTexture;
  18522. /**
  18523. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18524. * @returns The JSON representation of the texture
  18525. */
  18526. serialize(): any;
  18527. /**
  18528. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18529. */
  18530. disposeFramebufferObjects(): void;
  18531. /**
  18532. * Dispose the texture and release its associated resources.
  18533. */
  18534. dispose(): void;
  18535. /** @hidden */
  18536. _rebuild(): void;
  18537. /**
  18538. * Clear the info related to rendering groups preventing retention point in material dispose.
  18539. */
  18540. freeRenderingGroups(): void;
  18541. /**
  18542. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18543. * @returns the view count
  18544. */
  18545. getViewCount(): number;
  18546. }
  18547. }
  18548. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18549. import { Scene } from "babylonjs/scene";
  18550. import { Plane } from "babylonjs/Maths/math";
  18551. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18552. /**
  18553. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18554. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18555. * You can then easily use it as a reflectionTexture on a flat surface.
  18556. * In case the surface is not a plane, please consider relying on reflection probes.
  18557. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18558. */
  18559. export class MirrorTexture extends RenderTargetTexture {
  18560. private scene;
  18561. /**
  18562. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18563. * 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.
  18564. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18565. */
  18566. mirrorPlane: Plane;
  18567. /**
  18568. * Define the blur ratio used to blur the reflection if needed.
  18569. */
  18570. blurRatio: number;
  18571. /**
  18572. * Define the adaptive blur kernel used to blur the reflection if needed.
  18573. * This will autocompute the closest best match for the `blurKernel`
  18574. */
  18575. adaptiveBlurKernel: number;
  18576. /**
  18577. * Define the blur kernel used to blur the reflection if needed.
  18578. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18579. */
  18580. blurKernel: number;
  18581. /**
  18582. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18583. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18584. */
  18585. blurKernelX: number;
  18586. /**
  18587. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18588. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18589. */
  18590. blurKernelY: number;
  18591. private _autoComputeBlurKernel;
  18592. protected _onRatioRescale(): void;
  18593. private _updateGammaSpace;
  18594. private _imageProcessingConfigChangeObserver;
  18595. private _transformMatrix;
  18596. private _mirrorMatrix;
  18597. private _savedViewMatrix;
  18598. private _blurX;
  18599. private _blurY;
  18600. private _adaptiveBlurKernel;
  18601. private _blurKernelX;
  18602. private _blurKernelY;
  18603. private _blurRatio;
  18604. /**
  18605. * Instantiates a Mirror Texture.
  18606. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18607. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18608. * You can then easily use it as a reflectionTexture on a flat surface.
  18609. * In case the surface is not a plane, please consider relying on reflection probes.
  18610. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18611. * @param name
  18612. * @param size
  18613. * @param scene
  18614. * @param generateMipMaps
  18615. * @param type
  18616. * @param samplingMode
  18617. * @param generateDepthBuffer
  18618. */
  18619. constructor(name: string, size: number | {
  18620. width: number;
  18621. height: number;
  18622. } | {
  18623. ratio: number;
  18624. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18625. private _preparePostProcesses;
  18626. /**
  18627. * Clone the mirror texture.
  18628. * @returns the cloned texture
  18629. */
  18630. clone(): MirrorTexture;
  18631. /**
  18632. * Serialize the texture to a JSON representation you could use in Parse later on
  18633. * @returns the serialized JSON representation
  18634. */
  18635. serialize(): any;
  18636. /**
  18637. * Dispose the texture and release its associated resources.
  18638. */
  18639. dispose(): void;
  18640. }
  18641. }
  18642. declare module "babylonjs/Materials/Textures/texture" {
  18643. import { Observable } from "babylonjs/Misc/observable";
  18644. import { Nullable } from "babylonjs/types";
  18645. import { Scene } from "babylonjs/scene";
  18646. import { Matrix } from "babylonjs/Maths/math";
  18647. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18648. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18649. /**
  18650. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18651. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18652. */
  18653. export class Texture extends BaseTexture {
  18654. /** @hidden */
  18655. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18656. /** @hidden */
  18657. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18658. /** @hidden */
  18659. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18660. /** nearest is mag = nearest and min = nearest and mip = linear */
  18661. static readonly NEAREST_SAMPLINGMODE: number;
  18662. /** nearest is mag = nearest and min = nearest and mip = linear */
  18663. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18664. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18665. static readonly BILINEAR_SAMPLINGMODE: number;
  18666. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18667. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18668. /** Trilinear is mag = linear and min = linear and mip = linear */
  18669. static readonly TRILINEAR_SAMPLINGMODE: number;
  18670. /** Trilinear is mag = linear and min = linear and mip = linear */
  18671. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18672. /** mag = nearest and min = nearest and mip = nearest */
  18673. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18674. /** mag = nearest and min = linear and mip = nearest */
  18675. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18676. /** mag = nearest and min = linear and mip = linear */
  18677. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18678. /** mag = nearest and min = linear and mip = none */
  18679. static readonly NEAREST_LINEAR: number;
  18680. /** mag = nearest and min = nearest and mip = none */
  18681. static readonly NEAREST_NEAREST: number;
  18682. /** mag = linear and min = nearest and mip = nearest */
  18683. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18684. /** mag = linear and min = nearest and mip = linear */
  18685. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18686. /** mag = linear and min = linear and mip = none */
  18687. static readonly LINEAR_LINEAR: number;
  18688. /** mag = linear and min = nearest and mip = none */
  18689. static readonly LINEAR_NEAREST: number;
  18690. /** Explicit coordinates mode */
  18691. static readonly EXPLICIT_MODE: number;
  18692. /** Spherical coordinates mode */
  18693. static readonly SPHERICAL_MODE: number;
  18694. /** Planar coordinates mode */
  18695. static readonly PLANAR_MODE: number;
  18696. /** Cubic coordinates mode */
  18697. static readonly CUBIC_MODE: number;
  18698. /** Projection coordinates mode */
  18699. static readonly PROJECTION_MODE: number;
  18700. /** Inverse Cubic coordinates mode */
  18701. static readonly SKYBOX_MODE: number;
  18702. /** Inverse Cubic coordinates mode */
  18703. static readonly INVCUBIC_MODE: number;
  18704. /** Equirectangular coordinates mode */
  18705. static readonly EQUIRECTANGULAR_MODE: number;
  18706. /** Equirectangular Fixed coordinates mode */
  18707. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18708. /** Equirectangular Fixed Mirrored coordinates mode */
  18709. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18710. /** Texture is not repeating outside of 0..1 UVs */
  18711. static readonly CLAMP_ADDRESSMODE: number;
  18712. /** Texture is repeating outside of 0..1 UVs */
  18713. static readonly WRAP_ADDRESSMODE: number;
  18714. /** Texture is repeating and mirrored */
  18715. static readonly MIRROR_ADDRESSMODE: number;
  18716. /**
  18717. * 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
  18718. */
  18719. static UseSerializedUrlIfAny: boolean;
  18720. /**
  18721. * Define the url of the texture.
  18722. */
  18723. url: Nullable<string>;
  18724. /**
  18725. * Define an offset on the texture to offset the u coordinates of the UVs
  18726. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18727. */
  18728. uOffset: number;
  18729. /**
  18730. * Define an offset on the texture to offset the v coordinates of the UVs
  18731. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18732. */
  18733. vOffset: number;
  18734. /**
  18735. * Define an offset on the texture to scale the u coordinates of the UVs
  18736. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18737. */
  18738. uScale: number;
  18739. /**
  18740. * Define an offset on the texture to scale the v coordinates of the UVs
  18741. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18742. */
  18743. vScale: number;
  18744. /**
  18745. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18746. * @see http://doc.babylonjs.com/how_to/more_materials
  18747. */
  18748. uAng: number;
  18749. /**
  18750. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18751. * @see http://doc.babylonjs.com/how_to/more_materials
  18752. */
  18753. vAng: number;
  18754. /**
  18755. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18756. * @see http://doc.babylonjs.com/how_to/more_materials
  18757. */
  18758. wAng: number;
  18759. /**
  18760. * Defines the center of rotation (U)
  18761. */
  18762. uRotationCenter: number;
  18763. /**
  18764. * Defines the center of rotation (V)
  18765. */
  18766. vRotationCenter: number;
  18767. /**
  18768. * Defines the center of rotation (W)
  18769. */
  18770. wRotationCenter: number;
  18771. /**
  18772. * Are mip maps generated for this texture or not.
  18773. */
  18774. readonly noMipmap: boolean;
  18775. /**
  18776. * List of inspectable custom properties (used by the Inspector)
  18777. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18778. */
  18779. inspectableCustomProperties: Nullable<IInspectable[]>;
  18780. private _noMipmap;
  18781. /** @hidden */
  18782. _invertY: boolean;
  18783. private _rowGenerationMatrix;
  18784. private _cachedTextureMatrix;
  18785. private _projectionModeMatrix;
  18786. private _t0;
  18787. private _t1;
  18788. private _t2;
  18789. private _cachedUOffset;
  18790. private _cachedVOffset;
  18791. private _cachedUScale;
  18792. private _cachedVScale;
  18793. private _cachedUAng;
  18794. private _cachedVAng;
  18795. private _cachedWAng;
  18796. private _cachedProjectionMatrixId;
  18797. private _cachedCoordinatesMode;
  18798. /** @hidden */
  18799. protected _initialSamplingMode: number;
  18800. /** @hidden */
  18801. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18802. private _deleteBuffer;
  18803. protected _format: Nullable<number>;
  18804. private _delayedOnLoad;
  18805. private _delayedOnError;
  18806. /**
  18807. * Observable triggered once the texture has been loaded.
  18808. */
  18809. onLoadObservable: Observable<Texture>;
  18810. protected _isBlocking: boolean;
  18811. /**
  18812. * Is the texture preventing material to render while loading.
  18813. * If false, a default texture will be used instead of the loading one during the preparation step.
  18814. */
  18815. isBlocking: boolean;
  18816. /**
  18817. * Get the current sampling mode associated with the texture.
  18818. */
  18819. readonly samplingMode: number;
  18820. /**
  18821. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18822. */
  18823. readonly invertY: boolean;
  18824. /**
  18825. * Instantiates a new texture.
  18826. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18827. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18828. * @param url define the url of the picture to load as a texture
  18829. * @param scene define the scene the texture will belong to
  18830. * @param noMipmap define if the texture will require mip maps or not
  18831. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18832. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18833. * @param onLoad define a callback triggered when the texture has been loaded
  18834. * @param onError define a callback triggered when an error occurred during the loading session
  18835. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18836. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18837. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18838. */
  18839. 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);
  18840. /**
  18841. * Update the url (and optional buffer) of this texture if url was null during construction.
  18842. * @param url the url of the texture
  18843. * @param buffer the buffer of the texture (defaults to null)
  18844. * @param onLoad callback called when the texture is loaded (defaults to null)
  18845. */
  18846. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18847. /**
  18848. * Finish the loading sequence of a texture flagged as delayed load.
  18849. * @hidden
  18850. */
  18851. delayLoad(): void;
  18852. private _prepareRowForTextureGeneration;
  18853. /**
  18854. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18855. * @returns the transform matrix of the texture.
  18856. */
  18857. getTextureMatrix(): Matrix;
  18858. /**
  18859. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18860. * @returns The reflection texture transform
  18861. */
  18862. getReflectionTextureMatrix(): Matrix;
  18863. /**
  18864. * Clones the texture.
  18865. * @returns the cloned texture
  18866. */
  18867. clone(): Texture;
  18868. /**
  18869. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18870. * @returns The JSON representation of the texture
  18871. */
  18872. serialize(): any;
  18873. /**
  18874. * Get the current class name of the texture useful for serialization or dynamic coding.
  18875. * @returns "Texture"
  18876. */
  18877. getClassName(): string;
  18878. /**
  18879. * Dispose the texture and release its associated resources.
  18880. */
  18881. dispose(): void;
  18882. /**
  18883. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18884. * @param parsedTexture Define the JSON representation of the texture
  18885. * @param scene Define the scene the parsed texture should be instantiated in
  18886. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18887. * @returns The parsed texture if successful
  18888. */
  18889. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18890. /**
  18891. * Creates a texture from its base 64 representation.
  18892. * @param data Define the base64 payload without the data: prefix
  18893. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18894. * @param scene Define the scene the texture should belong to
  18895. * @param noMipmap Forces the texture to not create mip map information if true
  18896. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18897. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18898. * @param onLoad define a callback triggered when the texture has been loaded
  18899. * @param onError define a callback triggered when an error occurred during the loading session
  18900. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18901. * @returns the created texture
  18902. */
  18903. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18904. /**
  18905. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18906. * @param data Define the base64 payload without the data: prefix
  18907. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18908. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18909. * @param scene Define the scene the texture should belong to
  18910. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18911. * @param noMipmap Forces the texture to not create mip map information if true
  18912. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18913. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18914. * @param onLoad define a callback triggered when the texture has been loaded
  18915. * @param onError define a callback triggered when an error occurred during the loading session
  18916. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18917. * @returns the created texture
  18918. */
  18919. 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;
  18920. }
  18921. }
  18922. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  18923. import { Nullable } from "babylonjs/types";
  18924. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18925. import { Scene } from "babylonjs/scene";
  18926. module "babylonjs/Engines/engine" {
  18927. interface Engine {
  18928. /**
  18929. * Creates a raw texture
  18930. * @param data defines the data to store in the texture
  18931. * @param width defines the width of the texture
  18932. * @param height defines the height of the texture
  18933. * @param format defines the format of the data
  18934. * @param generateMipMaps defines if the engine should generate the mip levels
  18935. * @param invertY defines if data must be stored with Y axis inverted
  18936. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18937. * @param compression defines the compression used (null by default)
  18938. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18939. * @returns the raw texture inside an InternalTexture
  18940. */
  18941. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18942. /**
  18943. * Update a raw texture
  18944. * @param texture defines the texture to update
  18945. * @param data defines the data to store in the texture
  18946. * @param format defines the format of the data
  18947. * @param invertY defines if data must be stored with Y axis inverted
  18948. */
  18949. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18950. /**
  18951. * Update a raw texture
  18952. * @param texture defines the texture to update
  18953. * @param data defines the data to store in the texture
  18954. * @param format defines the format of the data
  18955. * @param invertY defines if data must be stored with Y axis inverted
  18956. * @param compression defines the compression used (null by default)
  18957. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18958. */
  18959. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18960. /**
  18961. * Creates a new raw cube texture
  18962. * @param data defines the array of data to use to create each face
  18963. * @param size defines the size of the textures
  18964. * @param format defines the format of the data
  18965. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18966. * @param generateMipMaps defines if the engine should generate the mip levels
  18967. * @param invertY defines if data must be stored with Y axis inverted
  18968. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18969. * @param compression defines the compression used (null by default)
  18970. * @returns the cube texture as an InternalTexture
  18971. */
  18972. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18973. /**
  18974. * Update a raw cube texture
  18975. * @param texture defines the texture to udpdate
  18976. * @param data defines the data to store
  18977. * @param format defines the data format
  18978. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18979. * @param invertY defines if data must be stored with Y axis inverted
  18980. */
  18981. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18982. /**
  18983. * Update a raw cube texture
  18984. * @param texture defines the texture to udpdate
  18985. * @param data defines the data to store
  18986. * @param format defines the data format
  18987. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18988. * @param invertY defines if data must be stored with Y axis inverted
  18989. * @param compression defines the compression used (null by default)
  18990. */
  18991. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18992. /**
  18993. * Update a raw cube texture
  18994. * @param texture defines the texture to udpdate
  18995. * @param data defines the data to store
  18996. * @param format defines the data format
  18997. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18998. * @param invertY defines if data must be stored with Y axis inverted
  18999. * @param compression defines the compression used (null by default)
  19000. * @param level defines which level of the texture to update
  19001. */
  19002. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  19003. /**
  19004. * Creates a new raw cube texture from a specified url
  19005. * @param url defines the url where the data is located
  19006. * @param scene defines the current scene
  19007. * @param size defines the size of the textures
  19008. * @param format defines the format of the data
  19009. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19010. * @param noMipmap defines if the engine should avoid generating the mip levels
  19011. * @param callback defines a callback used to extract texture data from loaded data
  19012. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19013. * @param onLoad defines a callback called when texture is loaded
  19014. * @param onError defines a callback called if there is an error
  19015. * @returns the cube texture as an InternalTexture
  19016. */
  19017. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  19018. /**
  19019. * Creates a new raw cube texture from a specified url
  19020. * @param url defines the url where the data is located
  19021. * @param scene defines the current scene
  19022. * @param size defines the size of the textures
  19023. * @param format defines the format of the data
  19024. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19025. * @param noMipmap defines if the engine should avoid generating the mip levels
  19026. * @param callback defines a callback used to extract texture data from loaded data
  19027. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19028. * @param onLoad defines a callback called when texture is loaded
  19029. * @param onError defines a callback called if there is an error
  19030. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19031. * @param invertY defines if data must be stored with Y axis inverted
  19032. * @returns the cube texture as an InternalTexture
  19033. */
  19034. 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;
  19035. /**
  19036. * Creates a new raw 3D texture
  19037. * @param data defines the data used to create the texture
  19038. * @param width defines the width of the texture
  19039. * @param height defines the height of the texture
  19040. * @param depth defines the depth of the texture
  19041. * @param format defines the format of the texture
  19042. * @param generateMipMaps defines if the engine must generate mip levels
  19043. * @param invertY defines if data must be stored with Y axis inverted
  19044. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19045. * @param compression defines the compressed used (can be null)
  19046. * @param textureType defines the compressed used (can be null)
  19047. * @returns a new raw 3D texture (stored in an InternalTexture)
  19048. */
  19049. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  19050. /**
  19051. * Update a raw 3D texture
  19052. * @param texture defines the texture to update
  19053. * @param data defines the data to store
  19054. * @param format defines the data format
  19055. * @param invertY defines if data must be stored with Y axis inverted
  19056. */
  19057. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  19058. /**
  19059. * Update a raw 3D texture
  19060. * @param texture defines the texture to update
  19061. * @param data defines the data to store
  19062. * @param format defines the data format
  19063. * @param invertY defines if data must be stored with Y axis inverted
  19064. * @param compression defines the used compression (can be null)
  19065. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  19066. */
  19067. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  19068. }
  19069. }
  19070. }
  19071. declare module "babylonjs/Materials/Textures/rawTexture" {
  19072. import { Scene } from "babylonjs/scene";
  19073. import { Texture } from "babylonjs/Materials/Textures/texture";
  19074. import "babylonjs/Engines/Extensions/engine.rawTexture";
  19075. /**
  19076. * Raw texture can help creating a texture directly from an array of data.
  19077. * This can be super useful if you either get the data from an uncompressed source or
  19078. * if you wish to create your texture pixel by pixel.
  19079. */
  19080. export class RawTexture extends Texture {
  19081. /**
  19082. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19083. */
  19084. format: number;
  19085. private _engine;
  19086. /**
  19087. * Instantiates a new RawTexture.
  19088. * Raw texture can help creating a texture directly from an array of data.
  19089. * This can be super useful if you either get the data from an uncompressed source or
  19090. * if you wish to create your texture pixel by pixel.
  19091. * @param data define the array of data to use to create the texture
  19092. * @param width define the width of the texture
  19093. * @param height define the height of the texture
  19094. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19095. * @param scene define the scene the texture belongs to
  19096. * @param generateMipMaps define whether mip maps should be generated or not
  19097. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19098. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19099. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19100. */
  19101. constructor(data: ArrayBufferView, width: number, height: number,
  19102. /**
  19103. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19104. */
  19105. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  19106. /**
  19107. * Updates the texture underlying data.
  19108. * @param data Define the new data of the texture
  19109. */
  19110. update(data: ArrayBufferView): void;
  19111. /**
  19112. * Creates a luminance texture from some data.
  19113. * @param data Define the texture data
  19114. * @param width Define the width of the texture
  19115. * @param height Define the height of the texture
  19116. * @param scene Define the scene the texture belongs to
  19117. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19118. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19119. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19120. * @returns the luminance texture
  19121. */
  19122. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19123. /**
  19124. * Creates a luminance alpha texture from some data.
  19125. * @param data Define the texture data
  19126. * @param width Define the width of the texture
  19127. * @param height Define the height of the texture
  19128. * @param scene Define the scene the texture belongs to
  19129. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19130. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19131. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19132. * @returns the luminance alpha texture
  19133. */
  19134. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19135. /**
  19136. * Creates an alpha texture from some data.
  19137. * @param data Define the texture data
  19138. * @param width Define the width of the texture
  19139. * @param height Define the height of the texture
  19140. * @param scene Define the scene the texture belongs to
  19141. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19142. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19143. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19144. * @returns the alpha texture
  19145. */
  19146. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19147. /**
  19148. * Creates a RGB texture from some data.
  19149. * @param data Define the texture data
  19150. * @param width Define the width of the texture
  19151. * @param height Define the height of the texture
  19152. * @param scene Define the scene the texture belongs to
  19153. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19154. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19155. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19156. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19157. * @returns the RGB alpha texture
  19158. */
  19159. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19160. /**
  19161. * Creates a RGBA texture from some data.
  19162. * @param data Define the texture data
  19163. * @param width Define the width of the texture
  19164. * @param height Define the height of the texture
  19165. * @param scene Define the scene the texture belongs to
  19166. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19167. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19168. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19169. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19170. * @returns the RGBA texture
  19171. */
  19172. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19173. /**
  19174. * Creates a R texture from some data.
  19175. * @param data Define the texture data
  19176. * @param width Define the width of the texture
  19177. * @param height Define the height of the texture
  19178. * @param scene Define the scene the texture belongs to
  19179. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19180. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19181. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19182. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19183. * @returns the R texture
  19184. */
  19185. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19186. }
  19187. }
  19188. declare module "babylonjs/Animations/runtimeAnimation" {
  19189. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  19190. import { Animatable } from "babylonjs/Animations/animatable";
  19191. import { Scene } from "babylonjs/scene";
  19192. /**
  19193. * Defines a runtime animation
  19194. */
  19195. export class RuntimeAnimation {
  19196. private _events;
  19197. /**
  19198. * The current frame of the runtime animation
  19199. */
  19200. private _currentFrame;
  19201. /**
  19202. * The animation used by the runtime animation
  19203. */
  19204. private _animation;
  19205. /**
  19206. * The target of the runtime animation
  19207. */
  19208. private _target;
  19209. /**
  19210. * The initiating animatable
  19211. */
  19212. private _host;
  19213. /**
  19214. * The original value of the runtime animation
  19215. */
  19216. private _originalValue;
  19217. /**
  19218. * The original blend value of the runtime animation
  19219. */
  19220. private _originalBlendValue;
  19221. /**
  19222. * The offsets cache of the runtime animation
  19223. */
  19224. private _offsetsCache;
  19225. /**
  19226. * The high limits cache of the runtime animation
  19227. */
  19228. private _highLimitsCache;
  19229. /**
  19230. * Specifies if the runtime animation has been stopped
  19231. */
  19232. private _stopped;
  19233. /**
  19234. * The blending factor of the runtime animation
  19235. */
  19236. private _blendingFactor;
  19237. /**
  19238. * The BabylonJS scene
  19239. */
  19240. private _scene;
  19241. /**
  19242. * The current value of the runtime animation
  19243. */
  19244. private _currentValue;
  19245. /** @hidden */
  19246. _animationState: _IAnimationState;
  19247. /**
  19248. * The active target of the runtime animation
  19249. */
  19250. private _activeTargets;
  19251. private _currentActiveTarget;
  19252. private _directTarget;
  19253. /**
  19254. * The target path of the runtime animation
  19255. */
  19256. private _targetPath;
  19257. /**
  19258. * The weight of the runtime animation
  19259. */
  19260. private _weight;
  19261. /**
  19262. * The ratio offset of the runtime animation
  19263. */
  19264. private _ratioOffset;
  19265. /**
  19266. * The previous delay of the runtime animation
  19267. */
  19268. private _previousDelay;
  19269. /**
  19270. * The previous ratio of the runtime animation
  19271. */
  19272. private _previousRatio;
  19273. private _enableBlending;
  19274. private _keys;
  19275. private _minFrame;
  19276. private _maxFrame;
  19277. private _minValue;
  19278. private _maxValue;
  19279. private _targetIsArray;
  19280. /**
  19281. * Gets the current frame of the runtime animation
  19282. */
  19283. readonly currentFrame: number;
  19284. /**
  19285. * Gets the weight of the runtime animation
  19286. */
  19287. readonly weight: number;
  19288. /**
  19289. * Gets the current value of the runtime animation
  19290. */
  19291. readonly currentValue: any;
  19292. /**
  19293. * Gets the target path of the runtime animation
  19294. */
  19295. readonly targetPath: string;
  19296. /**
  19297. * Gets the actual target of the runtime animation
  19298. */
  19299. readonly target: any;
  19300. /** @hidden */
  19301. _onLoop: () => void;
  19302. /**
  19303. * Create a new RuntimeAnimation object
  19304. * @param target defines the target of the animation
  19305. * @param animation defines the source animation object
  19306. * @param scene defines the hosting scene
  19307. * @param host defines the initiating Animatable
  19308. */
  19309. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  19310. private _preparePath;
  19311. /**
  19312. * Gets the animation from the runtime animation
  19313. */
  19314. readonly animation: Animation;
  19315. /**
  19316. * Resets the runtime animation to the beginning
  19317. * @param restoreOriginal defines whether to restore the target property to the original value
  19318. */
  19319. reset(restoreOriginal?: boolean): void;
  19320. /**
  19321. * Specifies if the runtime animation is stopped
  19322. * @returns Boolean specifying if the runtime animation is stopped
  19323. */
  19324. isStopped(): boolean;
  19325. /**
  19326. * Disposes of the runtime animation
  19327. */
  19328. dispose(): void;
  19329. /**
  19330. * Apply the interpolated value to the target
  19331. * @param currentValue defines the value computed by the animation
  19332. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  19333. */
  19334. setValue(currentValue: any, weight: number): void;
  19335. private _getOriginalValues;
  19336. private _setValue;
  19337. /**
  19338. * Gets the loop pmode of the runtime animation
  19339. * @returns Loop Mode
  19340. */
  19341. private _getCorrectLoopMode;
  19342. /**
  19343. * Move the current animation to a given frame
  19344. * @param frame defines the frame to move to
  19345. */
  19346. goToFrame(frame: number): void;
  19347. /**
  19348. * @hidden Internal use only
  19349. */
  19350. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  19351. /**
  19352. * Execute the current animation
  19353. * @param delay defines the delay to add to the current frame
  19354. * @param from defines the lower bound of the animation range
  19355. * @param to defines the upper bound of the animation range
  19356. * @param loop defines if the current animation must loop
  19357. * @param speedRatio defines the current speed ratio
  19358. * @param weight defines the weight of the animation (default is -1 so no weight)
  19359. * @param onLoop optional callback called when animation loops
  19360. * @returns a boolean indicating if the animation is running
  19361. */
  19362. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  19363. }
  19364. }
  19365. declare module "babylonjs/Animations/animatable" {
  19366. import { Animation } from "babylonjs/Animations/animation";
  19367. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  19368. import { Nullable } from "babylonjs/types";
  19369. import { Observable } from "babylonjs/Misc/observable";
  19370. import { Scene } from "babylonjs/scene";
  19371. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  19372. import { Node } from "babylonjs/node";
  19373. /**
  19374. * Class used to store an actual running animation
  19375. */
  19376. export class Animatable {
  19377. /** defines the target object */
  19378. target: any;
  19379. /** defines the starting frame number (default is 0) */
  19380. fromFrame: number;
  19381. /** defines the ending frame number (default is 100) */
  19382. toFrame: number;
  19383. /** defines if the animation must loop (default is false) */
  19384. loopAnimation: boolean;
  19385. /** defines a callback to call when animation ends if it is not looping */
  19386. onAnimationEnd?: (() => void) | null | undefined;
  19387. /** defines a callback to call when animation loops */
  19388. onAnimationLoop?: (() => void) | null | undefined;
  19389. private _localDelayOffset;
  19390. private _pausedDelay;
  19391. private _runtimeAnimations;
  19392. private _paused;
  19393. private _scene;
  19394. private _speedRatio;
  19395. private _weight;
  19396. private _syncRoot;
  19397. /**
  19398. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  19399. * This will only apply for non looping animation (default is true)
  19400. */
  19401. disposeOnEnd: boolean;
  19402. /**
  19403. * Gets a boolean indicating if the animation has started
  19404. */
  19405. animationStarted: boolean;
  19406. /**
  19407. * Observer raised when the animation ends
  19408. */
  19409. onAnimationEndObservable: Observable<Animatable>;
  19410. /**
  19411. * Observer raised when the animation loops
  19412. */
  19413. onAnimationLoopObservable: Observable<Animatable>;
  19414. /**
  19415. * Gets the root Animatable used to synchronize and normalize animations
  19416. */
  19417. readonly syncRoot: Nullable<Animatable>;
  19418. /**
  19419. * Gets the current frame of the first RuntimeAnimation
  19420. * Used to synchronize Animatables
  19421. */
  19422. readonly masterFrame: number;
  19423. /**
  19424. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19425. */
  19426. weight: number;
  19427. /**
  19428. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19429. */
  19430. speedRatio: number;
  19431. /**
  19432. * Creates a new Animatable
  19433. * @param scene defines the hosting scene
  19434. * @param target defines the target object
  19435. * @param fromFrame defines the starting frame number (default is 0)
  19436. * @param toFrame defines the ending frame number (default is 100)
  19437. * @param loopAnimation defines if the animation must loop (default is false)
  19438. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19439. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19440. * @param animations defines a group of animation to add to the new Animatable
  19441. * @param onAnimationLoop defines a callback to call when animation loops
  19442. */
  19443. constructor(scene: Scene,
  19444. /** defines the target object */
  19445. target: any,
  19446. /** defines the starting frame number (default is 0) */
  19447. fromFrame?: number,
  19448. /** defines the ending frame number (default is 100) */
  19449. toFrame?: number,
  19450. /** defines if the animation must loop (default is false) */
  19451. loopAnimation?: boolean, speedRatio?: number,
  19452. /** defines a callback to call when animation ends if it is not looping */
  19453. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19454. /** defines a callback to call when animation loops */
  19455. onAnimationLoop?: (() => void) | null | undefined);
  19456. /**
  19457. * Synchronize and normalize current Animatable with a source Animatable
  19458. * This is useful when using animation weights and when animations are not of the same length
  19459. * @param root defines the root Animatable to synchronize with
  19460. * @returns the current Animatable
  19461. */
  19462. syncWith(root: Animatable): Animatable;
  19463. /**
  19464. * Gets the list of runtime animations
  19465. * @returns an array of RuntimeAnimation
  19466. */
  19467. getAnimations(): RuntimeAnimation[];
  19468. /**
  19469. * Adds more animations to the current animatable
  19470. * @param target defines the target of the animations
  19471. * @param animations defines the new animations to add
  19472. */
  19473. appendAnimations(target: any, animations: Animation[]): void;
  19474. /**
  19475. * Gets the source animation for a specific property
  19476. * @param property defines the propertyu to look for
  19477. * @returns null or the source animation for the given property
  19478. */
  19479. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19480. /**
  19481. * Gets the runtime animation for a specific property
  19482. * @param property defines the propertyu to look for
  19483. * @returns null or the runtime animation for the given property
  19484. */
  19485. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19486. /**
  19487. * Resets the animatable to its original state
  19488. */
  19489. reset(): void;
  19490. /**
  19491. * Allows the animatable to blend with current running animations
  19492. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19493. * @param blendingSpeed defines the blending speed to use
  19494. */
  19495. enableBlending(blendingSpeed: number): void;
  19496. /**
  19497. * Disable animation blending
  19498. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19499. */
  19500. disableBlending(): void;
  19501. /**
  19502. * Jump directly to a given frame
  19503. * @param frame defines the frame to jump to
  19504. */
  19505. goToFrame(frame: number): void;
  19506. /**
  19507. * Pause the animation
  19508. */
  19509. pause(): void;
  19510. /**
  19511. * Restart the animation
  19512. */
  19513. restart(): void;
  19514. private _raiseOnAnimationEnd;
  19515. /**
  19516. * Stop and delete the current animation
  19517. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19518. * @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)
  19519. */
  19520. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19521. /**
  19522. * Wait asynchronously for the animation to end
  19523. * @returns a promise which will be fullfilled when the animation ends
  19524. */
  19525. waitAsync(): Promise<Animatable>;
  19526. /** @hidden */
  19527. _animate(delay: number): boolean;
  19528. }
  19529. module "babylonjs/scene" {
  19530. interface Scene {
  19531. /** @hidden */
  19532. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19533. /** @hidden */
  19534. _processLateAnimationBindingsForMatrices(holder: {
  19535. totalWeight: number;
  19536. animations: RuntimeAnimation[];
  19537. originalValue: Matrix;
  19538. }): any;
  19539. /** @hidden */
  19540. _processLateAnimationBindingsForQuaternions(holder: {
  19541. totalWeight: number;
  19542. animations: RuntimeAnimation[];
  19543. originalValue: Quaternion;
  19544. }, refQuaternion: Quaternion): Quaternion;
  19545. /** @hidden */
  19546. _processLateAnimationBindings(): void;
  19547. /**
  19548. * Will start the animation sequence of a given target
  19549. * @param target defines the target
  19550. * @param from defines from which frame should animation start
  19551. * @param to defines until which frame should animation run.
  19552. * @param weight defines the weight to apply to the animation (1.0 by default)
  19553. * @param loop defines if the animation loops
  19554. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19555. * @param onAnimationEnd defines the function to be executed when the animation ends
  19556. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19557. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19558. * @param onAnimationLoop defines the callback to call when an animation loops
  19559. * @returns the animatable object created for this animation
  19560. */
  19561. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19562. /**
  19563. * Will start the animation sequence of a given target
  19564. * @param target defines the target
  19565. * @param from defines from which frame should animation start
  19566. * @param to defines until which frame should animation run.
  19567. * @param loop defines if the animation loops
  19568. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19569. * @param onAnimationEnd defines the function to be executed when the animation ends
  19570. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19571. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19572. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19573. * @param onAnimationLoop defines the callback to call when an animation loops
  19574. * @returns the animatable object created for this animation
  19575. */
  19576. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19577. /**
  19578. * Will start the animation sequence of a given target and its hierarchy
  19579. * @param target defines the target
  19580. * @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.
  19581. * @param from defines from which frame should animation start
  19582. * @param to defines until which frame should animation run.
  19583. * @param loop defines if the animation loops
  19584. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19585. * @param onAnimationEnd defines the function to be executed when the animation ends
  19586. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19587. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19588. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19589. * @param onAnimationLoop defines the callback to call when an animation loops
  19590. * @returns the list of created animatables
  19591. */
  19592. 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[];
  19593. /**
  19594. * Begin a new animation on a given node
  19595. * @param target defines the target where the animation will take place
  19596. * @param animations defines the list of animations to start
  19597. * @param from defines the initial value
  19598. * @param to defines the final value
  19599. * @param loop defines if you want animation to loop (off by default)
  19600. * @param speedRatio defines the speed ratio to apply to all animations
  19601. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19602. * @param onAnimationLoop defines the callback to call when an animation loops
  19603. * @returns the list of created animatables
  19604. */
  19605. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19606. /**
  19607. * Begin a new animation on a given node and its hierarchy
  19608. * @param target defines the root node where the animation will take place
  19609. * @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.
  19610. * @param animations defines the list of animations to start
  19611. * @param from defines the initial value
  19612. * @param to defines the final value
  19613. * @param loop defines if you want animation to loop (off by default)
  19614. * @param speedRatio defines the speed ratio to apply to all animations
  19615. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19616. * @param onAnimationLoop defines the callback to call when an animation loops
  19617. * @returns the list of animatables created for all nodes
  19618. */
  19619. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19620. /**
  19621. * Gets the animatable associated with a specific target
  19622. * @param target defines the target of the animatable
  19623. * @returns the required animatable if found
  19624. */
  19625. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19626. /**
  19627. * Gets all animatables associated with a given target
  19628. * @param target defines the target to look animatables for
  19629. * @returns an array of Animatables
  19630. */
  19631. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19632. /**
  19633. * Stops and removes all animations that have been applied to the scene
  19634. */
  19635. stopAllAnimations(): void;
  19636. }
  19637. }
  19638. module "babylonjs/Bones/bone" {
  19639. interface Bone {
  19640. /**
  19641. * Copy an animation range from another bone
  19642. * @param source defines the source bone
  19643. * @param rangeName defines the range name to copy
  19644. * @param frameOffset defines the frame offset
  19645. * @param rescaleAsRequired defines if rescaling must be applied if required
  19646. * @param skelDimensionsRatio defines the scaling ratio
  19647. * @returns true if operation was successful
  19648. */
  19649. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19650. }
  19651. }
  19652. }
  19653. declare module "babylonjs/Bones/skeleton" {
  19654. import { Bone } from "babylonjs/Bones/bone";
  19655. import { IAnimatable } from "babylonjs/Misc/tools";
  19656. import { Observable } from "babylonjs/Misc/observable";
  19657. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19658. import { Scene } from "babylonjs/scene";
  19659. import { Nullable } from "babylonjs/types";
  19660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19661. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19662. import { Animatable } from "babylonjs/Animations/animatable";
  19663. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19664. import { Animation } from "babylonjs/Animations/animation";
  19665. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19666. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19667. /**
  19668. * Class used to handle skinning animations
  19669. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19670. */
  19671. export class Skeleton implements IAnimatable {
  19672. /** defines the skeleton name */
  19673. name: string;
  19674. /** defines the skeleton Id */
  19675. id: string;
  19676. /**
  19677. * Defines the list of child bones
  19678. */
  19679. bones: Bone[];
  19680. /**
  19681. * Defines an estimate of the dimension of the skeleton at rest
  19682. */
  19683. dimensionsAtRest: Vector3;
  19684. /**
  19685. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19686. */
  19687. needInitialSkinMatrix: boolean;
  19688. /**
  19689. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19690. */
  19691. overrideMesh: Nullable<AbstractMesh>;
  19692. /**
  19693. * Gets the list of animations attached to this skeleton
  19694. */
  19695. animations: Array<Animation>;
  19696. private _scene;
  19697. private _isDirty;
  19698. private _transformMatrices;
  19699. private _transformMatrixTexture;
  19700. private _meshesWithPoseMatrix;
  19701. private _animatables;
  19702. private _identity;
  19703. private _synchronizedWithMesh;
  19704. private _ranges;
  19705. private _lastAbsoluteTransformsUpdateId;
  19706. private _canUseTextureForBones;
  19707. private _uniqueId;
  19708. /** @hidden */
  19709. _numBonesWithLinkedTransformNode: number;
  19710. /** @hidden */
  19711. _hasWaitingData: Nullable<boolean>;
  19712. /**
  19713. * Specifies if the skeleton should be serialized
  19714. */
  19715. doNotSerialize: boolean;
  19716. private _useTextureToStoreBoneMatrices;
  19717. /**
  19718. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19719. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19720. */
  19721. useTextureToStoreBoneMatrices: boolean;
  19722. private _animationPropertiesOverride;
  19723. /**
  19724. * Gets or sets the animation properties override
  19725. */
  19726. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19727. /**
  19728. * List of inspectable custom properties (used by the Inspector)
  19729. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19730. */
  19731. inspectableCustomProperties: IInspectable[];
  19732. /**
  19733. * An observable triggered before computing the skeleton's matrices
  19734. */
  19735. onBeforeComputeObservable: Observable<Skeleton>;
  19736. /**
  19737. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19738. */
  19739. readonly isUsingTextureForMatrices: boolean;
  19740. /**
  19741. * Gets the unique ID of this skeleton
  19742. */
  19743. readonly uniqueId: number;
  19744. /**
  19745. * Creates a new skeleton
  19746. * @param name defines the skeleton name
  19747. * @param id defines the skeleton Id
  19748. * @param scene defines the hosting scene
  19749. */
  19750. constructor(
  19751. /** defines the skeleton name */
  19752. name: string,
  19753. /** defines the skeleton Id */
  19754. id: string, scene: Scene);
  19755. /**
  19756. * Gets the current object class name.
  19757. * @return the class name
  19758. */
  19759. getClassName(): string;
  19760. /**
  19761. * Returns an array containing the root bones
  19762. * @returns an array containing the root bones
  19763. */
  19764. getChildren(): Array<Bone>;
  19765. /**
  19766. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19767. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19768. * @returns a Float32Array containing matrices data
  19769. */
  19770. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19771. /**
  19772. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19773. * @returns a raw texture containing the data
  19774. */
  19775. getTransformMatrixTexture(): Nullable<RawTexture>;
  19776. /**
  19777. * Gets the current hosting scene
  19778. * @returns a scene object
  19779. */
  19780. getScene(): Scene;
  19781. /**
  19782. * Gets a string representing the current skeleton data
  19783. * @param fullDetails defines a boolean indicating if we want a verbose version
  19784. * @returns a string representing the current skeleton data
  19785. */
  19786. toString(fullDetails?: boolean): string;
  19787. /**
  19788. * Get bone's index searching by name
  19789. * @param name defines bone's name to search for
  19790. * @return the indice of the bone. Returns -1 if not found
  19791. */
  19792. getBoneIndexByName(name: string): number;
  19793. /**
  19794. * Creater a new animation range
  19795. * @param name defines the name of the range
  19796. * @param from defines the start key
  19797. * @param to defines the end key
  19798. */
  19799. createAnimationRange(name: string, from: number, to: number): void;
  19800. /**
  19801. * Delete a specific animation range
  19802. * @param name defines the name of the range
  19803. * @param deleteFrames defines if frames must be removed as well
  19804. */
  19805. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19806. /**
  19807. * Gets a specific animation range
  19808. * @param name defines the name of the range to look for
  19809. * @returns the requested animation range or null if not found
  19810. */
  19811. getAnimationRange(name: string): Nullable<AnimationRange>;
  19812. /**
  19813. * Gets the list of all animation ranges defined on this skeleton
  19814. * @returns an array
  19815. */
  19816. getAnimationRanges(): Nullable<AnimationRange>[];
  19817. /**
  19818. * Copy animation range from a source skeleton.
  19819. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19820. * @param source defines the source skeleton
  19821. * @param name defines the name of the range to copy
  19822. * @param rescaleAsRequired defines if rescaling must be applied if required
  19823. * @returns true if operation was successful
  19824. */
  19825. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19826. /**
  19827. * Forces the skeleton to go to rest pose
  19828. */
  19829. returnToRest(): void;
  19830. private _getHighestAnimationFrame;
  19831. /**
  19832. * Begin a specific animation range
  19833. * @param name defines the name of the range to start
  19834. * @param loop defines if looping must be turned on (false by default)
  19835. * @param speedRatio defines the speed ratio to apply (1 by default)
  19836. * @param onAnimationEnd defines a callback which will be called when animation will end
  19837. * @returns a new animatable
  19838. */
  19839. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19840. /** @hidden */
  19841. _markAsDirty(): void;
  19842. /** @hidden */
  19843. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19844. /** @hidden */
  19845. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19846. private _computeTransformMatrices;
  19847. /**
  19848. * Build all resources required to render a skeleton
  19849. */
  19850. prepare(): void;
  19851. /**
  19852. * Gets the list of animatables currently running for this skeleton
  19853. * @returns an array of animatables
  19854. */
  19855. getAnimatables(): IAnimatable[];
  19856. /**
  19857. * Clone the current skeleton
  19858. * @param name defines the name of the new skeleton
  19859. * @param id defines the id of the new skeleton
  19860. * @returns the new skeleton
  19861. */
  19862. clone(name: string, id: string): Skeleton;
  19863. /**
  19864. * Enable animation blending for this skeleton
  19865. * @param blendingSpeed defines the blending speed to apply
  19866. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19867. */
  19868. enableBlending(blendingSpeed?: number): void;
  19869. /**
  19870. * Releases all resources associated with the current skeleton
  19871. */
  19872. dispose(): void;
  19873. /**
  19874. * Serialize the skeleton in a JSON object
  19875. * @returns a JSON object
  19876. */
  19877. serialize(): any;
  19878. /**
  19879. * Creates a new skeleton from serialized data
  19880. * @param parsedSkeleton defines the serialized data
  19881. * @param scene defines the hosting scene
  19882. * @returns a new skeleton
  19883. */
  19884. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19885. /**
  19886. * Compute all node absolute transforms
  19887. * @param forceUpdate defines if computation must be done even if cache is up to date
  19888. */
  19889. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19890. /**
  19891. * Gets the root pose matrix
  19892. * @returns a matrix
  19893. */
  19894. getPoseMatrix(): Nullable<Matrix>;
  19895. /**
  19896. * Sorts bones per internal index
  19897. */
  19898. sortBones(): void;
  19899. private _sortBones;
  19900. }
  19901. }
  19902. declare module "babylonjs/Morph/morphTarget" {
  19903. import { IAnimatable } from "babylonjs/Misc/tools";
  19904. import { Observable } from "babylonjs/Misc/observable";
  19905. import { Nullable, FloatArray } from "babylonjs/types";
  19906. import { Scene } from "babylonjs/scene";
  19907. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19908. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19909. /**
  19910. * Defines a target to use with MorphTargetManager
  19911. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19912. */
  19913. export class MorphTarget implements IAnimatable {
  19914. /** defines the name of the target */
  19915. name: string;
  19916. /**
  19917. * Gets or sets the list of animations
  19918. */
  19919. animations: import("babylonjs/Animations/animation").Animation[];
  19920. private _scene;
  19921. private _positions;
  19922. private _normals;
  19923. private _tangents;
  19924. private _influence;
  19925. /**
  19926. * Observable raised when the influence changes
  19927. */
  19928. onInfluenceChanged: Observable<boolean>;
  19929. /** @hidden */
  19930. _onDataLayoutChanged: Observable<void>;
  19931. /**
  19932. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19933. */
  19934. influence: number;
  19935. /**
  19936. * Gets or sets the id of the morph Target
  19937. */
  19938. id: string;
  19939. private _animationPropertiesOverride;
  19940. /**
  19941. * Gets or sets the animation properties override
  19942. */
  19943. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19944. /**
  19945. * Creates a new MorphTarget
  19946. * @param name defines the name of the target
  19947. * @param influence defines the influence to use
  19948. * @param scene defines the scene the morphtarget belongs to
  19949. */
  19950. constructor(
  19951. /** defines the name of the target */
  19952. name: string, influence?: number, scene?: Nullable<Scene>);
  19953. /**
  19954. * Gets a boolean defining if the target contains position data
  19955. */
  19956. readonly hasPositions: boolean;
  19957. /**
  19958. * Gets a boolean defining if the target contains normal data
  19959. */
  19960. readonly hasNormals: boolean;
  19961. /**
  19962. * Gets a boolean defining if the target contains tangent data
  19963. */
  19964. readonly hasTangents: boolean;
  19965. /**
  19966. * Affects position data to this target
  19967. * @param data defines the position data to use
  19968. */
  19969. setPositions(data: Nullable<FloatArray>): void;
  19970. /**
  19971. * Gets the position data stored in this target
  19972. * @returns a FloatArray containing the position data (or null if not present)
  19973. */
  19974. getPositions(): Nullable<FloatArray>;
  19975. /**
  19976. * Affects normal data to this target
  19977. * @param data defines the normal data to use
  19978. */
  19979. setNormals(data: Nullable<FloatArray>): void;
  19980. /**
  19981. * Gets the normal data stored in this target
  19982. * @returns a FloatArray containing the normal data (or null if not present)
  19983. */
  19984. getNormals(): Nullable<FloatArray>;
  19985. /**
  19986. * Affects tangent data to this target
  19987. * @param data defines the tangent data to use
  19988. */
  19989. setTangents(data: Nullable<FloatArray>): void;
  19990. /**
  19991. * Gets the tangent data stored in this target
  19992. * @returns a FloatArray containing the tangent data (or null if not present)
  19993. */
  19994. getTangents(): Nullable<FloatArray>;
  19995. /**
  19996. * Serializes the current target into a Serialization object
  19997. * @returns the serialized object
  19998. */
  19999. serialize(): any;
  20000. /**
  20001. * Returns the string "MorphTarget"
  20002. * @returns "MorphTarget"
  20003. */
  20004. getClassName(): string;
  20005. /**
  20006. * Creates a new target from serialized data
  20007. * @param serializationObject defines the serialized data to use
  20008. * @returns a new MorphTarget
  20009. */
  20010. static Parse(serializationObject: any): MorphTarget;
  20011. /**
  20012. * Creates a MorphTarget from mesh data
  20013. * @param mesh defines the source mesh
  20014. * @param name defines the name to use for the new target
  20015. * @param influence defines the influence to attach to the target
  20016. * @returns a new MorphTarget
  20017. */
  20018. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  20019. }
  20020. }
  20021. declare module "babylonjs/Morph/morphTargetManager" {
  20022. import { Nullable } from "babylonjs/types";
  20023. import { Scene } from "babylonjs/scene";
  20024. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  20025. /**
  20026. * This class is used to deform meshes using morphing between different targets
  20027. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20028. */
  20029. export class MorphTargetManager {
  20030. private _targets;
  20031. private _targetInfluenceChangedObservers;
  20032. private _targetDataLayoutChangedObservers;
  20033. private _activeTargets;
  20034. private _scene;
  20035. private _influences;
  20036. private _supportsNormals;
  20037. private _supportsTangents;
  20038. private _vertexCount;
  20039. private _uniqueId;
  20040. private _tempInfluences;
  20041. /**
  20042. * Creates a new MorphTargetManager
  20043. * @param scene defines the current scene
  20044. */
  20045. constructor(scene?: Nullable<Scene>);
  20046. /**
  20047. * Gets the unique ID of this manager
  20048. */
  20049. readonly uniqueId: number;
  20050. /**
  20051. * Gets the number of vertices handled by this manager
  20052. */
  20053. readonly vertexCount: number;
  20054. /**
  20055. * Gets a boolean indicating if this manager supports morphing of normals
  20056. */
  20057. readonly supportsNormals: boolean;
  20058. /**
  20059. * Gets a boolean indicating if this manager supports morphing of tangents
  20060. */
  20061. readonly supportsTangents: boolean;
  20062. /**
  20063. * Gets the number of targets stored in this manager
  20064. */
  20065. readonly numTargets: number;
  20066. /**
  20067. * Gets the number of influencers (ie. the number of targets with influences > 0)
  20068. */
  20069. readonly numInfluencers: number;
  20070. /**
  20071. * Gets the list of influences (one per target)
  20072. */
  20073. readonly influences: Float32Array;
  20074. /**
  20075. * Gets the active target at specified index. An active target is a target with an influence > 0
  20076. * @param index defines the index to check
  20077. * @returns the requested target
  20078. */
  20079. getActiveTarget(index: number): MorphTarget;
  20080. /**
  20081. * Gets the target at specified index
  20082. * @param index defines the index to check
  20083. * @returns the requested target
  20084. */
  20085. getTarget(index: number): MorphTarget;
  20086. /**
  20087. * Add a new target to this manager
  20088. * @param target defines the target to add
  20089. */
  20090. addTarget(target: MorphTarget): void;
  20091. /**
  20092. * Removes a target from the manager
  20093. * @param target defines the target to remove
  20094. */
  20095. removeTarget(target: MorphTarget): void;
  20096. /**
  20097. * Serializes the current manager into a Serialization object
  20098. * @returns the serialized object
  20099. */
  20100. serialize(): any;
  20101. private _syncActiveTargets;
  20102. /**
  20103. * Syncrhonize the targets with all the meshes using this morph target manager
  20104. */
  20105. synchronize(): void;
  20106. /**
  20107. * Creates a new MorphTargetManager from serialized data
  20108. * @param serializationObject defines the serialized data
  20109. * @param scene defines the hosting scene
  20110. * @returns the new MorphTargetManager
  20111. */
  20112. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  20113. }
  20114. }
  20115. declare module "babylonjs/Meshes/meshLODLevel" {
  20116. import { Mesh } from "babylonjs/Meshes/mesh";
  20117. import { Nullable } from "babylonjs/types";
  20118. /**
  20119. * Class used to represent a specific level of detail of a mesh
  20120. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20121. */
  20122. export class MeshLODLevel {
  20123. /** Defines the distance where this level should star being displayed */
  20124. distance: number;
  20125. /** Defines the mesh to use to render this level */
  20126. mesh: Nullable<Mesh>;
  20127. /**
  20128. * Creates a new LOD level
  20129. * @param distance defines the distance where this level should star being displayed
  20130. * @param mesh defines the mesh to use to render this level
  20131. */
  20132. constructor(
  20133. /** Defines the distance where this level should star being displayed */
  20134. distance: number,
  20135. /** Defines the mesh to use to render this level */
  20136. mesh: Nullable<Mesh>);
  20137. }
  20138. }
  20139. declare module "babylonjs/Meshes/groundMesh" {
  20140. import { Scene } from "babylonjs/scene";
  20141. import { Vector3 } from "babylonjs/Maths/math";
  20142. import { Mesh } from "babylonjs/Meshes/mesh";
  20143. /**
  20144. * Mesh representing the gorund
  20145. */
  20146. export class GroundMesh extends Mesh {
  20147. /** If octree should be generated */
  20148. generateOctree: boolean;
  20149. private _heightQuads;
  20150. /** @hidden */
  20151. _subdivisionsX: number;
  20152. /** @hidden */
  20153. _subdivisionsY: number;
  20154. /** @hidden */
  20155. _width: number;
  20156. /** @hidden */
  20157. _height: number;
  20158. /** @hidden */
  20159. _minX: number;
  20160. /** @hidden */
  20161. _maxX: number;
  20162. /** @hidden */
  20163. _minZ: number;
  20164. /** @hidden */
  20165. _maxZ: number;
  20166. constructor(name: string, scene: Scene);
  20167. /**
  20168. * "GroundMesh"
  20169. * @returns "GroundMesh"
  20170. */
  20171. getClassName(): string;
  20172. /**
  20173. * The minimum of x and y subdivisions
  20174. */
  20175. readonly subdivisions: number;
  20176. /**
  20177. * X subdivisions
  20178. */
  20179. readonly subdivisionsX: number;
  20180. /**
  20181. * Y subdivisions
  20182. */
  20183. readonly subdivisionsY: number;
  20184. /**
  20185. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  20186. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20187. * @param chunksCount the number of subdivisions for x and y
  20188. * @param octreeBlocksSize (Default: 32)
  20189. */
  20190. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20191. /**
  20192. * Returns a height (y) value in the Worl system :
  20193. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20194. * @param x x coordinate
  20195. * @param z z coordinate
  20196. * @returns the ground y position if (x, z) are outside the ground surface.
  20197. */
  20198. getHeightAtCoordinates(x: number, z: number): number;
  20199. /**
  20200. * Returns a normalized vector (Vector3) orthogonal to the ground
  20201. * at the ground coordinates (x, z) expressed in the World system.
  20202. * @param x x coordinate
  20203. * @param z z coordinate
  20204. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20205. */
  20206. getNormalAtCoordinates(x: number, z: number): Vector3;
  20207. /**
  20208. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20209. * at the ground coordinates (x, z) expressed in the World system.
  20210. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20211. * @param x x coordinate
  20212. * @param z z coordinate
  20213. * @param ref vector to store the result
  20214. * @returns the GroundMesh.
  20215. */
  20216. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20217. /**
  20218. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20219. * if the ground has been updated.
  20220. * This can be used in the render loop.
  20221. * @returns the GroundMesh.
  20222. */
  20223. updateCoordinateHeights(): GroundMesh;
  20224. private _getFacetAt;
  20225. private _initHeightQuads;
  20226. private _computeHeightQuads;
  20227. /**
  20228. * Serializes this ground mesh
  20229. * @param serializationObject object to write serialization to
  20230. */
  20231. serialize(serializationObject: any): void;
  20232. /**
  20233. * Parses a serialized ground mesh
  20234. * @param parsedMesh the serialized mesh
  20235. * @param scene the scene to create the ground mesh in
  20236. * @returns the created ground mesh
  20237. */
  20238. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20239. }
  20240. }
  20241. declare module "babylonjs/Physics/physicsJoint" {
  20242. import { Vector3 } from "babylonjs/Maths/math";
  20243. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  20244. /**
  20245. * Interface for Physics-Joint data
  20246. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20247. */
  20248. export interface PhysicsJointData {
  20249. /**
  20250. * The main pivot of the joint
  20251. */
  20252. mainPivot?: Vector3;
  20253. /**
  20254. * The connected pivot of the joint
  20255. */
  20256. connectedPivot?: Vector3;
  20257. /**
  20258. * The main axis of the joint
  20259. */
  20260. mainAxis?: Vector3;
  20261. /**
  20262. * The connected axis of the joint
  20263. */
  20264. connectedAxis?: Vector3;
  20265. /**
  20266. * The collision of the joint
  20267. */
  20268. collision?: boolean;
  20269. /**
  20270. * Native Oimo/Cannon/Energy data
  20271. */
  20272. nativeParams?: any;
  20273. }
  20274. /**
  20275. * This is a holder class for the physics joint created by the physics plugin
  20276. * It holds a set of functions to control the underlying joint
  20277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20278. */
  20279. export class PhysicsJoint {
  20280. /**
  20281. * The type of the physics joint
  20282. */
  20283. type: number;
  20284. /**
  20285. * The data for the physics joint
  20286. */
  20287. jointData: PhysicsJointData;
  20288. private _physicsJoint;
  20289. protected _physicsPlugin: IPhysicsEnginePlugin;
  20290. /**
  20291. * Initializes the physics joint
  20292. * @param type The type of the physics joint
  20293. * @param jointData The data for the physics joint
  20294. */
  20295. constructor(
  20296. /**
  20297. * The type of the physics joint
  20298. */
  20299. type: number,
  20300. /**
  20301. * The data for the physics joint
  20302. */
  20303. jointData: PhysicsJointData);
  20304. /**
  20305. * Gets the physics joint
  20306. */
  20307. /**
  20308. * Sets the physics joint
  20309. */
  20310. physicsJoint: any;
  20311. /**
  20312. * Sets the physics plugin
  20313. */
  20314. physicsPlugin: IPhysicsEnginePlugin;
  20315. /**
  20316. * Execute a function that is physics-plugin specific.
  20317. * @param {Function} func the function that will be executed.
  20318. * It accepts two parameters: the physics world and the physics joint
  20319. */
  20320. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20321. /**
  20322. * Distance-Joint type
  20323. */
  20324. static DistanceJoint: number;
  20325. /**
  20326. * Hinge-Joint type
  20327. */
  20328. static HingeJoint: number;
  20329. /**
  20330. * Ball-and-Socket joint type
  20331. */
  20332. static BallAndSocketJoint: number;
  20333. /**
  20334. * Wheel-Joint type
  20335. */
  20336. static WheelJoint: number;
  20337. /**
  20338. * Slider-Joint type
  20339. */
  20340. static SliderJoint: number;
  20341. /**
  20342. * Prismatic-Joint type
  20343. */
  20344. static PrismaticJoint: number;
  20345. /**
  20346. * Universal-Joint type
  20347. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  20348. */
  20349. static UniversalJoint: number;
  20350. /**
  20351. * Hinge-Joint 2 type
  20352. */
  20353. static Hinge2Joint: number;
  20354. /**
  20355. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  20356. */
  20357. static PointToPointJoint: number;
  20358. /**
  20359. * Spring-Joint type
  20360. */
  20361. static SpringJoint: number;
  20362. /**
  20363. * Lock-Joint type
  20364. */
  20365. static LockJoint: number;
  20366. }
  20367. /**
  20368. * A class representing a physics distance joint
  20369. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20370. */
  20371. export class DistanceJoint extends PhysicsJoint {
  20372. /**
  20373. *
  20374. * @param jointData The data for the Distance-Joint
  20375. */
  20376. constructor(jointData: DistanceJointData);
  20377. /**
  20378. * Update the predefined distance.
  20379. * @param maxDistance The maximum preferred distance
  20380. * @param minDistance The minimum preferred distance
  20381. */
  20382. updateDistance(maxDistance: number, minDistance?: number): void;
  20383. }
  20384. /**
  20385. * Represents a Motor-Enabled Joint
  20386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20387. */
  20388. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20389. /**
  20390. * Initializes the Motor-Enabled Joint
  20391. * @param type The type of the joint
  20392. * @param jointData The physica joint data for the joint
  20393. */
  20394. constructor(type: number, jointData: PhysicsJointData);
  20395. /**
  20396. * Set the motor values.
  20397. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20398. * @param force the force to apply
  20399. * @param maxForce max force for this motor.
  20400. */
  20401. setMotor(force?: number, maxForce?: number): void;
  20402. /**
  20403. * Set the motor's limits.
  20404. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20405. * @param upperLimit The upper limit of the motor
  20406. * @param lowerLimit The lower limit of the motor
  20407. */
  20408. setLimit(upperLimit: number, lowerLimit?: number): void;
  20409. }
  20410. /**
  20411. * This class represents a single physics Hinge-Joint
  20412. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20413. */
  20414. export class HingeJoint extends MotorEnabledJoint {
  20415. /**
  20416. * Initializes the Hinge-Joint
  20417. * @param jointData The joint data for the Hinge-Joint
  20418. */
  20419. constructor(jointData: PhysicsJointData);
  20420. /**
  20421. * Set the motor values.
  20422. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20423. * @param {number} force the force to apply
  20424. * @param {number} maxForce max force for this motor.
  20425. */
  20426. setMotor(force?: number, maxForce?: number): void;
  20427. /**
  20428. * Set the motor's limits.
  20429. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20430. * @param upperLimit The upper limit of the motor
  20431. * @param lowerLimit The lower limit of the motor
  20432. */
  20433. setLimit(upperLimit: number, lowerLimit?: number): void;
  20434. }
  20435. /**
  20436. * This class represents a dual hinge physics joint (same as wheel joint)
  20437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20438. */
  20439. export class Hinge2Joint extends MotorEnabledJoint {
  20440. /**
  20441. * Initializes the Hinge2-Joint
  20442. * @param jointData The joint data for the Hinge2-Joint
  20443. */
  20444. constructor(jointData: PhysicsJointData);
  20445. /**
  20446. * Set the motor values.
  20447. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20448. * @param {number} targetSpeed the speed the motor is to reach
  20449. * @param {number} maxForce max force for this motor.
  20450. * @param {motorIndex} the motor's index, 0 or 1.
  20451. */
  20452. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20453. /**
  20454. * Set the motor limits.
  20455. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20456. * @param {number} upperLimit the upper limit
  20457. * @param {number} lowerLimit lower limit
  20458. * @param {motorIndex} the motor's index, 0 or 1.
  20459. */
  20460. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20461. }
  20462. /**
  20463. * Interface for a motor enabled joint
  20464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20465. */
  20466. export interface IMotorEnabledJoint {
  20467. /**
  20468. * Physics joint
  20469. */
  20470. physicsJoint: any;
  20471. /**
  20472. * Sets the motor of the motor-enabled joint
  20473. * @param force The force of the motor
  20474. * @param maxForce The maximum force of the motor
  20475. * @param motorIndex The index of the motor
  20476. */
  20477. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20478. /**
  20479. * Sets the limit of the motor
  20480. * @param upperLimit The upper limit of the motor
  20481. * @param lowerLimit The lower limit of the motor
  20482. * @param motorIndex The index of the motor
  20483. */
  20484. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20485. }
  20486. /**
  20487. * Joint data for a Distance-Joint
  20488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20489. */
  20490. export interface DistanceJointData extends PhysicsJointData {
  20491. /**
  20492. * Max distance the 2 joint objects can be apart
  20493. */
  20494. maxDistance: number;
  20495. }
  20496. /**
  20497. * Joint data from a spring joint
  20498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20499. */
  20500. export interface SpringJointData extends PhysicsJointData {
  20501. /**
  20502. * Length of the spring
  20503. */
  20504. length: number;
  20505. /**
  20506. * Stiffness of the spring
  20507. */
  20508. stiffness: number;
  20509. /**
  20510. * Damping of the spring
  20511. */
  20512. damping: number;
  20513. /** this callback will be called when applying the force to the impostors. */
  20514. forceApplicationCallback: () => void;
  20515. }
  20516. }
  20517. declare module "babylonjs/Physics/physicsRaycastResult" {
  20518. import { Vector3 } from "babylonjs/Maths/math";
  20519. /**
  20520. * Holds the data for the raycast result
  20521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20522. */
  20523. export class PhysicsRaycastResult {
  20524. private _hasHit;
  20525. private _hitDistance;
  20526. private _hitNormalWorld;
  20527. private _hitPointWorld;
  20528. private _rayFromWorld;
  20529. private _rayToWorld;
  20530. /**
  20531. * Gets if there was a hit
  20532. */
  20533. readonly hasHit: boolean;
  20534. /**
  20535. * Gets the distance from the hit
  20536. */
  20537. readonly hitDistance: number;
  20538. /**
  20539. * Gets the hit normal/direction in the world
  20540. */
  20541. readonly hitNormalWorld: Vector3;
  20542. /**
  20543. * Gets the hit point in the world
  20544. */
  20545. readonly hitPointWorld: Vector3;
  20546. /**
  20547. * Gets the ray "start point" of the ray in the world
  20548. */
  20549. readonly rayFromWorld: Vector3;
  20550. /**
  20551. * Gets the ray "end point" of the ray in the world
  20552. */
  20553. readonly rayToWorld: Vector3;
  20554. /**
  20555. * Sets the hit data (normal & point in world space)
  20556. * @param hitNormalWorld defines the normal in world space
  20557. * @param hitPointWorld defines the point in world space
  20558. */
  20559. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20560. /**
  20561. * Sets the distance from the start point to the hit point
  20562. * @param distance
  20563. */
  20564. setHitDistance(distance: number): void;
  20565. /**
  20566. * Calculates the distance manually
  20567. */
  20568. calculateHitDistance(): void;
  20569. /**
  20570. * Resets all the values to default
  20571. * @param from The from point on world space
  20572. * @param to The to point on world space
  20573. */
  20574. reset(from?: Vector3, to?: Vector3): void;
  20575. }
  20576. /**
  20577. * Interface for the size containing width and height
  20578. */
  20579. interface IXYZ {
  20580. /**
  20581. * X
  20582. */
  20583. x: number;
  20584. /**
  20585. * Y
  20586. */
  20587. y: number;
  20588. /**
  20589. * Z
  20590. */
  20591. z: number;
  20592. }
  20593. }
  20594. declare module "babylonjs/Physics/IPhysicsEngine" {
  20595. import { Nullable } from "babylonjs/types";
  20596. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20598. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20599. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20600. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20601. /**
  20602. * Interface used to describe a physics joint
  20603. */
  20604. export interface PhysicsImpostorJoint {
  20605. /** Defines the main impostor to which the joint is linked */
  20606. mainImpostor: PhysicsImpostor;
  20607. /** Defines the impostor that is connected to the main impostor using this joint */
  20608. connectedImpostor: PhysicsImpostor;
  20609. /** Defines the joint itself */
  20610. joint: PhysicsJoint;
  20611. }
  20612. /** @hidden */
  20613. export interface IPhysicsEnginePlugin {
  20614. world: any;
  20615. name: string;
  20616. setGravity(gravity: Vector3): void;
  20617. setTimeStep(timeStep: number): void;
  20618. getTimeStep(): number;
  20619. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20620. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20621. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20622. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20623. removePhysicsBody(impostor: PhysicsImpostor): void;
  20624. generateJoint(joint: PhysicsImpostorJoint): void;
  20625. removeJoint(joint: PhysicsImpostorJoint): void;
  20626. isSupported(): boolean;
  20627. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20628. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20629. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20630. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20631. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20632. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20633. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20634. getBodyMass(impostor: PhysicsImpostor): number;
  20635. getBodyFriction(impostor: PhysicsImpostor): number;
  20636. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20637. getBodyRestitution(impostor: PhysicsImpostor): number;
  20638. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20639. getBodyPressure?(impostor: PhysicsImpostor): number;
  20640. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20641. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20642. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20643. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20644. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20645. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20646. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20647. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20648. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20649. sleepBody(impostor: PhysicsImpostor): void;
  20650. wakeUpBody(impostor: PhysicsImpostor): void;
  20651. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20652. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20653. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20654. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20655. getRadius(impostor: PhysicsImpostor): number;
  20656. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20657. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20658. dispose(): void;
  20659. }
  20660. /**
  20661. * Interface used to define a physics engine
  20662. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20663. */
  20664. export interface IPhysicsEngine {
  20665. /**
  20666. * Gets the gravity vector used by the simulation
  20667. */
  20668. gravity: Vector3;
  20669. /**
  20670. * Sets the gravity vector used by the simulation
  20671. * @param gravity defines the gravity vector to use
  20672. */
  20673. setGravity(gravity: Vector3): void;
  20674. /**
  20675. * Set the time step of the physics engine.
  20676. * Default is 1/60.
  20677. * To slow it down, enter 1/600 for example.
  20678. * To speed it up, 1/30
  20679. * @param newTimeStep the new timestep to apply to this world.
  20680. */
  20681. setTimeStep(newTimeStep: number): void;
  20682. /**
  20683. * Get the time step of the physics engine.
  20684. * @returns the current time step
  20685. */
  20686. getTimeStep(): number;
  20687. /**
  20688. * Release all resources
  20689. */
  20690. dispose(): void;
  20691. /**
  20692. * Gets the name of the current physics plugin
  20693. * @returns the name of the plugin
  20694. */
  20695. getPhysicsPluginName(): string;
  20696. /**
  20697. * Adding a new impostor for the impostor tracking.
  20698. * This will be done by the impostor itself.
  20699. * @param impostor the impostor to add
  20700. */
  20701. addImpostor(impostor: PhysicsImpostor): void;
  20702. /**
  20703. * Remove an impostor from the engine.
  20704. * This impostor and its mesh will not longer be updated by the physics engine.
  20705. * @param impostor the impostor to remove
  20706. */
  20707. removeImpostor(impostor: PhysicsImpostor): void;
  20708. /**
  20709. * Add a joint to the physics engine
  20710. * @param mainImpostor defines the main impostor to which the joint is added.
  20711. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20712. * @param joint defines the joint that will connect both impostors.
  20713. */
  20714. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20715. /**
  20716. * Removes a joint from the simulation
  20717. * @param mainImpostor defines the impostor used with the joint
  20718. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20719. * @param joint defines the joint to remove
  20720. */
  20721. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20722. /**
  20723. * Gets the current plugin used to run the simulation
  20724. * @returns current plugin
  20725. */
  20726. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20727. /**
  20728. * Gets the list of physic impostors
  20729. * @returns an array of PhysicsImpostor
  20730. */
  20731. getImpostors(): Array<PhysicsImpostor>;
  20732. /**
  20733. * Gets the impostor for a physics enabled object
  20734. * @param object defines the object impersonated by the impostor
  20735. * @returns the PhysicsImpostor or null if not found
  20736. */
  20737. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20738. /**
  20739. * Gets the impostor for a physics body object
  20740. * @param body defines physics body used by the impostor
  20741. * @returns the PhysicsImpostor or null if not found
  20742. */
  20743. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20744. /**
  20745. * Does a raycast in the physics world
  20746. * @param from when should the ray start?
  20747. * @param to when should the ray end?
  20748. * @returns PhysicsRaycastResult
  20749. */
  20750. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20751. /**
  20752. * Called by the scene. No need to call it.
  20753. * @param delta defines the timespam between frames
  20754. */
  20755. _step(delta: number): void;
  20756. }
  20757. }
  20758. declare module "babylonjs/Physics/physicsImpostor" {
  20759. import { Nullable, IndicesArray } from "babylonjs/types";
  20760. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20761. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20763. import { Scene } from "babylonjs/scene";
  20764. import { Bone } from "babylonjs/Bones/bone";
  20765. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20766. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20767. /**
  20768. * The interface for the physics imposter parameters
  20769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20770. */
  20771. export interface PhysicsImpostorParameters {
  20772. /**
  20773. * The mass of the physics imposter
  20774. */
  20775. mass: number;
  20776. /**
  20777. * The friction of the physics imposter
  20778. */
  20779. friction?: number;
  20780. /**
  20781. * The coefficient of restitution of the physics imposter
  20782. */
  20783. restitution?: number;
  20784. /**
  20785. * The native options of the physics imposter
  20786. */
  20787. nativeOptions?: any;
  20788. /**
  20789. * Specifies if the parent should be ignored
  20790. */
  20791. ignoreParent?: boolean;
  20792. /**
  20793. * Specifies if bi-directional transformations should be disabled
  20794. */
  20795. disableBidirectionalTransformation?: boolean;
  20796. /**
  20797. * The pressure inside the physics imposter, soft object only
  20798. */
  20799. pressure?: number;
  20800. /**
  20801. * The stiffness the physics imposter, soft object only
  20802. */
  20803. stiffness?: number;
  20804. /**
  20805. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20806. */
  20807. velocityIterations?: number;
  20808. /**
  20809. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20810. */
  20811. positionIterations?: number;
  20812. /**
  20813. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20814. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20815. * Add to fix multiple points
  20816. */
  20817. fixedPoints?: number;
  20818. /**
  20819. * The collision margin around a soft object
  20820. */
  20821. margin?: number;
  20822. /**
  20823. * The collision margin around a soft object
  20824. */
  20825. damping?: number;
  20826. /**
  20827. * The path for a rope based on an extrusion
  20828. */
  20829. path?: any;
  20830. /**
  20831. * The shape of an extrusion used for a rope based on an extrusion
  20832. */
  20833. shape?: any;
  20834. }
  20835. /**
  20836. * Interface for a physics-enabled object
  20837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20838. */
  20839. export interface IPhysicsEnabledObject {
  20840. /**
  20841. * The position of the physics-enabled object
  20842. */
  20843. position: Vector3;
  20844. /**
  20845. * The rotation of the physics-enabled object
  20846. */
  20847. rotationQuaternion: Nullable<Quaternion>;
  20848. /**
  20849. * The scale of the physics-enabled object
  20850. */
  20851. scaling: Vector3;
  20852. /**
  20853. * The rotation of the physics-enabled object
  20854. */
  20855. rotation?: Vector3;
  20856. /**
  20857. * The parent of the physics-enabled object
  20858. */
  20859. parent?: any;
  20860. /**
  20861. * The bounding info of the physics-enabled object
  20862. * @returns The bounding info of the physics-enabled object
  20863. */
  20864. getBoundingInfo(): BoundingInfo;
  20865. /**
  20866. * Computes the world matrix
  20867. * @param force Specifies if the world matrix should be computed by force
  20868. * @returns A world matrix
  20869. */
  20870. computeWorldMatrix(force: boolean): Matrix;
  20871. /**
  20872. * Gets the world matrix
  20873. * @returns A world matrix
  20874. */
  20875. getWorldMatrix?(): Matrix;
  20876. /**
  20877. * Gets the child meshes
  20878. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20879. * @returns An array of abstract meshes
  20880. */
  20881. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20882. /**
  20883. * Gets the vertex data
  20884. * @param kind The type of vertex data
  20885. * @returns A nullable array of numbers, or a float32 array
  20886. */
  20887. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20888. /**
  20889. * Gets the indices from the mesh
  20890. * @returns A nullable array of index arrays
  20891. */
  20892. getIndices?(): Nullable<IndicesArray>;
  20893. /**
  20894. * Gets the scene from the mesh
  20895. * @returns the indices array or null
  20896. */
  20897. getScene?(): Scene;
  20898. /**
  20899. * Gets the absolute position from the mesh
  20900. * @returns the absolute position
  20901. */
  20902. getAbsolutePosition(): Vector3;
  20903. /**
  20904. * Gets the absolute pivot point from the mesh
  20905. * @returns the absolute pivot point
  20906. */
  20907. getAbsolutePivotPoint(): Vector3;
  20908. /**
  20909. * Rotates the mesh
  20910. * @param axis The axis of rotation
  20911. * @param amount The amount of rotation
  20912. * @param space The space of the rotation
  20913. * @returns The rotation transform node
  20914. */
  20915. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20916. /**
  20917. * Translates the mesh
  20918. * @param axis The axis of translation
  20919. * @param distance The distance of translation
  20920. * @param space The space of the translation
  20921. * @returns The transform node
  20922. */
  20923. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20924. /**
  20925. * Sets the absolute position of the mesh
  20926. * @param absolutePosition The absolute position of the mesh
  20927. * @returns The transform node
  20928. */
  20929. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20930. /**
  20931. * Gets the class name of the mesh
  20932. * @returns The class name
  20933. */
  20934. getClassName(): string;
  20935. }
  20936. /**
  20937. * Represents a physics imposter
  20938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20939. */
  20940. export class PhysicsImpostor {
  20941. /**
  20942. * The physics-enabled object used as the physics imposter
  20943. */
  20944. object: IPhysicsEnabledObject;
  20945. /**
  20946. * The type of the physics imposter
  20947. */
  20948. type: number;
  20949. private _options;
  20950. private _scene?;
  20951. /**
  20952. * The default object size of the imposter
  20953. */
  20954. static DEFAULT_OBJECT_SIZE: Vector3;
  20955. /**
  20956. * The identity quaternion of the imposter
  20957. */
  20958. static IDENTITY_QUATERNION: Quaternion;
  20959. /** @hidden */
  20960. _pluginData: any;
  20961. private _physicsEngine;
  20962. private _physicsBody;
  20963. private _bodyUpdateRequired;
  20964. private _onBeforePhysicsStepCallbacks;
  20965. private _onAfterPhysicsStepCallbacks;
  20966. /** @hidden */
  20967. _onPhysicsCollideCallbacks: Array<{
  20968. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20969. otherImpostors: Array<PhysicsImpostor>;
  20970. }>;
  20971. private _deltaPosition;
  20972. private _deltaRotation;
  20973. private _deltaRotationConjugated;
  20974. /** hidden */
  20975. _isFromLine: boolean;
  20976. private _parent;
  20977. private _isDisposed;
  20978. private static _tmpVecs;
  20979. private static _tmpQuat;
  20980. /**
  20981. * Specifies if the physics imposter is disposed
  20982. */
  20983. readonly isDisposed: boolean;
  20984. /**
  20985. * Gets the mass of the physics imposter
  20986. */
  20987. mass: number;
  20988. /**
  20989. * Gets the coefficient of friction
  20990. */
  20991. /**
  20992. * Sets the coefficient of friction
  20993. */
  20994. friction: number;
  20995. /**
  20996. * Gets the coefficient of restitution
  20997. */
  20998. /**
  20999. * Sets the coefficient of restitution
  21000. */
  21001. restitution: number;
  21002. /**
  21003. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  21004. */
  21005. /**
  21006. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  21007. */
  21008. pressure: number;
  21009. /**
  21010. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21011. */
  21012. /**
  21013. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21014. */
  21015. stiffness: number;
  21016. /**
  21017. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21018. */
  21019. /**
  21020. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21021. */
  21022. velocityIterations: number;
  21023. /**
  21024. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21025. */
  21026. /**
  21027. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21028. */
  21029. positionIterations: number;
  21030. /**
  21031. * The unique id of the physics imposter
  21032. * set by the physics engine when adding this impostor to the array
  21033. */
  21034. uniqueId: number;
  21035. /**
  21036. * @hidden
  21037. */
  21038. soft: boolean;
  21039. /**
  21040. * @hidden
  21041. */
  21042. segments: number;
  21043. private _joints;
  21044. /**
  21045. * Initializes the physics imposter
  21046. * @param object The physics-enabled object used as the physics imposter
  21047. * @param type The type of the physics imposter
  21048. * @param _options The options for the physics imposter
  21049. * @param _scene The Babylon scene
  21050. */
  21051. constructor(
  21052. /**
  21053. * The physics-enabled object used as the physics imposter
  21054. */
  21055. object: IPhysicsEnabledObject,
  21056. /**
  21057. * The type of the physics imposter
  21058. */
  21059. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  21060. /**
  21061. * This function will completly initialize this impostor.
  21062. * It will create a new body - but only if this mesh has no parent.
  21063. * If it has, this impostor will not be used other than to define the impostor
  21064. * of the child mesh.
  21065. * @hidden
  21066. */
  21067. _init(): void;
  21068. private _getPhysicsParent;
  21069. /**
  21070. * Should a new body be generated.
  21071. * @returns boolean specifying if body initialization is required
  21072. */
  21073. isBodyInitRequired(): boolean;
  21074. /**
  21075. * Sets the updated scaling
  21076. * @param updated Specifies if the scaling is updated
  21077. */
  21078. setScalingUpdated(): void;
  21079. /**
  21080. * Force a regeneration of this or the parent's impostor's body.
  21081. * Use under cautious - This will remove all joints already implemented.
  21082. */
  21083. forceUpdate(): void;
  21084. /**
  21085. * Gets the body that holds this impostor. Either its own, or its parent.
  21086. */
  21087. /**
  21088. * Set the physics body. Used mainly by the physics engine/plugin
  21089. */
  21090. physicsBody: any;
  21091. /**
  21092. * Get the parent of the physics imposter
  21093. * @returns Physics imposter or null
  21094. */
  21095. /**
  21096. * Sets the parent of the physics imposter
  21097. */
  21098. parent: Nullable<PhysicsImpostor>;
  21099. /**
  21100. * Resets the update flags
  21101. */
  21102. resetUpdateFlags(): void;
  21103. /**
  21104. * Gets the object extend size
  21105. * @returns the object extend size
  21106. */
  21107. getObjectExtendSize(): Vector3;
  21108. /**
  21109. * Gets the object center
  21110. * @returns The object center
  21111. */
  21112. getObjectCenter(): Vector3;
  21113. /**
  21114. * Get a specific parametes from the options parameter
  21115. * @param paramName The object parameter name
  21116. * @returns The object parameter
  21117. */
  21118. getParam(paramName: string): any;
  21119. /**
  21120. * Sets a specific parameter in the options given to the physics plugin
  21121. * @param paramName The parameter name
  21122. * @param value The value of the parameter
  21123. */
  21124. setParam(paramName: string, value: number): void;
  21125. /**
  21126. * Specifically change the body's mass option. Won't recreate the physics body object
  21127. * @param mass The mass of the physics imposter
  21128. */
  21129. setMass(mass: number): void;
  21130. /**
  21131. * Gets the linear velocity
  21132. * @returns linear velocity or null
  21133. */
  21134. getLinearVelocity(): Nullable<Vector3>;
  21135. /**
  21136. * Sets the linear velocity
  21137. * @param velocity linear velocity or null
  21138. */
  21139. setLinearVelocity(velocity: Nullable<Vector3>): void;
  21140. /**
  21141. * Gets the angular velocity
  21142. * @returns angular velocity or null
  21143. */
  21144. getAngularVelocity(): Nullable<Vector3>;
  21145. /**
  21146. * Sets the angular velocity
  21147. * @param velocity The velocity or null
  21148. */
  21149. setAngularVelocity(velocity: Nullable<Vector3>): void;
  21150. /**
  21151. * Execute a function with the physics plugin native code
  21152. * Provide a function the will have two variables - the world object and the physics body object
  21153. * @param func The function to execute with the physics plugin native code
  21154. */
  21155. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  21156. /**
  21157. * Register a function that will be executed before the physics world is stepping forward
  21158. * @param func The function to execute before the physics world is stepped forward
  21159. */
  21160. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21161. /**
  21162. * Unregister a function that will be executed before the physics world is stepping forward
  21163. * @param func The function to execute before the physics world is stepped forward
  21164. */
  21165. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21166. /**
  21167. * Register a function that will be executed after the physics step
  21168. * @param func The function to execute after physics step
  21169. */
  21170. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21171. /**
  21172. * Unregisters a function that will be executed after the physics step
  21173. * @param func The function to execute after physics step
  21174. */
  21175. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21176. /**
  21177. * register a function that will be executed when this impostor collides against a different body
  21178. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  21179. * @param func Callback that is executed on collision
  21180. */
  21181. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  21182. /**
  21183. * Unregisters the physics imposter on contact
  21184. * @param collideAgainst The physics object to collide against
  21185. * @param func Callback to execute on collision
  21186. */
  21187. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  21188. private _tmpQuat;
  21189. private _tmpQuat2;
  21190. /**
  21191. * Get the parent rotation
  21192. * @returns The parent rotation
  21193. */
  21194. getParentsRotation(): Quaternion;
  21195. /**
  21196. * this function is executed by the physics engine.
  21197. */
  21198. beforeStep: () => void;
  21199. /**
  21200. * this function is executed by the physics engine
  21201. */
  21202. afterStep: () => void;
  21203. /**
  21204. * Legacy collision detection event support
  21205. */
  21206. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  21207. /**
  21208. * event and body object due to cannon's event-based architecture.
  21209. */
  21210. onCollide: (e: {
  21211. body: any;
  21212. }) => void;
  21213. /**
  21214. * Apply a force
  21215. * @param force The force to apply
  21216. * @param contactPoint The contact point for the force
  21217. * @returns The physics imposter
  21218. */
  21219. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21220. /**
  21221. * Apply an impulse
  21222. * @param force The impulse force
  21223. * @param contactPoint The contact point for the impulse force
  21224. * @returns The physics imposter
  21225. */
  21226. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21227. /**
  21228. * A help function to create a joint
  21229. * @param otherImpostor A physics imposter used to create a joint
  21230. * @param jointType The type of joint
  21231. * @param jointData The data for the joint
  21232. * @returns The physics imposter
  21233. */
  21234. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  21235. /**
  21236. * Add a joint to this impostor with a different impostor
  21237. * @param otherImpostor A physics imposter used to add a joint
  21238. * @param joint The joint to add
  21239. * @returns The physics imposter
  21240. */
  21241. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  21242. /**
  21243. * Add an anchor to a cloth impostor
  21244. * @param otherImpostor rigid impostor to anchor to
  21245. * @param width ratio across width from 0 to 1
  21246. * @param height ratio up height from 0 to 1
  21247. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  21248. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  21249. * @returns impostor the soft imposter
  21250. */
  21251. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21252. /**
  21253. * Add a hook to a rope impostor
  21254. * @param otherImpostor rigid impostor to anchor to
  21255. * @param length ratio across rope from 0 to 1
  21256. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  21257. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  21258. * @returns impostor the rope imposter
  21259. */
  21260. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21261. /**
  21262. * Will keep this body still, in a sleep mode.
  21263. * @returns the physics imposter
  21264. */
  21265. sleep(): PhysicsImpostor;
  21266. /**
  21267. * Wake the body up.
  21268. * @returns The physics imposter
  21269. */
  21270. wakeUp(): PhysicsImpostor;
  21271. /**
  21272. * Clones the physics imposter
  21273. * @param newObject The physics imposter clones to this physics-enabled object
  21274. * @returns A nullable physics imposter
  21275. */
  21276. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  21277. /**
  21278. * Disposes the physics imposter
  21279. */
  21280. dispose(): void;
  21281. /**
  21282. * Sets the delta position
  21283. * @param position The delta position amount
  21284. */
  21285. setDeltaPosition(position: Vector3): void;
  21286. /**
  21287. * Sets the delta rotation
  21288. * @param rotation The delta rotation amount
  21289. */
  21290. setDeltaRotation(rotation: Quaternion): void;
  21291. /**
  21292. * Gets the box size of the physics imposter and stores the result in the input parameter
  21293. * @param result Stores the box size
  21294. * @returns The physics imposter
  21295. */
  21296. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  21297. /**
  21298. * Gets the radius of the physics imposter
  21299. * @returns Radius of the physics imposter
  21300. */
  21301. getRadius(): number;
  21302. /**
  21303. * Sync a bone with this impostor
  21304. * @param bone The bone to sync to the impostor.
  21305. * @param boneMesh The mesh that the bone is influencing.
  21306. * @param jointPivot The pivot of the joint / bone in local space.
  21307. * @param distToJoint Optional distance from the impostor to the joint.
  21308. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21309. */
  21310. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  21311. /**
  21312. * Sync impostor to a bone
  21313. * @param bone The bone that the impostor will be synced to.
  21314. * @param boneMesh The mesh that the bone is influencing.
  21315. * @param jointPivot The pivot of the joint / bone in local space.
  21316. * @param distToJoint Optional distance from the impostor to the joint.
  21317. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21318. * @param boneAxis Optional vector3 axis the bone is aligned with
  21319. */
  21320. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  21321. /**
  21322. * No-Imposter type
  21323. */
  21324. static NoImpostor: number;
  21325. /**
  21326. * Sphere-Imposter type
  21327. */
  21328. static SphereImpostor: number;
  21329. /**
  21330. * Box-Imposter type
  21331. */
  21332. static BoxImpostor: number;
  21333. /**
  21334. * Plane-Imposter type
  21335. */
  21336. static PlaneImpostor: number;
  21337. /**
  21338. * Mesh-imposter type
  21339. */
  21340. static MeshImpostor: number;
  21341. /**
  21342. * Cylinder-Imposter type
  21343. */
  21344. static CylinderImpostor: number;
  21345. /**
  21346. * Particle-Imposter type
  21347. */
  21348. static ParticleImpostor: number;
  21349. /**
  21350. * Heightmap-Imposter type
  21351. */
  21352. static HeightmapImpostor: number;
  21353. /**
  21354. * ConvexHull-Impostor type (Ammo.js plugin only)
  21355. */
  21356. static ConvexHullImpostor: number;
  21357. /**
  21358. * Rope-Imposter type
  21359. */
  21360. static RopeImpostor: number;
  21361. /**
  21362. * Cloth-Imposter type
  21363. */
  21364. static ClothImpostor: number;
  21365. /**
  21366. * Softbody-Imposter type
  21367. */
  21368. static SoftbodyImpostor: number;
  21369. }
  21370. }
  21371. declare module "babylonjs/Meshes/mesh" {
  21372. import { Observable } from "babylonjs/Misc/observable";
  21373. import { IAnimatable } from "babylonjs/Misc/tools";
  21374. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21375. import { Camera } from "babylonjs/Cameras/camera";
  21376. import { Scene } from "babylonjs/scene";
  21377. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  21378. import { Engine } from "babylonjs/Engines/engine";
  21379. import { Node } from "babylonjs/node";
  21380. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21381. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21382. import { Buffer } from "babylonjs/Meshes/buffer";
  21383. import { Geometry } from "babylonjs/Meshes/geometry";
  21384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21385. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21386. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21387. import { Effect } from "babylonjs/Materials/effect";
  21388. import { Material } from "babylonjs/Materials/material";
  21389. import { Skeleton } from "babylonjs/Bones/skeleton";
  21390. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  21391. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  21392. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  21393. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  21394. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  21395. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  21396. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  21397. /**
  21398. * @hidden
  21399. **/
  21400. export class _CreationDataStorage {
  21401. closePath?: boolean;
  21402. closeArray?: boolean;
  21403. idx: number[];
  21404. dashSize: number;
  21405. gapSize: number;
  21406. path3D: Path3D;
  21407. pathArray: Vector3[][];
  21408. arc: number;
  21409. radius: number;
  21410. cap: number;
  21411. tessellation: number;
  21412. }
  21413. /**
  21414. * @hidden
  21415. **/
  21416. class _InstanceDataStorage {
  21417. visibleInstances: any;
  21418. batchCache: _InstancesBatch;
  21419. instancesBufferSize: number;
  21420. instancesBuffer: Nullable<Buffer>;
  21421. instancesData: Float32Array;
  21422. overridenInstanceCount: number;
  21423. isFrozen: boolean;
  21424. previousBatch: _InstancesBatch;
  21425. hardwareInstancedRendering: boolean;
  21426. sideOrientation: number;
  21427. }
  21428. /**
  21429. * @hidden
  21430. **/
  21431. export class _InstancesBatch {
  21432. mustReturn: boolean;
  21433. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21434. renderSelf: boolean[];
  21435. hardwareInstancedRendering: boolean[];
  21436. }
  21437. /**
  21438. * Class used to represent renderable models
  21439. */
  21440. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21441. /**
  21442. * Mesh side orientation : usually the external or front surface
  21443. */
  21444. static readonly FRONTSIDE: number;
  21445. /**
  21446. * Mesh side orientation : usually the internal or back surface
  21447. */
  21448. static readonly BACKSIDE: number;
  21449. /**
  21450. * Mesh side orientation : both internal and external or front and back surfaces
  21451. */
  21452. static readonly DOUBLESIDE: number;
  21453. /**
  21454. * Mesh side orientation : by default, `FRONTSIDE`
  21455. */
  21456. static readonly DEFAULTSIDE: number;
  21457. /**
  21458. * Mesh cap setting : no cap
  21459. */
  21460. static readonly NO_CAP: number;
  21461. /**
  21462. * Mesh cap setting : one cap at the beginning of the mesh
  21463. */
  21464. static readonly CAP_START: number;
  21465. /**
  21466. * Mesh cap setting : one cap at the end of the mesh
  21467. */
  21468. static readonly CAP_END: number;
  21469. /**
  21470. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21471. */
  21472. static readonly CAP_ALL: number;
  21473. /**
  21474. * Gets the default side orientation.
  21475. * @param orientation the orientation to value to attempt to get
  21476. * @returns the default orientation
  21477. * @hidden
  21478. */
  21479. static _GetDefaultSideOrientation(orientation?: number): number;
  21480. private _internalMeshDataInfo;
  21481. /**
  21482. * An event triggered before rendering the mesh
  21483. */
  21484. readonly onBeforeRenderObservable: Observable<Mesh>;
  21485. /**
  21486. * An event triggered before binding the mesh
  21487. */
  21488. readonly onBeforeBindObservable: Observable<Mesh>;
  21489. /**
  21490. * An event triggered after rendering the mesh
  21491. */
  21492. readonly onAfterRenderObservable: Observable<Mesh>;
  21493. /**
  21494. * An event triggered before drawing the mesh
  21495. */
  21496. readonly onBeforeDrawObservable: Observable<Mesh>;
  21497. private _onBeforeDrawObserver;
  21498. /**
  21499. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21500. */
  21501. onBeforeDraw: () => void;
  21502. /**
  21503. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21504. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21505. */
  21506. delayLoadState: number;
  21507. /**
  21508. * Gets the list of instances created from this mesh
  21509. * it is not supposed to be modified manually.
  21510. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21511. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21512. */
  21513. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21514. /**
  21515. * Gets the file containing delay loading data for this mesh
  21516. */
  21517. delayLoadingFile: string;
  21518. /** @hidden */
  21519. _binaryInfo: any;
  21520. /**
  21521. * User defined function used to change how LOD level selection is done
  21522. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21523. */
  21524. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21525. /**
  21526. * Gets or sets the morph target manager
  21527. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21528. */
  21529. morphTargetManager: Nullable<MorphTargetManager>;
  21530. /** @hidden */
  21531. _creationDataStorage: Nullable<_CreationDataStorage>;
  21532. /** @hidden */
  21533. _geometry: Nullable<Geometry>;
  21534. /** @hidden */
  21535. _delayInfo: Array<string>;
  21536. /** @hidden */
  21537. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21538. /** @hidden */
  21539. _instanceDataStorage: _InstanceDataStorage;
  21540. private _effectiveMaterial;
  21541. /** @hidden */
  21542. _shouldGenerateFlatShading: boolean;
  21543. /** @hidden */
  21544. _originalBuilderSideOrientation: number;
  21545. /**
  21546. * Use this property to change the original side orientation defined at construction time
  21547. */
  21548. overrideMaterialSideOrientation: Nullable<number>;
  21549. /**
  21550. * Gets the source mesh (the one used to clone this one from)
  21551. */
  21552. readonly source: Nullable<Mesh>;
  21553. /**
  21554. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21555. */
  21556. isUnIndexed: boolean;
  21557. /**
  21558. * @constructor
  21559. * @param name The value used by scene.getMeshByName() to do a lookup.
  21560. * @param scene The scene to add this mesh to.
  21561. * @param parent The parent of this mesh, if it has one
  21562. * @param source An optional Mesh from which geometry is shared, cloned.
  21563. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21564. * When false, achieved by calling a clone(), also passing False.
  21565. * This will make creation of children, recursive.
  21566. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21567. */
  21568. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21569. /**
  21570. * Gets the class name
  21571. * @returns the string "Mesh".
  21572. */
  21573. getClassName(): string;
  21574. /** @hidden */
  21575. readonly _isMesh: boolean;
  21576. /**
  21577. * Returns a description of this mesh
  21578. * @param fullDetails define if full details about this mesh must be used
  21579. * @returns a descriptive string representing this mesh
  21580. */
  21581. toString(fullDetails?: boolean): string;
  21582. /** @hidden */
  21583. _unBindEffect(): void;
  21584. /**
  21585. * Gets a boolean indicating if this mesh has LOD
  21586. */
  21587. readonly hasLODLevels: boolean;
  21588. /**
  21589. * Gets the list of MeshLODLevel associated with the current mesh
  21590. * @returns an array of MeshLODLevel
  21591. */
  21592. getLODLevels(): MeshLODLevel[];
  21593. private _sortLODLevels;
  21594. /**
  21595. * Add a mesh as LOD level triggered at the given distance.
  21596. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21597. * @param distance The distance from the center of the object to show this level
  21598. * @param mesh The mesh to be added as LOD level (can be null)
  21599. * @return This mesh (for chaining)
  21600. */
  21601. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21602. /**
  21603. * Returns the LOD level mesh at the passed distance or null if not found.
  21604. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21605. * @param distance The distance from the center of the object to show this level
  21606. * @returns a Mesh or `null`
  21607. */
  21608. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21609. /**
  21610. * Remove a mesh from the LOD array
  21611. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21612. * @param mesh defines the mesh to be removed
  21613. * @return This mesh (for chaining)
  21614. */
  21615. removeLODLevel(mesh: Mesh): Mesh;
  21616. /**
  21617. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21618. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21619. * @param camera defines the camera to use to compute distance
  21620. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21621. * @return This mesh (for chaining)
  21622. */
  21623. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21624. /**
  21625. * Gets the mesh internal Geometry object
  21626. */
  21627. readonly geometry: Nullable<Geometry>;
  21628. /**
  21629. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21630. * @returns the total number of vertices
  21631. */
  21632. getTotalVertices(): number;
  21633. /**
  21634. * Returns the content of an associated vertex buffer
  21635. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21636. * - VertexBuffer.PositionKind
  21637. * - VertexBuffer.UVKind
  21638. * - VertexBuffer.UV2Kind
  21639. * - VertexBuffer.UV3Kind
  21640. * - VertexBuffer.UV4Kind
  21641. * - VertexBuffer.UV5Kind
  21642. * - VertexBuffer.UV6Kind
  21643. * - VertexBuffer.ColorKind
  21644. * - VertexBuffer.MatricesIndicesKind
  21645. * - VertexBuffer.MatricesIndicesExtraKind
  21646. * - VertexBuffer.MatricesWeightsKind
  21647. * - VertexBuffer.MatricesWeightsExtraKind
  21648. * @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
  21649. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21650. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21651. */
  21652. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21653. /**
  21654. * Returns the mesh VertexBuffer object from the requested `kind`
  21655. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21656. * - VertexBuffer.PositionKind
  21657. * - VertexBuffer.UVKind
  21658. * - VertexBuffer.UV2Kind
  21659. * - VertexBuffer.UV3Kind
  21660. * - VertexBuffer.UV4Kind
  21661. * - VertexBuffer.UV5Kind
  21662. * - VertexBuffer.UV6Kind
  21663. * - VertexBuffer.ColorKind
  21664. * - VertexBuffer.MatricesIndicesKind
  21665. * - VertexBuffer.MatricesIndicesExtraKind
  21666. * - VertexBuffer.MatricesWeightsKind
  21667. * - VertexBuffer.MatricesWeightsExtraKind
  21668. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21669. */
  21670. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21671. /**
  21672. * Tests if a specific vertex buffer is associated with this mesh
  21673. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21674. * - VertexBuffer.PositionKind
  21675. * - VertexBuffer.UVKind
  21676. * - VertexBuffer.UV2Kind
  21677. * - VertexBuffer.UV3Kind
  21678. * - VertexBuffer.UV4Kind
  21679. * - VertexBuffer.UV5Kind
  21680. * - VertexBuffer.UV6Kind
  21681. * - VertexBuffer.ColorKind
  21682. * - VertexBuffer.MatricesIndicesKind
  21683. * - VertexBuffer.MatricesIndicesExtraKind
  21684. * - VertexBuffer.MatricesWeightsKind
  21685. * - VertexBuffer.MatricesWeightsExtraKind
  21686. * @returns a boolean
  21687. */
  21688. isVerticesDataPresent(kind: string): boolean;
  21689. /**
  21690. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21691. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21692. * - VertexBuffer.PositionKind
  21693. * - VertexBuffer.UVKind
  21694. * - VertexBuffer.UV2Kind
  21695. * - VertexBuffer.UV3Kind
  21696. * - VertexBuffer.UV4Kind
  21697. * - VertexBuffer.UV5Kind
  21698. * - VertexBuffer.UV6Kind
  21699. * - VertexBuffer.ColorKind
  21700. * - VertexBuffer.MatricesIndicesKind
  21701. * - VertexBuffer.MatricesIndicesExtraKind
  21702. * - VertexBuffer.MatricesWeightsKind
  21703. * - VertexBuffer.MatricesWeightsExtraKind
  21704. * @returns a boolean
  21705. */
  21706. isVertexBufferUpdatable(kind: string): boolean;
  21707. /**
  21708. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21709. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21710. * - VertexBuffer.PositionKind
  21711. * - VertexBuffer.UVKind
  21712. * - VertexBuffer.UV2Kind
  21713. * - VertexBuffer.UV3Kind
  21714. * - VertexBuffer.UV4Kind
  21715. * - VertexBuffer.UV5Kind
  21716. * - VertexBuffer.UV6Kind
  21717. * - VertexBuffer.ColorKind
  21718. * - VertexBuffer.MatricesIndicesKind
  21719. * - VertexBuffer.MatricesIndicesExtraKind
  21720. * - VertexBuffer.MatricesWeightsKind
  21721. * - VertexBuffer.MatricesWeightsExtraKind
  21722. * @returns an array of strings
  21723. */
  21724. getVerticesDataKinds(): string[];
  21725. /**
  21726. * Returns a positive integer : the total number of indices in this mesh geometry.
  21727. * @returns the numner of indices or zero if the mesh has no geometry.
  21728. */
  21729. getTotalIndices(): number;
  21730. /**
  21731. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21732. * @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.
  21733. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21734. * @returns the indices array or an empty array if the mesh has no geometry
  21735. */
  21736. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21737. readonly isBlocked: boolean;
  21738. /**
  21739. * Determine if the current mesh is ready to be rendered
  21740. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21741. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21742. * @returns true if all associated assets are ready (material, textures, shaders)
  21743. */
  21744. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21745. /**
  21746. * 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.
  21747. */
  21748. readonly areNormalsFrozen: boolean;
  21749. /**
  21750. * 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.
  21751. * @returns the current mesh
  21752. */
  21753. freezeNormals(): Mesh;
  21754. /**
  21755. * 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
  21756. * @returns the current mesh
  21757. */
  21758. unfreezeNormals(): Mesh;
  21759. /**
  21760. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21761. */
  21762. overridenInstanceCount: number;
  21763. /** @hidden */
  21764. _preActivate(): Mesh;
  21765. /** @hidden */
  21766. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21767. /** @hidden */
  21768. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21769. /**
  21770. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21771. * This means the mesh underlying bounding box and sphere are recomputed.
  21772. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21773. * @returns the current mesh
  21774. */
  21775. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21776. /** @hidden */
  21777. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21778. /**
  21779. * This function will subdivide the mesh into multiple submeshes
  21780. * @param count defines the expected number of submeshes
  21781. */
  21782. subdivide(count: number): void;
  21783. /**
  21784. * Copy a FloatArray into a specific associated vertex buffer
  21785. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21786. * - VertexBuffer.PositionKind
  21787. * - VertexBuffer.UVKind
  21788. * - VertexBuffer.UV2Kind
  21789. * - VertexBuffer.UV3Kind
  21790. * - VertexBuffer.UV4Kind
  21791. * - VertexBuffer.UV5Kind
  21792. * - VertexBuffer.UV6Kind
  21793. * - VertexBuffer.ColorKind
  21794. * - VertexBuffer.MatricesIndicesKind
  21795. * - VertexBuffer.MatricesIndicesExtraKind
  21796. * - VertexBuffer.MatricesWeightsKind
  21797. * - VertexBuffer.MatricesWeightsExtraKind
  21798. * @param data defines the data source
  21799. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21800. * @param stride defines the data stride size (can be null)
  21801. * @returns the current mesh
  21802. */
  21803. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21804. /**
  21805. * Flags an associated vertex buffer as updatable
  21806. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21807. * - VertexBuffer.PositionKind
  21808. * - VertexBuffer.UVKind
  21809. * - VertexBuffer.UV2Kind
  21810. * - VertexBuffer.UV3Kind
  21811. * - VertexBuffer.UV4Kind
  21812. * - VertexBuffer.UV5Kind
  21813. * - VertexBuffer.UV6Kind
  21814. * - VertexBuffer.ColorKind
  21815. * - VertexBuffer.MatricesIndicesKind
  21816. * - VertexBuffer.MatricesIndicesExtraKind
  21817. * - VertexBuffer.MatricesWeightsKind
  21818. * - VertexBuffer.MatricesWeightsExtraKind
  21819. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21820. */
  21821. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21822. /**
  21823. * Sets the mesh global Vertex Buffer
  21824. * @param buffer defines the buffer to use
  21825. * @returns the current mesh
  21826. */
  21827. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21828. /**
  21829. * Update a specific associated vertex buffer
  21830. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21831. * - VertexBuffer.PositionKind
  21832. * - VertexBuffer.UVKind
  21833. * - VertexBuffer.UV2Kind
  21834. * - VertexBuffer.UV3Kind
  21835. * - VertexBuffer.UV4Kind
  21836. * - VertexBuffer.UV5Kind
  21837. * - VertexBuffer.UV6Kind
  21838. * - VertexBuffer.ColorKind
  21839. * - VertexBuffer.MatricesIndicesKind
  21840. * - VertexBuffer.MatricesIndicesExtraKind
  21841. * - VertexBuffer.MatricesWeightsKind
  21842. * - VertexBuffer.MatricesWeightsExtraKind
  21843. * @param data defines the data source
  21844. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21845. * @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)
  21846. * @returns the current mesh
  21847. */
  21848. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21849. /**
  21850. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21851. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21852. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21853. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21854. * @returns the current mesh
  21855. */
  21856. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21857. /**
  21858. * Creates a un-shared specific occurence of the geometry for the mesh.
  21859. * @returns the current mesh
  21860. */
  21861. makeGeometryUnique(): Mesh;
  21862. /**
  21863. * Set the index buffer of this mesh
  21864. * @param indices defines the source data
  21865. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21866. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21867. * @returns the current mesh
  21868. */
  21869. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21870. /**
  21871. * Update the current index buffer
  21872. * @param indices defines the source data
  21873. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21874. * @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)
  21875. * @returns the current mesh
  21876. */
  21877. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21878. /**
  21879. * Invert the geometry to move from a right handed system to a left handed one.
  21880. * @returns the current mesh
  21881. */
  21882. toLeftHanded(): Mesh;
  21883. /** @hidden */
  21884. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21885. /** @hidden */
  21886. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21887. /**
  21888. * Registers for this mesh a javascript function called just before the rendering process
  21889. * @param func defines the function to call before rendering this mesh
  21890. * @returns the current mesh
  21891. */
  21892. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21893. /**
  21894. * Disposes a previously registered javascript function called before the rendering
  21895. * @param func defines the function to remove
  21896. * @returns the current mesh
  21897. */
  21898. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21899. /**
  21900. * Registers for this mesh a javascript function called just after the rendering is complete
  21901. * @param func defines the function to call after rendering this mesh
  21902. * @returns the current mesh
  21903. */
  21904. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21905. /**
  21906. * Disposes a previously registered javascript function called after the rendering.
  21907. * @param func defines the function to remove
  21908. * @returns the current mesh
  21909. */
  21910. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21911. /** @hidden */
  21912. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21913. /** @hidden */
  21914. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21915. /** @hidden */
  21916. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21917. /** @hidden */
  21918. _freeze(): void;
  21919. /** @hidden */
  21920. _unFreeze(): void;
  21921. /**
  21922. * 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
  21923. * @param subMesh defines the subMesh to render
  21924. * @param enableAlphaMode defines if alpha mode can be changed
  21925. * @returns the current mesh
  21926. */
  21927. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21928. private _onBeforeDraw;
  21929. /**
  21930. * Renormalize the mesh and patch it up if there are no weights
  21931. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21932. * However in the case of zero weights then we set just a single influence to 1.
  21933. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21934. */
  21935. cleanMatrixWeights(): void;
  21936. private normalizeSkinFourWeights;
  21937. private normalizeSkinWeightsAndExtra;
  21938. /**
  21939. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21940. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21941. * the user know there was an issue with importing the mesh
  21942. * @returns a validation object with skinned, valid and report string
  21943. */
  21944. validateSkinning(): {
  21945. skinned: boolean;
  21946. valid: boolean;
  21947. report: string;
  21948. };
  21949. /** @hidden */
  21950. _checkDelayState(): Mesh;
  21951. private _queueLoad;
  21952. /**
  21953. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21954. * A mesh is in the frustum if its bounding box intersects the frustum
  21955. * @param frustumPlanes defines the frustum to test
  21956. * @returns true if the mesh is in the frustum planes
  21957. */
  21958. isInFrustum(frustumPlanes: Plane[]): boolean;
  21959. /**
  21960. * Sets the mesh material by the material or multiMaterial `id` property
  21961. * @param id is a string identifying the material or the multiMaterial
  21962. * @returns the current mesh
  21963. */
  21964. setMaterialByID(id: string): Mesh;
  21965. /**
  21966. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21967. * @returns an array of IAnimatable
  21968. */
  21969. getAnimatables(): IAnimatable[];
  21970. /**
  21971. * Modifies the mesh geometry according to the passed transformation matrix.
  21972. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21973. * The mesh normals are modified using the same transformation.
  21974. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21975. * @param transform defines the transform matrix to use
  21976. * @see http://doc.babylonjs.com/resources/baking_transformations
  21977. * @returns the current mesh
  21978. */
  21979. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21980. /**
  21981. * Modifies the mesh geometry according to its own current World Matrix.
  21982. * The mesh World Matrix is then reset.
  21983. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21984. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21985. * @see http://doc.babylonjs.com/resources/baking_transformations
  21986. * @returns the current mesh
  21987. */
  21988. bakeCurrentTransformIntoVertices(): Mesh;
  21989. /** @hidden */
  21990. readonly _positions: Nullable<Vector3[]>;
  21991. /** @hidden */
  21992. _resetPointsArrayCache(): Mesh;
  21993. /** @hidden */
  21994. _generatePointsArray(): boolean;
  21995. /**
  21996. * Returns a new Mesh object generated from the current mesh properties.
  21997. * This method must not get confused with createInstance()
  21998. * @param name is a string, the name given to the new mesh
  21999. * @param newParent can be any Node object (default `null`)
  22000. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  22001. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  22002. * @returns a new mesh
  22003. */
  22004. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  22005. /**
  22006. * Releases resources associated with this mesh.
  22007. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22008. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22009. */
  22010. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22011. /**
  22012. * Modifies the mesh geometry according to a displacement map.
  22013. * 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.
  22014. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22015. * @param url is a string, the URL from the image file is to be downloaded.
  22016. * @param minHeight is the lower limit of the displacement.
  22017. * @param maxHeight is the upper limit of the displacement.
  22018. * @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.
  22019. * @param uvOffset is an optional vector2 used to offset UV.
  22020. * @param uvScale is an optional vector2 used to scale UV.
  22021. * @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.
  22022. * @returns the Mesh.
  22023. */
  22024. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22025. /**
  22026. * Modifies the mesh geometry according to a displacementMap buffer.
  22027. * 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.
  22028. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22029. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  22030. * @param heightMapWidth is the width of the buffer image.
  22031. * @param heightMapHeight is the height of the buffer image.
  22032. * @param minHeight is the lower limit of the displacement.
  22033. * @param maxHeight is the upper limit of the displacement.
  22034. * @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.
  22035. * @param uvOffset is an optional vector2 used to offset UV.
  22036. * @param uvScale is an optional vector2 used to scale UV.
  22037. * @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.
  22038. * @returns the Mesh.
  22039. */
  22040. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22041. /**
  22042. * Modify the mesh to get a flat shading rendering.
  22043. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22044. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22045. * @returns current mesh
  22046. */
  22047. convertToFlatShadedMesh(): Mesh;
  22048. /**
  22049. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22050. * In other words, more vertices, no more indices and a single bigger VBO.
  22051. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22052. * @returns current mesh
  22053. */
  22054. convertToUnIndexedMesh(): Mesh;
  22055. /**
  22056. * Inverses facet orientations.
  22057. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22058. * @param flipNormals will also inverts the normals
  22059. * @returns current mesh
  22060. */
  22061. flipFaces(flipNormals?: boolean): Mesh;
  22062. /**
  22063. * Increase the number of facets and hence vertices in a mesh
  22064. * Vertex normals are interpolated from existing vertex normals
  22065. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22066. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  22067. */
  22068. increaseVertices(numberPerEdge: number): void;
  22069. /**
  22070. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  22071. * This will undo any application of covertToFlatShadedMesh
  22072. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22073. */
  22074. forceSharedVertices(): void;
  22075. /** @hidden */
  22076. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  22077. /** @hidden */
  22078. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  22079. /**
  22080. * Creates a new InstancedMesh object from the mesh model.
  22081. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  22082. * @param name defines the name of the new instance
  22083. * @returns a new InstancedMesh
  22084. */
  22085. createInstance(name: string): InstancedMesh;
  22086. /**
  22087. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22088. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22089. * @returns the current mesh
  22090. */
  22091. synchronizeInstances(): Mesh;
  22092. /**
  22093. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22094. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22095. * This should be used together with the simplification to avoid disappearing triangles.
  22096. * @param successCallback an optional success callback to be called after the optimization finished.
  22097. * @returns the current mesh
  22098. */
  22099. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22100. /**
  22101. * Serialize current mesh
  22102. * @param serializationObject defines the object which will receive the serialization data
  22103. */
  22104. serialize(serializationObject: any): void;
  22105. /** @hidden */
  22106. _syncGeometryWithMorphTargetManager(): void;
  22107. /** @hidden */
  22108. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  22109. /**
  22110. * Returns a new Mesh object parsed from the source provided.
  22111. * @param parsedMesh is the source
  22112. * @param scene defines the hosting scene
  22113. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  22114. * @returns a new Mesh
  22115. */
  22116. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22117. /**
  22118. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  22119. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22120. * @param name defines the name of the mesh to create
  22121. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22122. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  22123. * @param closePath creates a seam between the first and the last points of each path of the path array
  22124. * @param offset is taken in account only if the `pathArray` is containing a single path
  22125. * @param scene defines the hosting scene
  22126. * @param updatable defines if the mesh must be flagged as updatable
  22127. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22128. * @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)
  22129. * @returns a new Mesh
  22130. */
  22131. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22132. /**
  22133. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  22134. * @param name defines the name of the mesh to create
  22135. * @param radius sets the radius size (float) of the polygon (default 0.5)
  22136. * @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
  22137. * @param scene defines the hosting scene
  22138. * @param updatable defines if the mesh must be flagged as updatable
  22139. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22140. * @returns a new Mesh
  22141. */
  22142. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22143. /**
  22144. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  22145. * @param name defines the name of the mesh to create
  22146. * @param size sets the size (float) of each box side (default 1)
  22147. * @param scene defines the hosting scene
  22148. * @param updatable defines if the mesh must be flagged as updatable
  22149. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22150. * @returns a new Mesh
  22151. */
  22152. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22153. /**
  22154. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  22155. * @param name defines the name of the mesh to create
  22156. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22157. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22158. * @param scene defines the hosting scene
  22159. * @param updatable defines if the mesh must be flagged as updatable
  22160. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22161. * @returns a new Mesh
  22162. */
  22163. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22164. /**
  22165. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  22166. * @param name defines the name of the mesh to create
  22167. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22168. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22169. * @param scene defines the hosting scene
  22170. * @returns a new Mesh
  22171. */
  22172. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  22173. /**
  22174. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  22175. * @param name defines the name of the mesh to create
  22176. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  22177. * @param diameterTop set the top cap diameter (floats, default 1)
  22178. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  22179. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  22180. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  22181. * @param scene defines the hosting scene
  22182. * @param updatable defines if the mesh must be flagged as updatable
  22183. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22184. * @returns a new Mesh
  22185. */
  22186. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22187. /**
  22188. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  22189. * @param name defines the name of the mesh to create
  22190. * @param diameter sets the diameter size (float) of the torus (default 1)
  22191. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  22192. * @param tessellation sets the number of torus sides (postive integer, default 16)
  22193. * @param scene defines the hosting scene
  22194. * @param updatable defines if the mesh must be flagged as updatable
  22195. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22196. * @returns a new Mesh
  22197. */
  22198. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22199. /**
  22200. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  22201. * @param name defines the name of the mesh to create
  22202. * @param radius sets the global radius size (float) of the torus knot (default 2)
  22203. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  22204. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  22205. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  22206. * @param p the number of windings on X axis (positive integers, default 2)
  22207. * @param q the number of windings on Y axis (positive integers, default 3)
  22208. * @param scene defines the hosting scene
  22209. * @param updatable defines if the mesh must be flagged as updatable
  22210. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22211. * @returns a new Mesh
  22212. */
  22213. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22214. /**
  22215. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  22216. * @param name defines the name of the mesh to create
  22217. * @param points is an array successive Vector3
  22218. * @param scene defines the hosting scene
  22219. * @param updatable defines if the mesh must be flagged as updatable
  22220. * @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).
  22221. * @returns a new Mesh
  22222. */
  22223. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22224. /**
  22225. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  22226. * @param name defines the name of the mesh to create
  22227. * @param points is an array successive Vector3
  22228. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  22229. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22230. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  22231. * @param scene defines the hosting scene
  22232. * @param updatable defines if the mesh must be flagged as updatable
  22233. * @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)
  22234. * @returns a new Mesh
  22235. */
  22236. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22237. /**
  22238. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  22239. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22240. * 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.
  22241. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22242. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22243. * Remember you can only change the shape positions, not their number when updating a polygon.
  22244. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  22245. * @param name defines the name of the mesh to create
  22246. * @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
  22247. * @param scene defines the hosting scene
  22248. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22249. * @param updatable defines if the mesh must be flagged as updatable
  22250. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22251. * @param earcutInjection can be used to inject your own earcut reference
  22252. * @returns a new Mesh
  22253. */
  22254. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22255. /**
  22256. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  22257. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  22258. * @param name defines the name of the mesh to create
  22259. * @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
  22260. * @param depth defines the height of extrusion
  22261. * @param scene defines the hosting scene
  22262. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22263. * @param updatable defines if the mesh must be flagged as updatable
  22264. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22265. * @param earcutInjection can be used to inject your own earcut reference
  22266. * @returns a new Mesh
  22267. */
  22268. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22269. /**
  22270. * Creates an extruded shape mesh.
  22271. * 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
  22272. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22273. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22274. * @param name defines the name of the mesh to create
  22275. * @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
  22276. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22277. * @param scale is the value to scale the shape
  22278. * @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
  22279. * @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
  22280. * @param scene defines the hosting scene
  22281. * @param updatable defines if the mesh must be flagged as updatable
  22282. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22283. * @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)
  22284. * @returns a new Mesh
  22285. */
  22286. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22287. /**
  22288. * Creates an custom extruded shape mesh.
  22289. * The custom extrusion is a parametric shape.
  22290. * It has no predefined shape. Its final shape will depend on the input parameters.
  22291. * Please consider using the same method from the MeshBuilder class instead
  22292. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22293. * @param name defines the name of the mesh to create
  22294. * @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
  22295. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22296. * @param scaleFunction is a custom Javascript function called on each path point
  22297. * @param rotationFunction is a custom Javascript function called on each path point
  22298. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22299. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  22300. * @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
  22301. * @param scene defines the hosting scene
  22302. * @param updatable defines if the mesh must be flagged as updatable
  22303. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22304. * @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)
  22305. * @returns a new Mesh
  22306. */
  22307. 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;
  22308. /**
  22309. * Creates lathe mesh.
  22310. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22311. * Please consider using the same method from the MeshBuilder class instead
  22312. * @param name defines the name of the mesh to create
  22313. * @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
  22314. * @param radius is the radius value of the lathe
  22315. * @param tessellation is the side number of the lathe.
  22316. * @param scene defines the hosting scene
  22317. * @param updatable defines if the mesh must be flagged as updatable
  22318. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22319. * @returns a new Mesh
  22320. */
  22321. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22322. /**
  22323. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  22324. * @param name defines the name of the mesh to create
  22325. * @param size sets the size (float) of both sides of the plane at once (default 1)
  22326. * @param scene defines the hosting scene
  22327. * @param updatable defines if the mesh must be flagged as updatable
  22328. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22329. * @returns a new Mesh
  22330. */
  22331. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22332. /**
  22333. * Creates a ground mesh.
  22334. * Please consider using the same method from the MeshBuilder class instead
  22335. * @param name defines the name of the mesh to create
  22336. * @param width set the width of the ground
  22337. * @param height set the height of the ground
  22338. * @param subdivisions sets the number of subdivisions per side
  22339. * @param scene defines the hosting scene
  22340. * @param updatable defines if the mesh must be flagged as updatable
  22341. * @returns a new Mesh
  22342. */
  22343. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22344. /**
  22345. * Creates a tiled ground mesh.
  22346. * Please consider using the same method from the MeshBuilder class instead
  22347. * @param name defines the name of the mesh to create
  22348. * @param xmin set the ground minimum X coordinate
  22349. * @param zmin set the ground minimum Y coordinate
  22350. * @param xmax set the ground maximum X coordinate
  22351. * @param zmax set the ground maximum Z coordinate
  22352. * @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
  22353. * @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
  22354. * @param scene defines the hosting scene
  22355. * @param updatable defines if the mesh must be flagged as updatable
  22356. * @returns a new Mesh
  22357. */
  22358. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22359. w: number;
  22360. h: number;
  22361. }, precision: {
  22362. w: number;
  22363. h: number;
  22364. }, scene: Scene, updatable?: boolean): Mesh;
  22365. /**
  22366. * Creates a ground mesh from a height map.
  22367. * Please consider using the same method from the MeshBuilder class instead
  22368. * @see http://doc.babylonjs.com/babylon101/height_map
  22369. * @param name defines the name of the mesh to create
  22370. * @param url sets the URL of the height map image resource
  22371. * @param width set the ground width size
  22372. * @param height set the ground height size
  22373. * @param subdivisions sets the number of subdivision per side
  22374. * @param minHeight is the minimum altitude on the ground
  22375. * @param maxHeight is the maximum altitude on the ground
  22376. * @param scene defines the hosting scene
  22377. * @param updatable defines if the mesh must be flagged as updatable
  22378. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  22379. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  22380. * @returns a new Mesh
  22381. */
  22382. 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;
  22383. /**
  22384. * Creates a tube mesh.
  22385. * The tube is a parametric shape.
  22386. * It has no predefined shape. Its final shape will depend on the input parameters.
  22387. * Please consider using the same method from the MeshBuilder class instead
  22388. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22389. * @param name defines the name of the mesh to create
  22390. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  22391. * @param radius sets the tube radius size
  22392. * @param tessellation is the number of sides on the tubular surface
  22393. * @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
  22394. * @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
  22395. * @param scene defines the hosting scene
  22396. * @param updatable defines if the mesh must be flagged as updatable
  22397. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22398. * @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)
  22399. * @returns a new Mesh
  22400. */
  22401. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22402. (i: number, distance: number): number;
  22403. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22404. /**
  22405. * Creates a polyhedron mesh.
  22406. * Please consider using the same method from the MeshBuilder class instead.
  22407. * * 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
  22408. * * The parameter `size` (positive float, default 1) sets the polygon size
  22409. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22410. * * 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`
  22411. * * 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
  22412. * * 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)`)
  22413. * * 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
  22414. * * 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
  22415. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22416. * * If you create a double-sided mesh, you can choose what parts of 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
  22417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22418. * @param name defines the name of the mesh to create
  22419. * @param options defines the options used to create the mesh
  22420. * @param scene defines the hosting scene
  22421. * @returns a new Mesh
  22422. */
  22423. static CreatePolyhedron(name: string, options: {
  22424. type?: number;
  22425. size?: number;
  22426. sizeX?: number;
  22427. sizeY?: number;
  22428. sizeZ?: number;
  22429. custom?: any;
  22430. faceUV?: Vector4[];
  22431. faceColors?: Color4[];
  22432. updatable?: boolean;
  22433. sideOrientation?: number;
  22434. }, scene: Scene): Mesh;
  22435. /**
  22436. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22437. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22438. * * 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`)
  22439. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22440. * * 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
  22441. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22442. * * If you create a double-sided mesh, you can choose what parts of 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
  22443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22444. * @param name defines the name of the mesh
  22445. * @param options defines the options used to create the mesh
  22446. * @param scene defines the hosting scene
  22447. * @returns a new Mesh
  22448. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22449. */
  22450. static CreateIcoSphere(name: string, options: {
  22451. radius?: number;
  22452. flat?: boolean;
  22453. subdivisions?: number;
  22454. sideOrientation?: number;
  22455. updatable?: boolean;
  22456. }, scene: Scene): Mesh;
  22457. /**
  22458. * Creates a decal mesh.
  22459. * Please consider using the same method from the MeshBuilder class instead.
  22460. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22461. * @param name defines the name of the mesh
  22462. * @param sourceMesh defines the mesh receiving the decal
  22463. * @param position sets the position of the decal in world coordinates
  22464. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22465. * @param size sets the decal scaling
  22466. * @param angle sets the angle to rotate the decal
  22467. * @returns a new Mesh
  22468. */
  22469. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22470. /**
  22471. * Prepare internal position array for software CPU skinning
  22472. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22473. */
  22474. setPositionsForCPUSkinning(): Float32Array;
  22475. /**
  22476. * Prepare internal normal array for software CPU skinning
  22477. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22478. */
  22479. setNormalsForCPUSkinning(): Float32Array;
  22480. /**
  22481. * Updates the vertex buffer by applying transformation from the bones
  22482. * @param skeleton defines the skeleton to apply to current mesh
  22483. * @returns the current mesh
  22484. */
  22485. applySkeleton(skeleton: Skeleton): Mesh;
  22486. /**
  22487. * 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
  22488. * @param meshes defines the list of meshes to scan
  22489. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22490. */
  22491. static MinMax(meshes: AbstractMesh[]): {
  22492. min: Vector3;
  22493. max: Vector3;
  22494. };
  22495. /**
  22496. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22497. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22498. * @returns a vector3
  22499. */
  22500. static Center(meshesOrMinMaxVector: {
  22501. min: Vector3;
  22502. max: Vector3;
  22503. } | AbstractMesh[]): Vector3;
  22504. /**
  22505. * Merge the array of meshes into a single mesh for performance reasons.
  22506. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22507. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22508. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22509. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22510. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22511. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22512. * @returns a new mesh
  22513. */
  22514. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22515. /** @hidden */
  22516. addInstance(instance: InstancedMesh): void;
  22517. /** @hidden */
  22518. removeInstance(instance: InstancedMesh): void;
  22519. }
  22520. }
  22521. declare module "babylonjs/Materials/material" {
  22522. import { IAnimatable } from "babylonjs/Misc/tools";
  22523. import { SmartArray } from "babylonjs/Misc/smartArray";
  22524. import { Observable } from "babylonjs/Misc/observable";
  22525. import { Nullable } from "babylonjs/types";
  22526. import { Scene } from "babylonjs/scene";
  22527. import { Matrix } from "babylonjs/Maths/math";
  22528. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22530. import { Mesh } from "babylonjs/Meshes/mesh";
  22531. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22532. import { Effect } from "babylonjs/Materials/effect";
  22533. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22534. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22535. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22536. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22537. import { Animation } from "babylonjs/Animations/animation";
  22538. /**
  22539. * Base class for the main features of a material in Babylon.js
  22540. */
  22541. export class Material implements IAnimatable {
  22542. /**
  22543. * Returns the triangle fill mode
  22544. */
  22545. static readonly TriangleFillMode: number;
  22546. /**
  22547. * Returns the wireframe mode
  22548. */
  22549. static readonly WireFrameFillMode: number;
  22550. /**
  22551. * Returns the point fill mode
  22552. */
  22553. static readonly PointFillMode: number;
  22554. /**
  22555. * Returns the point list draw mode
  22556. */
  22557. static readonly PointListDrawMode: number;
  22558. /**
  22559. * Returns the line list draw mode
  22560. */
  22561. static readonly LineListDrawMode: number;
  22562. /**
  22563. * Returns the line loop draw mode
  22564. */
  22565. static readonly LineLoopDrawMode: number;
  22566. /**
  22567. * Returns the line strip draw mode
  22568. */
  22569. static readonly LineStripDrawMode: number;
  22570. /**
  22571. * Returns the triangle strip draw mode
  22572. */
  22573. static readonly TriangleStripDrawMode: number;
  22574. /**
  22575. * Returns the triangle fan draw mode
  22576. */
  22577. static readonly TriangleFanDrawMode: number;
  22578. /**
  22579. * Stores the clock-wise side orientation
  22580. */
  22581. static readonly ClockWiseSideOrientation: number;
  22582. /**
  22583. * Stores the counter clock-wise side orientation
  22584. */
  22585. static readonly CounterClockWiseSideOrientation: number;
  22586. /**
  22587. * The dirty texture flag value
  22588. */
  22589. static readonly TextureDirtyFlag: number;
  22590. /**
  22591. * The dirty light flag value
  22592. */
  22593. static readonly LightDirtyFlag: number;
  22594. /**
  22595. * The dirty fresnel flag value
  22596. */
  22597. static readonly FresnelDirtyFlag: number;
  22598. /**
  22599. * The dirty attribute flag value
  22600. */
  22601. static readonly AttributesDirtyFlag: number;
  22602. /**
  22603. * The dirty misc flag value
  22604. */
  22605. static readonly MiscDirtyFlag: number;
  22606. /**
  22607. * The all dirty flag value
  22608. */
  22609. static readonly AllDirtyFlag: number;
  22610. /**
  22611. * The ID of the material
  22612. */
  22613. id: string;
  22614. /**
  22615. * Gets or sets the unique id of the material
  22616. */
  22617. uniqueId: number;
  22618. /**
  22619. * The name of the material
  22620. */
  22621. name: string;
  22622. /**
  22623. * Gets or sets user defined metadata
  22624. */
  22625. metadata: any;
  22626. /**
  22627. * For internal use only. Please do not use.
  22628. */
  22629. reservedDataStore: any;
  22630. /**
  22631. * Specifies if the ready state should be checked on each call
  22632. */
  22633. checkReadyOnEveryCall: boolean;
  22634. /**
  22635. * Specifies if the ready state should be checked once
  22636. */
  22637. checkReadyOnlyOnce: boolean;
  22638. /**
  22639. * The state of the material
  22640. */
  22641. state: string;
  22642. /**
  22643. * The alpha value of the material
  22644. */
  22645. protected _alpha: number;
  22646. /**
  22647. * List of inspectable custom properties (used by the Inspector)
  22648. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22649. */
  22650. inspectableCustomProperties: IInspectable[];
  22651. /**
  22652. * Sets the alpha value of the material
  22653. */
  22654. /**
  22655. * Gets the alpha value of the material
  22656. */
  22657. alpha: number;
  22658. /**
  22659. * Specifies if back face culling is enabled
  22660. */
  22661. protected _backFaceCulling: boolean;
  22662. /**
  22663. * Sets the back-face culling state
  22664. */
  22665. /**
  22666. * Gets the back-face culling state
  22667. */
  22668. backFaceCulling: boolean;
  22669. /**
  22670. * Stores the value for side orientation
  22671. */
  22672. sideOrientation: number;
  22673. /**
  22674. * Callback triggered when the material is compiled
  22675. */
  22676. onCompiled: Nullable<(effect: Effect) => void>;
  22677. /**
  22678. * Callback triggered when an error occurs
  22679. */
  22680. onError: Nullable<(effect: Effect, errors: string) => void>;
  22681. /**
  22682. * Callback triggered to get the render target textures
  22683. */
  22684. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22685. /**
  22686. * Gets a boolean indicating that current material needs to register RTT
  22687. */
  22688. readonly hasRenderTargetTextures: boolean;
  22689. /**
  22690. * Specifies if the material should be serialized
  22691. */
  22692. doNotSerialize: boolean;
  22693. /**
  22694. * @hidden
  22695. */
  22696. _storeEffectOnSubMeshes: boolean;
  22697. /**
  22698. * Stores the animations for the material
  22699. */
  22700. animations: Nullable<Array<Animation>>;
  22701. /**
  22702. * An event triggered when the material is disposed
  22703. */
  22704. onDisposeObservable: Observable<Material>;
  22705. /**
  22706. * An observer which watches for dispose events
  22707. */
  22708. private _onDisposeObserver;
  22709. private _onUnBindObservable;
  22710. /**
  22711. * Called during a dispose event
  22712. */
  22713. onDispose: () => void;
  22714. private _onBindObservable;
  22715. /**
  22716. * An event triggered when the material is bound
  22717. */
  22718. readonly onBindObservable: Observable<AbstractMesh>;
  22719. /**
  22720. * An observer which watches for bind events
  22721. */
  22722. private _onBindObserver;
  22723. /**
  22724. * Called during a bind event
  22725. */
  22726. onBind: (Mesh: AbstractMesh) => void;
  22727. /**
  22728. * An event triggered when the material is unbound
  22729. */
  22730. readonly onUnBindObservable: Observable<Material>;
  22731. /**
  22732. * Stores the value of the alpha mode
  22733. */
  22734. private _alphaMode;
  22735. /**
  22736. * Sets the value of the alpha mode.
  22737. *
  22738. * | Value | Type | Description |
  22739. * | --- | --- | --- |
  22740. * | 0 | ALPHA_DISABLE | |
  22741. * | 1 | ALPHA_ADD | |
  22742. * | 2 | ALPHA_COMBINE | |
  22743. * | 3 | ALPHA_SUBTRACT | |
  22744. * | 4 | ALPHA_MULTIPLY | |
  22745. * | 5 | ALPHA_MAXIMIZED | |
  22746. * | 6 | ALPHA_ONEONE | |
  22747. * | 7 | ALPHA_PREMULTIPLIED | |
  22748. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22749. * | 9 | ALPHA_INTERPOLATE | |
  22750. * | 10 | ALPHA_SCREENMODE | |
  22751. *
  22752. */
  22753. /**
  22754. * Gets the value of the alpha mode
  22755. */
  22756. alphaMode: number;
  22757. /**
  22758. * Stores the state of the need depth pre-pass value
  22759. */
  22760. private _needDepthPrePass;
  22761. /**
  22762. * Sets the need depth pre-pass value
  22763. */
  22764. /**
  22765. * Gets the depth pre-pass value
  22766. */
  22767. needDepthPrePass: boolean;
  22768. /**
  22769. * Specifies if depth writing should be disabled
  22770. */
  22771. disableDepthWrite: boolean;
  22772. /**
  22773. * Specifies if depth writing should be forced
  22774. */
  22775. forceDepthWrite: boolean;
  22776. /**
  22777. * Specifies if there should be a separate pass for culling
  22778. */
  22779. separateCullingPass: boolean;
  22780. /**
  22781. * Stores the state specifing if fog should be enabled
  22782. */
  22783. private _fogEnabled;
  22784. /**
  22785. * Sets the state for enabling fog
  22786. */
  22787. /**
  22788. * Gets the value of the fog enabled state
  22789. */
  22790. fogEnabled: boolean;
  22791. /**
  22792. * Stores the size of points
  22793. */
  22794. pointSize: number;
  22795. /**
  22796. * Stores the z offset value
  22797. */
  22798. zOffset: number;
  22799. /**
  22800. * Gets a value specifying if wireframe mode is enabled
  22801. */
  22802. /**
  22803. * Sets the state of wireframe mode
  22804. */
  22805. wireframe: boolean;
  22806. /**
  22807. * Gets the value specifying if point clouds are enabled
  22808. */
  22809. /**
  22810. * Sets the state of point cloud mode
  22811. */
  22812. pointsCloud: boolean;
  22813. /**
  22814. * Gets the material fill mode
  22815. */
  22816. /**
  22817. * Sets the material fill mode
  22818. */
  22819. fillMode: number;
  22820. /**
  22821. * @hidden
  22822. * Stores the effects for the material
  22823. */
  22824. _effect: Nullable<Effect>;
  22825. /**
  22826. * @hidden
  22827. * Specifies if the material was previously ready
  22828. */
  22829. _wasPreviouslyReady: boolean;
  22830. /**
  22831. * Specifies if uniform buffers should be used
  22832. */
  22833. private _useUBO;
  22834. /**
  22835. * Stores a reference to the scene
  22836. */
  22837. private _scene;
  22838. /**
  22839. * Stores the fill mode state
  22840. */
  22841. private _fillMode;
  22842. /**
  22843. * Specifies if the depth write state should be cached
  22844. */
  22845. private _cachedDepthWriteState;
  22846. /**
  22847. * Stores the uniform buffer
  22848. */
  22849. protected _uniformBuffer: UniformBuffer;
  22850. /** @hidden */
  22851. _indexInSceneMaterialArray: number;
  22852. /** @hidden */
  22853. meshMap: Nullable<{
  22854. [id: string]: AbstractMesh | undefined;
  22855. }>;
  22856. /**
  22857. * Creates a material instance
  22858. * @param name defines the name of the material
  22859. * @param scene defines the scene to reference
  22860. * @param doNotAdd specifies if the material should be added to the scene
  22861. */
  22862. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22863. /**
  22864. * Returns a string representation of the current material
  22865. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22866. * @returns a string with material information
  22867. */
  22868. toString(fullDetails?: boolean): string;
  22869. /**
  22870. * Gets the class name of the material
  22871. * @returns a string with the class name of the material
  22872. */
  22873. getClassName(): string;
  22874. /**
  22875. * Specifies if updates for the material been locked
  22876. */
  22877. readonly isFrozen: boolean;
  22878. /**
  22879. * Locks updates for the material
  22880. */
  22881. freeze(): void;
  22882. /**
  22883. * Unlocks updates for the material
  22884. */
  22885. unfreeze(): void;
  22886. /**
  22887. * Specifies if the material is ready to be used
  22888. * @param mesh defines the mesh to check
  22889. * @param useInstances specifies if instances should be used
  22890. * @returns a boolean indicating if the material is ready to be used
  22891. */
  22892. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22893. /**
  22894. * Specifies that the submesh is ready to be used
  22895. * @param mesh defines the mesh to check
  22896. * @param subMesh defines which submesh to check
  22897. * @param useInstances specifies that instances should be used
  22898. * @returns a boolean indicating that the submesh is ready or not
  22899. */
  22900. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22901. /**
  22902. * Returns the material effect
  22903. * @returns the effect associated with the material
  22904. */
  22905. getEffect(): Nullable<Effect>;
  22906. /**
  22907. * Returns the current scene
  22908. * @returns a Scene
  22909. */
  22910. getScene(): Scene;
  22911. /**
  22912. * Specifies if the material will require alpha blending
  22913. * @returns a boolean specifying if alpha blending is needed
  22914. */
  22915. needAlphaBlending(): boolean;
  22916. /**
  22917. * Specifies if the mesh will require alpha blending
  22918. * @param mesh defines the mesh to check
  22919. * @returns a boolean specifying if alpha blending is needed for the mesh
  22920. */
  22921. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22922. /**
  22923. * Specifies if this material should be rendered in alpha test mode
  22924. * @returns a boolean specifying if an alpha test is needed.
  22925. */
  22926. needAlphaTesting(): boolean;
  22927. /**
  22928. * Gets the texture used for the alpha test
  22929. * @returns the texture to use for alpha testing
  22930. */
  22931. getAlphaTestTexture(): Nullable<BaseTexture>;
  22932. /**
  22933. * Marks the material to indicate that it needs to be re-calculated
  22934. */
  22935. markDirty(): void;
  22936. /** @hidden */
  22937. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22938. /**
  22939. * Binds the material to the mesh
  22940. * @param world defines the world transformation matrix
  22941. * @param mesh defines the mesh to bind the material to
  22942. */
  22943. bind(world: Matrix, mesh?: Mesh): void;
  22944. /**
  22945. * Binds the submesh to the material
  22946. * @param world defines the world transformation matrix
  22947. * @param mesh defines the mesh containing the submesh
  22948. * @param subMesh defines the submesh to bind the material to
  22949. */
  22950. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22951. /**
  22952. * Binds the world matrix to the material
  22953. * @param world defines the world transformation matrix
  22954. */
  22955. bindOnlyWorldMatrix(world: Matrix): void;
  22956. /**
  22957. * Binds the scene's uniform buffer to the effect.
  22958. * @param effect defines the effect to bind to the scene uniform buffer
  22959. * @param sceneUbo defines the uniform buffer storing scene data
  22960. */
  22961. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22962. /**
  22963. * Binds the view matrix to the effect
  22964. * @param effect defines the effect to bind the view matrix to
  22965. */
  22966. bindView(effect: Effect): void;
  22967. /**
  22968. * Binds the view projection matrix to the effect
  22969. * @param effect defines the effect to bind the view projection matrix to
  22970. */
  22971. bindViewProjection(effect: Effect): void;
  22972. /**
  22973. * Specifies if material alpha testing should be turned on for the mesh
  22974. * @param mesh defines the mesh to check
  22975. */
  22976. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22977. /**
  22978. * Processes to execute after binding the material to a mesh
  22979. * @param mesh defines the rendered mesh
  22980. */
  22981. protected _afterBind(mesh?: Mesh): void;
  22982. /**
  22983. * Unbinds the material from the mesh
  22984. */
  22985. unbind(): void;
  22986. /**
  22987. * Gets the active textures from the material
  22988. * @returns an array of textures
  22989. */
  22990. getActiveTextures(): BaseTexture[];
  22991. /**
  22992. * Specifies if the material uses a texture
  22993. * @param texture defines the texture to check against the material
  22994. * @returns a boolean specifying if the material uses the texture
  22995. */
  22996. hasTexture(texture: BaseTexture): boolean;
  22997. /**
  22998. * Makes a duplicate of the material, and gives it a new name
  22999. * @param name defines the new name for the duplicated material
  23000. * @returns the cloned material
  23001. */
  23002. clone(name: string): Nullable<Material>;
  23003. /**
  23004. * Gets the meshes bound to the material
  23005. * @returns an array of meshes bound to the material
  23006. */
  23007. getBindedMeshes(): AbstractMesh[];
  23008. /**
  23009. * Force shader compilation
  23010. * @param mesh defines the mesh associated with this material
  23011. * @param onCompiled defines a function to execute once the material is compiled
  23012. * @param options defines the options to configure the compilation
  23013. */
  23014. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23015. clipPlane: boolean;
  23016. }>): void;
  23017. /**
  23018. * Force shader compilation
  23019. * @param mesh defines the mesh that will use this material
  23020. * @param options defines additional options for compiling the shaders
  23021. * @returns a promise that resolves when the compilation completes
  23022. */
  23023. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23024. clipPlane: boolean;
  23025. }>): Promise<void>;
  23026. private static readonly _ImageProcessingDirtyCallBack;
  23027. private static readonly _TextureDirtyCallBack;
  23028. private static readonly _FresnelDirtyCallBack;
  23029. private static readonly _MiscDirtyCallBack;
  23030. private static readonly _LightsDirtyCallBack;
  23031. private static readonly _AttributeDirtyCallBack;
  23032. private static _FresnelAndMiscDirtyCallBack;
  23033. private static _TextureAndMiscDirtyCallBack;
  23034. private static readonly _DirtyCallbackArray;
  23035. private static readonly _RunDirtyCallBacks;
  23036. /**
  23037. * Marks a define in the material to indicate that it needs to be re-computed
  23038. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23039. */
  23040. markAsDirty(flag: number): void;
  23041. /**
  23042. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23043. * @param func defines a function which checks material defines against the submeshes
  23044. */
  23045. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23046. /**
  23047. * Indicates that image processing needs to be re-calculated for all submeshes
  23048. */
  23049. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23050. /**
  23051. * Indicates that textures need to be re-calculated for all submeshes
  23052. */
  23053. protected _markAllSubMeshesAsTexturesDirty(): void;
  23054. /**
  23055. * Indicates that fresnel needs to be re-calculated for all submeshes
  23056. */
  23057. protected _markAllSubMeshesAsFresnelDirty(): void;
  23058. /**
  23059. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23060. */
  23061. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23062. /**
  23063. * Indicates that lights need to be re-calculated for all submeshes
  23064. */
  23065. protected _markAllSubMeshesAsLightsDirty(): void;
  23066. /**
  23067. * Indicates that attributes need to be re-calculated for all submeshes
  23068. */
  23069. protected _markAllSubMeshesAsAttributesDirty(): void;
  23070. /**
  23071. * Indicates that misc needs to be re-calculated for all submeshes
  23072. */
  23073. protected _markAllSubMeshesAsMiscDirty(): void;
  23074. /**
  23075. * Indicates that textures and misc need to be re-calculated for all submeshes
  23076. */
  23077. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23078. /**
  23079. * Disposes the material
  23080. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23081. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23082. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23083. */
  23084. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23085. /** @hidden */
  23086. private releaseVertexArrayObject;
  23087. /**
  23088. * Serializes this material
  23089. * @returns the serialized material object
  23090. */
  23091. serialize(): any;
  23092. /**
  23093. * Creates a material from parsed material data
  23094. * @param parsedMaterial defines parsed material data
  23095. * @param scene defines the hosting scene
  23096. * @param rootUrl defines the root URL to use to load textures
  23097. * @returns a new material
  23098. */
  23099. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23100. }
  23101. }
  23102. declare module "babylonjs/Meshes/subMesh" {
  23103. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23104. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23105. import { Engine } from "babylonjs/Engines/engine";
  23106. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23107. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23108. import { Effect } from "babylonjs/Materials/effect";
  23109. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23110. import { Collider } from "babylonjs/Collisions/collider";
  23111. import { Material } from "babylonjs/Materials/material";
  23112. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23114. import { Mesh } from "babylonjs/Meshes/mesh";
  23115. import { Ray } from "babylonjs/Culling/ray";
  23116. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23117. /**
  23118. * Base class for submeshes
  23119. */
  23120. export class BaseSubMesh {
  23121. /** @hidden */
  23122. _materialDefines: Nullable<MaterialDefines>;
  23123. /** @hidden */
  23124. _materialEffect: Nullable<Effect>;
  23125. /**
  23126. * Gets associated effect
  23127. */
  23128. readonly effect: Nullable<Effect>;
  23129. /**
  23130. * Sets associated effect (effect used to render this submesh)
  23131. * @param effect defines the effect to associate with
  23132. * @param defines defines the set of defines used to compile this effect
  23133. */
  23134. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23135. }
  23136. /**
  23137. * Defines a subdivision inside a mesh
  23138. */
  23139. export class SubMesh extends BaseSubMesh implements ICullable {
  23140. /** the material index to use */
  23141. materialIndex: number;
  23142. /** vertex index start */
  23143. verticesStart: number;
  23144. /** vertices count */
  23145. verticesCount: number;
  23146. /** index start */
  23147. indexStart: number;
  23148. /** indices count */
  23149. indexCount: number;
  23150. /** @hidden */
  23151. _linesIndexCount: number;
  23152. private _mesh;
  23153. private _renderingMesh;
  23154. private _boundingInfo;
  23155. private _linesIndexBuffer;
  23156. /** @hidden */
  23157. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23158. /** @hidden */
  23159. _trianglePlanes: Plane[];
  23160. /** @hidden */
  23161. _lastColliderTransformMatrix: Nullable<Matrix>;
  23162. /** @hidden */
  23163. _renderId: number;
  23164. /** @hidden */
  23165. _alphaIndex: number;
  23166. /** @hidden */
  23167. _distanceToCamera: number;
  23168. /** @hidden */
  23169. _id: number;
  23170. private _currentMaterial;
  23171. /**
  23172. * Add a new submesh to a mesh
  23173. * @param materialIndex defines the material index to use
  23174. * @param verticesStart defines vertex index start
  23175. * @param verticesCount defines vertices count
  23176. * @param indexStart defines index start
  23177. * @param indexCount defines indices count
  23178. * @param mesh defines the parent mesh
  23179. * @param renderingMesh defines an optional rendering mesh
  23180. * @param createBoundingBox defines if bounding box should be created for this submesh
  23181. * @returns the new submesh
  23182. */
  23183. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23184. /**
  23185. * Creates a new submesh
  23186. * @param materialIndex defines the material index to use
  23187. * @param verticesStart defines vertex index start
  23188. * @param verticesCount defines vertices count
  23189. * @param indexStart defines index start
  23190. * @param indexCount defines indices count
  23191. * @param mesh defines the parent mesh
  23192. * @param renderingMesh defines an optional rendering mesh
  23193. * @param createBoundingBox defines if bounding box should be created for this submesh
  23194. */
  23195. constructor(
  23196. /** the material index to use */
  23197. materialIndex: number,
  23198. /** vertex index start */
  23199. verticesStart: number,
  23200. /** vertices count */
  23201. verticesCount: number,
  23202. /** index start */
  23203. indexStart: number,
  23204. /** indices count */
  23205. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23206. /**
  23207. * Returns true if this submesh covers the entire parent mesh
  23208. * @ignorenaming
  23209. */
  23210. readonly IsGlobal: boolean;
  23211. /**
  23212. * Returns the submesh BoudingInfo object
  23213. * @returns current bounding info (or mesh's one if the submesh is global)
  23214. */
  23215. getBoundingInfo(): BoundingInfo;
  23216. /**
  23217. * Sets the submesh BoundingInfo
  23218. * @param boundingInfo defines the new bounding info to use
  23219. * @returns the SubMesh
  23220. */
  23221. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23222. /**
  23223. * Returns the mesh of the current submesh
  23224. * @return the parent mesh
  23225. */
  23226. getMesh(): AbstractMesh;
  23227. /**
  23228. * Returns the rendering mesh of the submesh
  23229. * @returns the rendering mesh (could be different from parent mesh)
  23230. */
  23231. getRenderingMesh(): Mesh;
  23232. /**
  23233. * Returns the submesh material
  23234. * @returns null or the current material
  23235. */
  23236. getMaterial(): Nullable<Material>;
  23237. /**
  23238. * Sets a new updated BoundingInfo object to the submesh
  23239. * @param data defines an optional position array to use to determine the bounding info
  23240. * @returns the SubMesh
  23241. */
  23242. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23243. /** @hidden */
  23244. _checkCollision(collider: Collider): boolean;
  23245. /**
  23246. * Updates the submesh BoundingInfo
  23247. * @param world defines the world matrix to use to update the bounding info
  23248. * @returns the submesh
  23249. */
  23250. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23251. /**
  23252. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23253. * @param frustumPlanes defines the frustum planes
  23254. * @returns true if the submesh is intersecting with the frustum
  23255. */
  23256. isInFrustum(frustumPlanes: Plane[]): boolean;
  23257. /**
  23258. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23259. * @param frustumPlanes defines the frustum planes
  23260. * @returns true if the submesh is inside the frustum
  23261. */
  23262. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23263. /**
  23264. * Renders the submesh
  23265. * @param enableAlphaMode defines if alpha needs to be used
  23266. * @returns the submesh
  23267. */
  23268. render(enableAlphaMode: boolean): SubMesh;
  23269. /**
  23270. * @hidden
  23271. */
  23272. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23273. /**
  23274. * Checks if the submesh intersects with a ray
  23275. * @param ray defines the ray to test
  23276. * @returns true is the passed ray intersects the submesh bounding box
  23277. */
  23278. canIntersects(ray: Ray): boolean;
  23279. /**
  23280. * Intersects current submesh with a ray
  23281. * @param ray defines the ray to test
  23282. * @param positions defines mesh's positions array
  23283. * @param indices defines mesh's indices array
  23284. * @param fastCheck defines if only bounding info should be used
  23285. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23286. * @returns intersection info or null if no intersection
  23287. */
  23288. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23289. /** @hidden */
  23290. private _intersectLines;
  23291. /** @hidden */
  23292. private _intersectUnIndexedLines;
  23293. /** @hidden */
  23294. private _intersectTriangles;
  23295. /** @hidden */
  23296. private _intersectUnIndexedTriangles;
  23297. /** @hidden */
  23298. _rebuild(): void;
  23299. /**
  23300. * Creates a new submesh from the passed mesh
  23301. * @param newMesh defines the new hosting mesh
  23302. * @param newRenderingMesh defines an optional rendering mesh
  23303. * @returns the new submesh
  23304. */
  23305. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23306. /**
  23307. * Release associated resources
  23308. */
  23309. dispose(): void;
  23310. /**
  23311. * Gets the class name
  23312. * @returns the string "SubMesh".
  23313. */
  23314. getClassName(): string;
  23315. /**
  23316. * Creates a new submesh from indices data
  23317. * @param materialIndex the index of the main mesh material
  23318. * @param startIndex the index where to start the copy in the mesh indices array
  23319. * @param indexCount the number of indices to copy then from the startIndex
  23320. * @param mesh the main mesh to create the submesh from
  23321. * @param renderingMesh the optional rendering mesh
  23322. * @returns a new submesh
  23323. */
  23324. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23325. }
  23326. }
  23327. declare module "babylonjs/Meshes/geometry" {
  23328. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23329. import { Scene } from "babylonjs/scene";
  23330. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23331. import { Engine } from "babylonjs/Engines/engine";
  23332. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23333. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23334. import { Effect } from "babylonjs/Materials/effect";
  23335. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23336. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23337. import { Mesh } from "babylonjs/Meshes/mesh";
  23338. /**
  23339. * Class used to store geometry data (vertex buffers + index buffer)
  23340. */
  23341. export class Geometry implements IGetSetVerticesData {
  23342. /**
  23343. * Gets or sets the ID of the geometry
  23344. */
  23345. id: string;
  23346. /**
  23347. * Gets or sets the unique ID of the geometry
  23348. */
  23349. uniqueId: number;
  23350. /**
  23351. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23352. */
  23353. delayLoadState: number;
  23354. /**
  23355. * Gets the file containing the data to load when running in delay load state
  23356. */
  23357. delayLoadingFile: Nullable<string>;
  23358. /**
  23359. * Callback called when the geometry is updated
  23360. */
  23361. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23362. private _scene;
  23363. private _engine;
  23364. private _meshes;
  23365. private _totalVertices;
  23366. /** @hidden */
  23367. _indices: IndicesArray;
  23368. /** @hidden */
  23369. _vertexBuffers: {
  23370. [key: string]: VertexBuffer;
  23371. };
  23372. private _isDisposed;
  23373. private _extend;
  23374. private _boundingBias;
  23375. /** @hidden */
  23376. _delayInfo: Array<string>;
  23377. private _indexBuffer;
  23378. private _indexBufferIsUpdatable;
  23379. /** @hidden */
  23380. _boundingInfo: Nullable<BoundingInfo>;
  23381. /** @hidden */
  23382. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23383. /** @hidden */
  23384. _softwareSkinningFrameId: number;
  23385. private _vertexArrayObjects;
  23386. private _updatable;
  23387. /** @hidden */
  23388. _positions: Nullable<Vector3[]>;
  23389. /**
  23390. * 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
  23391. */
  23392. /**
  23393. * 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
  23394. */
  23395. boundingBias: Vector2;
  23396. /**
  23397. * Static function used to attach a new empty geometry to a mesh
  23398. * @param mesh defines the mesh to attach the geometry to
  23399. * @returns the new Geometry
  23400. */
  23401. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23402. /**
  23403. * Creates a new geometry
  23404. * @param id defines the unique ID
  23405. * @param scene defines the hosting scene
  23406. * @param vertexData defines the VertexData used to get geometry data
  23407. * @param updatable defines if geometry must be updatable (false by default)
  23408. * @param mesh defines the mesh that will be associated with the geometry
  23409. */
  23410. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23411. /**
  23412. * Gets the current extend of the geometry
  23413. */
  23414. readonly extend: {
  23415. minimum: Vector3;
  23416. maximum: Vector3;
  23417. };
  23418. /**
  23419. * Gets the hosting scene
  23420. * @returns the hosting Scene
  23421. */
  23422. getScene(): Scene;
  23423. /**
  23424. * Gets the hosting engine
  23425. * @returns the hosting Engine
  23426. */
  23427. getEngine(): Engine;
  23428. /**
  23429. * Defines if the geometry is ready to use
  23430. * @returns true if the geometry is ready to be used
  23431. */
  23432. isReady(): boolean;
  23433. /**
  23434. * Gets a value indicating that the geometry should not be serialized
  23435. */
  23436. readonly doNotSerialize: boolean;
  23437. /** @hidden */
  23438. _rebuild(): void;
  23439. /**
  23440. * Affects all geometry data in one call
  23441. * @param vertexData defines the geometry data
  23442. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23443. */
  23444. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23445. /**
  23446. * Set specific vertex data
  23447. * @param kind defines the data kind (Position, normal, etc...)
  23448. * @param data defines the vertex data to use
  23449. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23450. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23451. */
  23452. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23453. /**
  23454. * Removes a specific vertex data
  23455. * @param kind defines the data kind (Position, normal, etc...)
  23456. */
  23457. removeVerticesData(kind: string): void;
  23458. /**
  23459. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23460. * @param buffer defines the vertex buffer to use
  23461. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23462. */
  23463. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23464. /**
  23465. * Update a specific vertex buffer
  23466. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23467. * It will do nothing if the buffer is not updatable
  23468. * @param kind defines the data kind (Position, normal, etc...)
  23469. * @param data defines the data to use
  23470. * @param offset defines the offset in the target buffer where to store the data
  23471. * @param useBytes set to true if the offset is in bytes
  23472. */
  23473. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23474. /**
  23475. * Update a specific vertex buffer
  23476. * This function will create a new buffer if the current one is not updatable
  23477. * @param kind defines the data kind (Position, normal, etc...)
  23478. * @param data defines the data to use
  23479. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23480. */
  23481. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23482. private _updateBoundingInfo;
  23483. /** @hidden */
  23484. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23485. /**
  23486. * Gets total number of vertices
  23487. * @returns the total number of vertices
  23488. */
  23489. getTotalVertices(): number;
  23490. /**
  23491. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23492. * @param kind defines the data kind (Position, normal, etc...)
  23493. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23494. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23495. * @returns a float array containing vertex data
  23496. */
  23497. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23498. /**
  23499. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23500. * @param kind defines the data kind (Position, normal, etc...)
  23501. * @returns true if the vertex buffer with the specified kind is updatable
  23502. */
  23503. isVertexBufferUpdatable(kind: string): boolean;
  23504. /**
  23505. * Gets a specific vertex buffer
  23506. * @param kind defines the data kind (Position, normal, etc...)
  23507. * @returns a VertexBuffer
  23508. */
  23509. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23510. /**
  23511. * Returns all vertex buffers
  23512. * @return an object holding all vertex buffers indexed by kind
  23513. */
  23514. getVertexBuffers(): Nullable<{
  23515. [key: string]: VertexBuffer;
  23516. }>;
  23517. /**
  23518. * Gets a boolean indicating if specific vertex buffer is present
  23519. * @param kind defines the data kind (Position, normal, etc...)
  23520. * @returns true if data is present
  23521. */
  23522. isVerticesDataPresent(kind: string): boolean;
  23523. /**
  23524. * Gets a list of all attached data kinds (Position, normal, etc...)
  23525. * @returns a list of string containing all kinds
  23526. */
  23527. getVerticesDataKinds(): string[];
  23528. /**
  23529. * Update index buffer
  23530. * @param indices defines the indices to store in the index buffer
  23531. * @param offset defines the offset in the target buffer where to store the data
  23532. * @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)
  23533. */
  23534. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23535. /**
  23536. * Creates a new index buffer
  23537. * @param indices defines the indices to store in the index buffer
  23538. * @param totalVertices defines the total number of vertices (could be null)
  23539. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23540. */
  23541. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23542. /**
  23543. * Return the total number of indices
  23544. * @returns the total number of indices
  23545. */
  23546. getTotalIndices(): number;
  23547. /**
  23548. * Gets the index buffer array
  23549. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23550. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23551. * @returns the index buffer array
  23552. */
  23553. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23554. /**
  23555. * Gets the index buffer
  23556. * @return the index buffer
  23557. */
  23558. getIndexBuffer(): Nullable<DataBuffer>;
  23559. /** @hidden */
  23560. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23561. /**
  23562. * Release the associated resources for a specific mesh
  23563. * @param mesh defines the source mesh
  23564. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23565. */
  23566. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23567. /**
  23568. * Apply current geometry to a given mesh
  23569. * @param mesh defines the mesh to apply geometry to
  23570. */
  23571. applyToMesh(mesh: Mesh): void;
  23572. private _updateExtend;
  23573. private _applyToMesh;
  23574. private notifyUpdate;
  23575. /**
  23576. * Load the geometry if it was flagged as delay loaded
  23577. * @param scene defines the hosting scene
  23578. * @param onLoaded defines a callback called when the geometry is loaded
  23579. */
  23580. load(scene: Scene, onLoaded?: () => void): void;
  23581. private _queueLoad;
  23582. /**
  23583. * Invert the geometry to move from a right handed system to a left handed one.
  23584. */
  23585. toLeftHanded(): void;
  23586. /** @hidden */
  23587. _resetPointsArrayCache(): void;
  23588. /** @hidden */
  23589. _generatePointsArray(): boolean;
  23590. /**
  23591. * Gets a value indicating if the geometry is disposed
  23592. * @returns true if the geometry was disposed
  23593. */
  23594. isDisposed(): boolean;
  23595. private _disposeVertexArrayObjects;
  23596. /**
  23597. * Free all associated resources
  23598. */
  23599. dispose(): void;
  23600. /**
  23601. * Clone the current geometry into a new geometry
  23602. * @param id defines the unique ID of the new geometry
  23603. * @returns a new geometry object
  23604. */
  23605. copy(id: string): Geometry;
  23606. /**
  23607. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23608. * @return a JSON representation of the current geometry data (without the vertices data)
  23609. */
  23610. serialize(): any;
  23611. private toNumberArray;
  23612. /**
  23613. * Serialize all vertices data into a JSON oject
  23614. * @returns a JSON representation of the current geometry data
  23615. */
  23616. serializeVerticeData(): any;
  23617. /**
  23618. * Extracts a clone of a mesh geometry
  23619. * @param mesh defines the source mesh
  23620. * @param id defines the unique ID of the new geometry object
  23621. * @returns the new geometry object
  23622. */
  23623. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23624. /**
  23625. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23626. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23627. * Be aware Math.random() could cause collisions, but:
  23628. * "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"
  23629. * @returns a string containing a new GUID
  23630. */
  23631. static RandomId(): string;
  23632. /** @hidden */
  23633. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23634. private static _CleanMatricesWeights;
  23635. /**
  23636. * Create a new geometry from persisted data (Using .babylon file format)
  23637. * @param parsedVertexData defines the persisted data
  23638. * @param scene defines the hosting scene
  23639. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23640. * @returns the new geometry object
  23641. */
  23642. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23643. }
  23644. }
  23645. declare module "babylonjs/Meshes/mesh.vertexData" {
  23646. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23647. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23648. import { Geometry } from "babylonjs/Meshes/geometry";
  23649. import { Mesh } from "babylonjs/Meshes/mesh";
  23650. /**
  23651. * Define an interface for all classes that will get and set the data on vertices
  23652. */
  23653. export interface IGetSetVerticesData {
  23654. /**
  23655. * Gets a boolean indicating if specific vertex data is present
  23656. * @param kind defines the vertex data kind to use
  23657. * @returns true is data kind is present
  23658. */
  23659. isVerticesDataPresent(kind: string): boolean;
  23660. /**
  23661. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23662. * @param kind defines the data kind (Position, normal, etc...)
  23663. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23664. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23665. * @returns a float array containing vertex data
  23666. */
  23667. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23668. /**
  23669. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23670. * @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.
  23671. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23672. * @returns the indices array or an empty array if the mesh has no geometry
  23673. */
  23674. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23675. /**
  23676. * Set specific vertex data
  23677. * @param kind defines the data kind (Position, normal, etc...)
  23678. * @param data defines the vertex data to use
  23679. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23680. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23681. */
  23682. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23683. /**
  23684. * Update a specific associated vertex buffer
  23685. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23686. * - VertexBuffer.PositionKind
  23687. * - VertexBuffer.UVKind
  23688. * - VertexBuffer.UV2Kind
  23689. * - VertexBuffer.UV3Kind
  23690. * - VertexBuffer.UV4Kind
  23691. * - VertexBuffer.UV5Kind
  23692. * - VertexBuffer.UV6Kind
  23693. * - VertexBuffer.ColorKind
  23694. * - VertexBuffer.MatricesIndicesKind
  23695. * - VertexBuffer.MatricesIndicesExtraKind
  23696. * - VertexBuffer.MatricesWeightsKind
  23697. * - VertexBuffer.MatricesWeightsExtraKind
  23698. * @param data defines the data source
  23699. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23700. * @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)
  23701. */
  23702. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23703. /**
  23704. * Creates a new index buffer
  23705. * @param indices defines the indices to store in the index buffer
  23706. * @param totalVertices defines the total number of vertices (could be null)
  23707. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23708. */
  23709. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23710. }
  23711. /**
  23712. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23713. */
  23714. export class VertexData {
  23715. /**
  23716. * Mesh side orientation : usually the external or front surface
  23717. */
  23718. static readonly FRONTSIDE: number;
  23719. /**
  23720. * Mesh side orientation : usually the internal or back surface
  23721. */
  23722. static readonly BACKSIDE: number;
  23723. /**
  23724. * Mesh side orientation : both internal and external or front and back surfaces
  23725. */
  23726. static readonly DOUBLESIDE: number;
  23727. /**
  23728. * Mesh side orientation : by default, `FRONTSIDE`
  23729. */
  23730. static readonly DEFAULTSIDE: number;
  23731. /**
  23732. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23733. */
  23734. positions: Nullable<FloatArray>;
  23735. /**
  23736. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23737. */
  23738. normals: Nullable<FloatArray>;
  23739. /**
  23740. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23741. */
  23742. tangents: Nullable<FloatArray>;
  23743. /**
  23744. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23745. */
  23746. uvs: Nullable<FloatArray>;
  23747. /**
  23748. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23749. */
  23750. uvs2: Nullable<FloatArray>;
  23751. /**
  23752. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23753. */
  23754. uvs3: Nullable<FloatArray>;
  23755. /**
  23756. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23757. */
  23758. uvs4: Nullable<FloatArray>;
  23759. /**
  23760. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23761. */
  23762. uvs5: Nullable<FloatArray>;
  23763. /**
  23764. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23765. */
  23766. uvs6: Nullable<FloatArray>;
  23767. /**
  23768. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23769. */
  23770. colors: Nullable<FloatArray>;
  23771. /**
  23772. * 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).
  23773. */
  23774. matricesIndices: Nullable<FloatArray>;
  23775. /**
  23776. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23777. */
  23778. matricesWeights: Nullable<FloatArray>;
  23779. /**
  23780. * An array extending the number of possible indices
  23781. */
  23782. matricesIndicesExtra: Nullable<FloatArray>;
  23783. /**
  23784. * An array extending the number of possible weights when the number of indices is extended
  23785. */
  23786. matricesWeightsExtra: Nullable<FloatArray>;
  23787. /**
  23788. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23789. */
  23790. indices: Nullable<IndicesArray>;
  23791. /**
  23792. * Uses the passed data array to set the set the values for the specified kind of data
  23793. * @param data a linear array of floating numbers
  23794. * @param kind the type of data that is being set, eg positions, colors etc
  23795. */
  23796. set(data: FloatArray, kind: string): void;
  23797. /**
  23798. * Associates the vertexData to the passed Mesh.
  23799. * Sets it as updatable or not (default `false`)
  23800. * @param mesh the mesh the vertexData is applied to
  23801. * @param updatable when used and having the value true allows new data to update the vertexData
  23802. * @returns the VertexData
  23803. */
  23804. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23805. /**
  23806. * Associates the vertexData to the passed Geometry.
  23807. * Sets it as updatable or not (default `false`)
  23808. * @param geometry the geometry the vertexData is applied to
  23809. * @param updatable when used and having the value true allows new data to update the vertexData
  23810. * @returns VertexData
  23811. */
  23812. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23813. /**
  23814. * Updates the associated mesh
  23815. * @param mesh the mesh to be updated
  23816. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23817. * @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
  23818. * @returns VertexData
  23819. */
  23820. updateMesh(mesh: Mesh): VertexData;
  23821. /**
  23822. * Updates the associated geometry
  23823. * @param geometry the geometry to be updated
  23824. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23825. * @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
  23826. * @returns VertexData.
  23827. */
  23828. updateGeometry(geometry: Geometry): VertexData;
  23829. private _applyTo;
  23830. private _update;
  23831. /**
  23832. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23833. * @param matrix the transforming matrix
  23834. * @returns the VertexData
  23835. */
  23836. transform(matrix: Matrix): VertexData;
  23837. /**
  23838. * Merges the passed VertexData into the current one
  23839. * @param other the VertexData to be merged into the current one
  23840. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23841. * @returns the modified VertexData
  23842. */
  23843. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23844. private _mergeElement;
  23845. private _validate;
  23846. /**
  23847. * Serializes the VertexData
  23848. * @returns a serialized object
  23849. */
  23850. serialize(): any;
  23851. /**
  23852. * Extracts the vertexData from a mesh
  23853. * @param mesh the mesh from which to extract the VertexData
  23854. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23855. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23856. * @returns the object VertexData associated to the passed mesh
  23857. */
  23858. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23859. /**
  23860. * Extracts the vertexData from the geometry
  23861. * @param geometry the geometry from which to extract the VertexData
  23862. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23863. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23864. * @returns the object VertexData associated to the passed mesh
  23865. */
  23866. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23867. private static _ExtractFrom;
  23868. /**
  23869. * Creates the VertexData for a Ribbon
  23870. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23871. * * pathArray array of paths, each of which an array of successive Vector3
  23872. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23873. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23874. * * 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
  23875. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23876. * * 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)
  23877. * * 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)
  23878. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23879. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23880. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23881. * @returns the VertexData of the ribbon
  23882. */
  23883. static CreateRibbon(options: {
  23884. pathArray: Vector3[][];
  23885. closeArray?: boolean;
  23886. closePath?: boolean;
  23887. offset?: number;
  23888. sideOrientation?: number;
  23889. frontUVs?: Vector4;
  23890. backUVs?: Vector4;
  23891. invertUV?: boolean;
  23892. uvs?: Vector2[];
  23893. colors?: Color4[];
  23894. }): VertexData;
  23895. /**
  23896. * Creates the VertexData for a box
  23897. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23898. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23899. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23900. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23901. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23902. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23903. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23904. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23905. * * 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)
  23906. * * 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)
  23907. * @returns the VertexData of the box
  23908. */
  23909. static CreateBox(options: {
  23910. size?: number;
  23911. width?: number;
  23912. height?: number;
  23913. depth?: number;
  23914. faceUV?: Vector4[];
  23915. faceColors?: Color4[];
  23916. sideOrientation?: number;
  23917. frontUVs?: Vector4;
  23918. backUVs?: Vector4;
  23919. }): VertexData;
  23920. /**
  23921. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23922. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23923. * * segments sets the number of horizontal strips optional, default 32
  23924. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23925. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23926. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23927. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23928. * * 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
  23929. * * 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
  23930. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23931. * * 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)
  23932. * * 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)
  23933. * @returns the VertexData of the ellipsoid
  23934. */
  23935. static CreateSphere(options: {
  23936. segments?: number;
  23937. diameter?: number;
  23938. diameterX?: number;
  23939. diameterY?: number;
  23940. diameterZ?: number;
  23941. arc?: number;
  23942. slice?: number;
  23943. sideOrientation?: number;
  23944. frontUVs?: Vector4;
  23945. backUVs?: Vector4;
  23946. }): VertexData;
  23947. /**
  23948. * Creates the VertexData for a cylinder, cone or prism
  23949. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23950. * * height sets the height (y direction) of the cylinder, optional, default 2
  23951. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23952. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23953. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23954. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23955. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23956. * * 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
  23957. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23958. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23959. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23960. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23961. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23962. * * 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)
  23963. * * 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)
  23964. * @returns the VertexData of the cylinder, cone or prism
  23965. */
  23966. static CreateCylinder(options: {
  23967. height?: number;
  23968. diameterTop?: number;
  23969. diameterBottom?: number;
  23970. diameter?: number;
  23971. tessellation?: number;
  23972. subdivisions?: number;
  23973. arc?: number;
  23974. faceColors?: Color4[];
  23975. faceUV?: Vector4[];
  23976. hasRings?: boolean;
  23977. enclose?: boolean;
  23978. sideOrientation?: number;
  23979. frontUVs?: Vector4;
  23980. backUVs?: Vector4;
  23981. }): VertexData;
  23982. /**
  23983. * Creates the VertexData for a torus
  23984. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23985. * * diameter the diameter of the torus, optional default 1
  23986. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23987. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23988. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23989. * * 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)
  23990. * * 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)
  23991. * @returns the VertexData of the torus
  23992. */
  23993. static CreateTorus(options: {
  23994. diameter?: number;
  23995. thickness?: number;
  23996. tessellation?: number;
  23997. sideOrientation?: number;
  23998. frontUVs?: Vector4;
  23999. backUVs?: Vector4;
  24000. }): VertexData;
  24001. /**
  24002. * Creates the VertexData of the LineSystem
  24003. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24004. * - lines an array of lines, each line being an array of successive Vector3
  24005. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24006. * @returns the VertexData of the LineSystem
  24007. */
  24008. static CreateLineSystem(options: {
  24009. lines: Vector3[][];
  24010. colors?: Nullable<Color4[][]>;
  24011. }): VertexData;
  24012. /**
  24013. * Create the VertexData for a DashedLines
  24014. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24015. * - points an array successive Vector3
  24016. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24017. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24018. * - dashNb the intended total number of dashes, optional, default 200
  24019. * @returns the VertexData for the DashedLines
  24020. */
  24021. static CreateDashedLines(options: {
  24022. points: Vector3[];
  24023. dashSize?: number;
  24024. gapSize?: number;
  24025. dashNb?: number;
  24026. }): VertexData;
  24027. /**
  24028. * Creates the VertexData for a Ground
  24029. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24030. * - width the width (x direction) of the ground, optional, default 1
  24031. * - height the height (z direction) of the ground, optional, default 1
  24032. * - subdivisions the number of subdivisions per side, optional, default 1
  24033. * @returns the VertexData of the Ground
  24034. */
  24035. static CreateGround(options: {
  24036. width?: number;
  24037. height?: number;
  24038. subdivisions?: number;
  24039. subdivisionsX?: number;
  24040. subdivisionsY?: number;
  24041. }): VertexData;
  24042. /**
  24043. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24044. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24045. * * xmin the ground minimum X coordinate, optional, default -1
  24046. * * zmin the ground minimum Z coordinate, optional, default -1
  24047. * * xmax the ground maximum X coordinate, optional, default 1
  24048. * * zmax the ground maximum Z coordinate, optional, default 1
  24049. * * 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}
  24050. * * 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}
  24051. * @returns the VertexData of the TiledGround
  24052. */
  24053. static CreateTiledGround(options: {
  24054. xmin: number;
  24055. zmin: number;
  24056. xmax: number;
  24057. zmax: number;
  24058. subdivisions?: {
  24059. w: number;
  24060. h: number;
  24061. };
  24062. precision?: {
  24063. w: number;
  24064. h: number;
  24065. };
  24066. }): VertexData;
  24067. /**
  24068. * Creates the VertexData of the Ground designed from a heightmap
  24069. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24070. * * width the width (x direction) of the ground
  24071. * * height the height (z direction) of the ground
  24072. * * subdivisions the number of subdivisions per side
  24073. * * minHeight the minimum altitude on the ground, optional, default 0
  24074. * * maxHeight the maximum altitude on the ground, optional default 1
  24075. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24076. * * buffer the array holding the image color data
  24077. * * bufferWidth the width of image
  24078. * * bufferHeight the height of image
  24079. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24080. * @returns the VertexData of the Ground designed from a heightmap
  24081. */
  24082. static CreateGroundFromHeightMap(options: {
  24083. width: number;
  24084. height: number;
  24085. subdivisions: number;
  24086. minHeight: number;
  24087. maxHeight: number;
  24088. colorFilter: Color3;
  24089. buffer: Uint8Array;
  24090. bufferWidth: number;
  24091. bufferHeight: number;
  24092. alphaFilter: number;
  24093. }): VertexData;
  24094. /**
  24095. * Creates the VertexData for a Plane
  24096. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24097. * * size sets the width and height of the plane to the value of size, optional default 1
  24098. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24099. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24100. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24101. * * 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)
  24102. * * 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)
  24103. * @returns the VertexData of the box
  24104. */
  24105. static CreatePlane(options: {
  24106. size?: number;
  24107. width?: number;
  24108. height?: number;
  24109. sideOrientation?: number;
  24110. frontUVs?: Vector4;
  24111. backUVs?: Vector4;
  24112. }): VertexData;
  24113. /**
  24114. * Creates the VertexData of the Disc or regular Polygon
  24115. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24116. * * radius the radius of the disc, optional default 0.5
  24117. * * tessellation the number of polygon sides, optional, default 64
  24118. * * 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
  24119. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24120. * * 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)
  24121. * * 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)
  24122. * @returns the VertexData of the box
  24123. */
  24124. static CreateDisc(options: {
  24125. radius?: number;
  24126. tessellation?: number;
  24127. arc?: number;
  24128. sideOrientation?: number;
  24129. frontUVs?: Vector4;
  24130. backUVs?: Vector4;
  24131. }): VertexData;
  24132. /**
  24133. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24134. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24135. * @param polygon a mesh built from polygonTriangulation.build()
  24136. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24137. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24138. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24139. * @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)
  24140. * @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)
  24141. * @returns the VertexData of the Polygon
  24142. */
  24143. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24144. /**
  24145. * Creates the VertexData of the IcoSphere
  24146. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24147. * * radius the radius of the IcoSphere, optional default 1
  24148. * * radiusX allows stretching in the x direction, optional, default radius
  24149. * * radiusY allows stretching in the y direction, optional, default radius
  24150. * * radiusZ allows stretching in the z direction, optional, default radius
  24151. * * flat when true creates a flat shaded mesh, optional, default true
  24152. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24153. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24154. * * 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)
  24155. * * 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)
  24156. * @returns the VertexData of the IcoSphere
  24157. */
  24158. static CreateIcoSphere(options: {
  24159. radius?: number;
  24160. radiusX?: number;
  24161. radiusY?: number;
  24162. radiusZ?: number;
  24163. flat?: boolean;
  24164. subdivisions?: number;
  24165. sideOrientation?: number;
  24166. frontUVs?: Vector4;
  24167. backUVs?: Vector4;
  24168. }): VertexData;
  24169. /**
  24170. * Creates the VertexData for a Polyhedron
  24171. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24172. * * type provided types are:
  24173. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24174. * * 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)
  24175. * * size the size of the IcoSphere, optional default 1
  24176. * * sizeX allows stretching in the x direction, optional, default size
  24177. * * sizeY allows stretching in the y direction, optional, default size
  24178. * * sizeZ allows stretching in the z direction, optional, default size
  24179. * * 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
  24180. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24181. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24182. * * flat when true creates a flat shaded mesh, optional, default true
  24183. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24184. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24185. * * 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)
  24186. * * 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)
  24187. * @returns the VertexData of the Polyhedron
  24188. */
  24189. static CreatePolyhedron(options: {
  24190. type?: number;
  24191. size?: number;
  24192. sizeX?: number;
  24193. sizeY?: number;
  24194. sizeZ?: number;
  24195. custom?: any;
  24196. faceUV?: Vector4[];
  24197. faceColors?: Color4[];
  24198. flat?: boolean;
  24199. sideOrientation?: number;
  24200. frontUVs?: Vector4;
  24201. backUVs?: Vector4;
  24202. }): VertexData;
  24203. /**
  24204. * Creates the VertexData for a TorusKnot
  24205. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24206. * * radius the radius of the torus knot, optional, default 2
  24207. * * tube the thickness of the tube, optional, default 0.5
  24208. * * radialSegments the number of sides on each tube segments, optional, default 32
  24209. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24210. * * p the number of windings around the z axis, optional, default 2
  24211. * * q the number of windings around the x axis, optional, default 3
  24212. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24213. * * 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)
  24214. * * 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)
  24215. * @returns the VertexData of the Torus Knot
  24216. */
  24217. static CreateTorusKnot(options: {
  24218. radius?: number;
  24219. tube?: number;
  24220. radialSegments?: number;
  24221. tubularSegments?: number;
  24222. p?: number;
  24223. q?: number;
  24224. sideOrientation?: number;
  24225. frontUVs?: Vector4;
  24226. backUVs?: Vector4;
  24227. }): VertexData;
  24228. /**
  24229. * Compute normals for given positions and indices
  24230. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24231. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24232. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24233. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24234. * * facetNormals : optional array of facet normals (vector3)
  24235. * * facetPositions : optional array of facet positions (vector3)
  24236. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24237. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24238. * * bInfo : optional bounding info, required for facetPartitioning computation
  24239. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24240. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24241. * * useRightHandedSystem: optional boolean to for right handed system computation
  24242. * * depthSort : optional boolean to enable the facet depth sort computation
  24243. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24244. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24245. */
  24246. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24247. facetNormals?: any;
  24248. facetPositions?: any;
  24249. facetPartitioning?: any;
  24250. ratio?: number;
  24251. bInfo?: any;
  24252. bbSize?: Vector3;
  24253. subDiv?: any;
  24254. useRightHandedSystem?: boolean;
  24255. depthSort?: boolean;
  24256. distanceTo?: Vector3;
  24257. depthSortedFacets?: any;
  24258. }): void;
  24259. /** @hidden */
  24260. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24261. /**
  24262. * Applies VertexData created from the imported parameters to the geometry
  24263. * @param parsedVertexData the parsed data from an imported file
  24264. * @param geometry the geometry to apply the VertexData to
  24265. */
  24266. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24267. }
  24268. }
  24269. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24270. import { Nullable } from "babylonjs/types";
  24271. import { Scene } from "babylonjs/scene";
  24272. import { Vector4 } from "babylonjs/Maths/math";
  24273. import { Mesh } from "babylonjs/Meshes/mesh";
  24274. /**
  24275. * Class containing static functions to help procedurally build meshes
  24276. */
  24277. export class DiscBuilder {
  24278. /**
  24279. * Creates a plane polygonal mesh. By default, this is a disc
  24280. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24281. * * 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
  24282. * * 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
  24283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24286. * @param name defines the name of the mesh
  24287. * @param options defines the options used to create the mesh
  24288. * @param scene defines the hosting scene
  24289. * @returns the plane polygonal mesh
  24290. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24291. */
  24292. static CreateDisc(name: string, options: {
  24293. radius?: number;
  24294. tessellation?: number;
  24295. arc?: number;
  24296. updatable?: boolean;
  24297. sideOrientation?: number;
  24298. frontUVs?: Vector4;
  24299. backUVs?: Vector4;
  24300. }, scene?: Nullable<Scene>): Mesh;
  24301. }
  24302. }
  24303. declare module "babylonjs/Particles/solidParticleSystem" {
  24304. import { Vector3 } from "babylonjs/Maths/math";
  24305. import { Mesh } from "babylonjs/Meshes/mesh";
  24306. import { Scene, IDisposable } from "babylonjs/scene";
  24307. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24308. /**
  24309. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24310. *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.
  24311. * The SPS is also a particle system. It provides some methods to manage the particles.
  24312. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24313. *
  24314. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24315. */
  24316. export class SolidParticleSystem implements IDisposable {
  24317. /**
  24318. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24319. * Example : var p = SPS.particles[i];
  24320. */
  24321. particles: SolidParticle[];
  24322. /**
  24323. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24324. */
  24325. nbParticles: number;
  24326. /**
  24327. * If the particles must ever face the camera (default false). Useful for planar particles.
  24328. */
  24329. billboard: boolean;
  24330. /**
  24331. * Recompute normals when adding a shape
  24332. */
  24333. recomputeNormals: boolean;
  24334. /**
  24335. * This a counter ofr your own usage. It's not set by any SPS functions.
  24336. */
  24337. counter: number;
  24338. /**
  24339. * The SPS name. This name is also given to the underlying mesh.
  24340. */
  24341. name: string;
  24342. /**
  24343. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24344. */
  24345. mesh: Mesh;
  24346. /**
  24347. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24348. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24349. */
  24350. vars: any;
  24351. /**
  24352. * This array is populated when the SPS is set as 'pickable'.
  24353. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24354. * Each element of this array is an object `{idx: int, faceId: int}`.
  24355. * `idx` is the picked particle index in the `SPS.particles` array
  24356. * `faceId` is the picked face index counted within this particle.
  24357. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24358. */
  24359. pickedParticles: {
  24360. idx: number;
  24361. faceId: number;
  24362. }[];
  24363. /**
  24364. * This array is populated when `enableDepthSort` is set to true.
  24365. * Each element of this array is an instance of the class DepthSortedParticle.
  24366. */
  24367. depthSortedParticles: DepthSortedParticle[];
  24368. /**
  24369. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24370. * @hidden
  24371. */
  24372. _bSphereOnly: boolean;
  24373. /**
  24374. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24375. * @hidden
  24376. */
  24377. _bSphereRadiusFactor: number;
  24378. private _scene;
  24379. private _positions;
  24380. private _indices;
  24381. private _normals;
  24382. private _colors;
  24383. private _uvs;
  24384. private _indices32;
  24385. private _positions32;
  24386. private _normals32;
  24387. private _fixedNormal32;
  24388. private _colors32;
  24389. private _uvs32;
  24390. private _index;
  24391. private _updatable;
  24392. private _pickable;
  24393. private _isVisibilityBoxLocked;
  24394. private _alwaysVisible;
  24395. private _depthSort;
  24396. private _shapeCounter;
  24397. private _copy;
  24398. private _color;
  24399. private _computeParticleColor;
  24400. private _computeParticleTexture;
  24401. private _computeParticleRotation;
  24402. private _computeParticleVertex;
  24403. private _computeBoundingBox;
  24404. private _depthSortParticles;
  24405. private _camera;
  24406. private _mustUnrotateFixedNormals;
  24407. private _particlesIntersect;
  24408. private _needs32Bits;
  24409. /**
  24410. * Creates a SPS (Solid Particle System) object.
  24411. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24412. * @param scene (Scene) is the scene in which the SPS is added.
  24413. * @param options defines the options of the sps e.g.
  24414. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24415. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24416. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24417. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24418. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24419. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24420. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24421. */
  24422. constructor(name: string, scene: Scene, options?: {
  24423. updatable?: boolean;
  24424. isPickable?: boolean;
  24425. enableDepthSort?: boolean;
  24426. particleIntersection?: boolean;
  24427. boundingSphereOnly?: boolean;
  24428. bSphereRadiusFactor?: number;
  24429. });
  24430. /**
  24431. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24432. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24433. * @returns the created mesh
  24434. */
  24435. buildMesh(): Mesh;
  24436. /**
  24437. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24438. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24439. * Thus the particles generated from `digest()` have their property `position` set yet.
  24440. * @param mesh ( Mesh ) is the mesh to be digested
  24441. * @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
  24442. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24443. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24444. * @returns the current SPS
  24445. */
  24446. digest(mesh: Mesh, options?: {
  24447. facetNb?: number;
  24448. number?: number;
  24449. delta?: number;
  24450. }): SolidParticleSystem;
  24451. private _unrotateFixedNormals;
  24452. private _resetCopy;
  24453. private _meshBuilder;
  24454. private _posToShape;
  24455. private _uvsToShapeUV;
  24456. private _addParticle;
  24457. /**
  24458. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24459. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24460. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24461. * @param nb (positive integer) the number of particles to be created from this model
  24462. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24463. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24464. * @returns the number of shapes in the system
  24465. */
  24466. addShape(mesh: Mesh, nb: number, options?: {
  24467. positionFunction?: any;
  24468. vertexFunction?: any;
  24469. }): number;
  24470. private _rebuildParticle;
  24471. /**
  24472. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24473. * @returns the SPS.
  24474. */
  24475. rebuildMesh(): SolidParticleSystem;
  24476. /**
  24477. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24478. * This method calls `updateParticle()` for each particle of the SPS.
  24479. * For an animated SPS, it is usually called within the render loop.
  24480. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24481. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24482. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24483. * @returns the SPS.
  24484. */
  24485. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24486. /**
  24487. * Disposes the SPS.
  24488. */
  24489. dispose(): void;
  24490. /**
  24491. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24492. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24493. * @returns the SPS.
  24494. */
  24495. refreshVisibleSize(): SolidParticleSystem;
  24496. /**
  24497. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24498. * @param size the size (float) of the visibility box
  24499. * note : this doesn't lock the SPS mesh bounding box.
  24500. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24501. */
  24502. setVisibilityBox(size: number): void;
  24503. /**
  24504. * Gets whether the SPS as always visible or not
  24505. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24506. */
  24507. /**
  24508. * Sets the SPS as always visible or not
  24509. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24510. */
  24511. isAlwaysVisible: boolean;
  24512. /**
  24513. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24514. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24515. */
  24516. /**
  24517. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24518. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24519. */
  24520. isVisibilityBoxLocked: boolean;
  24521. /**
  24522. * Tells to `setParticles()` to compute the particle rotations or not.
  24523. * Default value : true. The SPS is faster when it's set to false.
  24524. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24525. */
  24526. /**
  24527. * Gets if `setParticles()` computes the particle rotations or not.
  24528. * Default value : true. The SPS is faster when it's set to false.
  24529. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24530. */
  24531. computeParticleRotation: boolean;
  24532. /**
  24533. * Tells to `setParticles()` to compute the particle colors or not.
  24534. * Default value : true. The SPS is faster when it's set to false.
  24535. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24536. */
  24537. /**
  24538. * Gets if `setParticles()` computes the particle colors or not.
  24539. * Default value : true. The SPS is faster when it's set to false.
  24540. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24541. */
  24542. computeParticleColor: boolean;
  24543. /**
  24544. * Gets if `setParticles()` computes the particle textures or not.
  24545. * Default value : true. The SPS is faster when it's set to false.
  24546. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24547. */
  24548. computeParticleTexture: boolean;
  24549. /**
  24550. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24551. * Default value : false. The SPS is faster when it's set to false.
  24552. * Note : the particle custom vertex positions aren't stored values.
  24553. */
  24554. /**
  24555. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24556. * Default value : false. The SPS is faster when it's set to false.
  24557. * Note : the particle custom vertex positions aren't stored values.
  24558. */
  24559. computeParticleVertex: boolean;
  24560. /**
  24561. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24562. */
  24563. /**
  24564. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24565. */
  24566. computeBoundingBox: boolean;
  24567. /**
  24568. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24569. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24570. * Default : `true`
  24571. */
  24572. /**
  24573. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24574. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24575. * Default : `true`
  24576. */
  24577. depthSortParticles: boolean;
  24578. /**
  24579. * This function does nothing. It may be overwritten to set all the particle first values.
  24580. * The SPS doesn't call this function, you may have to call it by your own.
  24581. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24582. */
  24583. initParticles(): void;
  24584. /**
  24585. * This function does nothing. It may be overwritten to recycle a particle.
  24586. * The SPS doesn't call this function, you may have to call it by your own.
  24587. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24588. * @param particle The particle to recycle
  24589. * @returns the recycled particle
  24590. */
  24591. recycleParticle(particle: SolidParticle): SolidParticle;
  24592. /**
  24593. * Updates a particle : this function should be overwritten by the user.
  24594. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24595. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24596. * @example : just set a particle position or velocity and recycle conditions
  24597. * @param particle The particle to update
  24598. * @returns the updated particle
  24599. */
  24600. updateParticle(particle: SolidParticle): SolidParticle;
  24601. /**
  24602. * Updates a vertex of a particle : it can be overwritten by the user.
  24603. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24604. * @param particle the current particle
  24605. * @param vertex the current index of the current particle
  24606. * @param pt the index of the current vertex in the particle shape
  24607. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24608. * @example : just set a vertex particle position
  24609. * @returns the updated vertex
  24610. */
  24611. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24612. /**
  24613. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24614. * This does nothing and may be overwritten by the user.
  24615. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24616. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24617. * @param update the boolean update value actually passed to setParticles()
  24618. */
  24619. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24620. /**
  24621. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24622. * This will be passed three parameters.
  24623. * This does nothing and may be overwritten by the user.
  24624. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24625. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24626. * @param update the boolean update value actually passed to setParticles()
  24627. */
  24628. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24629. }
  24630. }
  24631. declare module "babylonjs/Particles/solidParticle" {
  24632. import { Nullable } from "babylonjs/types";
  24633. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24634. import { Mesh } from "babylonjs/Meshes/mesh";
  24635. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24636. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24637. /**
  24638. * Represents one particle of a solid particle system.
  24639. */
  24640. export class SolidParticle {
  24641. /**
  24642. * particle global index
  24643. */
  24644. idx: number;
  24645. /**
  24646. * The color of the particle
  24647. */
  24648. color: Nullable<Color4>;
  24649. /**
  24650. * The world space position of the particle.
  24651. */
  24652. position: Vector3;
  24653. /**
  24654. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24655. */
  24656. rotation: Vector3;
  24657. /**
  24658. * The world space rotation quaternion of the particle.
  24659. */
  24660. rotationQuaternion: Nullable<Quaternion>;
  24661. /**
  24662. * The scaling of the particle.
  24663. */
  24664. scaling: Vector3;
  24665. /**
  24666. * The uvs of the particle.
  24667. */
  24668. uvs: Vector4;
  24669. /**
  24670. * The current speed of the particle.
  24671. */
  24672. velocity: Vector3;
  24673. /**
  24674. * The pivot point in the particle local space.
  24675. */
  24676. pivot: Vector3;
  24677. /**
  24678. * Must the particle be translated from its pivot point in its local space ?
  24679. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24680. * Default : false
  24681. */
  24682. translateFromPivot: boolean;
  24683. /**
  24684. * Is the particle active or not ?
  24685. */
  24686. alive: boolean;
  24687. /**
  24688. * Is the particle visible or not ?
  24689. */
  24690. isVisible: boolean;
  24691. /**
  24692. * Index of this particle in the global "positions" array (Internal use)
  24693. * @hidden
  24694. */
  24695. _pos: number;
  24696. /**
  24697. * @hidden Index of this particle in the global "indices" array (Internal use)
  24698. */
  24699. _ind: number;
  24700. /**
  24701. * @hidden ModelShape of this particle (Internal use)
  24702. */
  24703. _model: ModelShape;
  24704. /**
  24705. * ModelShape id of this particle
  24706. */
  24707. shapeId: number;
  24708. /**
  24709. * Index of the particle in its shape id (Internal use)
  24710. */
  24711. idxInShape: number;
  24712. /**
  24713. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24714. */
  24715. _modelBoundingInfo: BoundingInfo;
  24716. /**
  24717. * @hidden Particle BoundingInfo object (Internal use)
  24718. */
  24719. _boundingInfo: BoundingInfo;
  24720. /**
  24721. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24722. */
  24723. _sps: SolidParticleSystem;
  24724. /**
  24725. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24726. */
  24727. _stillInvisible: boolean;
  24728. /**
  24729. * @hidden Last computed particle rotation matrix
  24730. */
  24731. _rotationMatrix: number[];
  24732. /**
  24733. * Parent particle Id, if any.
  24734. * Default null.
  24735. */
  24736. parentId: Nullable<number>;
  24737. /**
  24738. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24739. * The possible values are :
  24740. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24741. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24742. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24743. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24744. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24745. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24746. * */
  24747. cullingStrategy: number;
  24748. /**
  24749. * @hidden Internal global position in the SPS.
  24750. */
  24751. _globalPosition: Vector3;
  24752. /**
  24753. * Creates a Solid Particle object.
  24754. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24755. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24756. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24757. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24758. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24759. * @param shapeId (integer) is the model shape identifier in the SPS.
  24760. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24761. * @param sps defines the sps it is associated to
  24762. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24763. */
  24764. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24765. /**
  24766. * Legacy support, changed scale to scaling
  24767. */
  24768. /**
  24769. * Legacy support, changed scale to scaling
  24770. */
  24771. scale: Vector3;
  24772. /**
  24773. * Legacy support, changed quaternion to rotationQuaternion
  24774. */
  24775. /**
  24776. * Legacy support, changed quaternion to rotationQuaternion
  24777. */
  24778. quaternion: Nullable<Quaternion>;
  24779. /**
  24780. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24781. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24782. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24783. * @returns true if it intersects
  24784. */
  24785. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24786. /**
  24787. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24788. * A particle is in the frustum if its bounding box intersects the frustum
  24789. * @param frustumPlanes defines the frustum to test
  24790. * @returns true if the particle is in the frustum planes
  24791. */
  24792. isInFrustum(frustumPlanes: Plane[]): boolean;
  24793. /**
  24794. * get the rotation matrix of the particle
  24795. * @hidden
  24796. */
  24797. getRotationMatrix(m: Matrix): void;
  24798. }
  24799. /**
  24800. * Represents the shape of the model used by one particle of a solid particle system.
  24801. * SPS internal tool, don't use it manually.
  24802. */
  24803. export class ModelShape {
  24804. /**
  24805. * The shape id
  24806. * @hidden
  24807. */
  24808. shapeID: number;
  24809. /**
  24810. * flat array of model positions (internal use)
  24811. * @hidden
  24812. */
  24813. _shape: Vector3[];
  24814. /**
  24815. * flat array of model UVs (internal use)
  24816. * @hidden
  24817. */
  24818. _shapeUV: number[];
  24819. /**
  24820. * length of the shape in the model indices array (internal use)
  24821. * @hidden
  24822. */
  24823. _indicesLength: number;
  24824. /**
  24825. * Custom position function (internal use)
  24826. * @hidden
  24827. */
  24828. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24829. /**
  24830. * Custom vertex function (internal use)
  24831. * @hidden
  24832. */
  24833. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24834. /**
  24835. * 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.
  24836. * SPS internal tool, don't use it manually.
  24837. * @hidden
  24838. */
  24839. 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>);
  24840. }
  24841. /**
  24842. * Represents a Depth Sorted Particle in the solid particle system.
  24843. */
  24844. export class DepthSortedParticle {
  24845. /**
  24846. * Index of the particle in the "indices" array
  24847. */
  24848. ind: number;
  24849. /**
  24850. * Length of the particle shape in the "indices" array
  24851. */
  24852. indicesLength: number;
  24853. /**
  24854. * Squared distance from the particle to the camera
  24855. */
  24856. sqDistance: number;
  24857. }
  24858. }
  24859. declare module "babylonjs/Collisions/meshCollisionData" {
  24860. import { Collider } from "babylonjs/Collisions/collider";
  24861. import { Vector3 } from "babylonjs/Maths/math";
  24862. import { Nullable } from "babylonjs/types";
  24863. import { Observer } from "babylonjs/Misc/observable";
  24864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24865. /**
  24866. * @hidden
  24867. */
  24868. export class _MeshCollisionData {
  24869. _checkCollisions: boolean;
  24870. _collisionMask: number;
  24871. _collisionGroup: number;
  24872. _collider: Nullable<Collider>;
  24873. _oldPositionForCollisions: Vector3;
  24874. _diffPositionForCollisions: Vector3;
  24875. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24876. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24877. }
  24878. }
  24879. declare module "babylonjs/Meshes/abstractMesh" {
  24880. import { Observable } from "babylonjs/Misc/observable";
  24881. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24882. import { Camera } from "babylonjs/Cameras/camera";
  24883. import { Scene, IDisposable } from "babylonjs/scene";
  24884. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24885. import { Node } from "babylonjs/node";
  24886. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24887. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24888. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24889. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24890. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24891. import { Material } from "babylonjs/Materials/material";
  24892. import { Light } from "babylonjs/Lights/light";
  24893. import { Skeleton } from "babylonjs/Bones/skeleton";
  24894. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24895. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24896. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24897. import { Ray } from "babylonjs/Culling/ray";
  24898. import { Collider } from "babylonjs/Collisions/collider";
  24899. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24900. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  24901. /** @hidden */
  24902. class _FacetDataStorage {
  24903. facetPositions: Vector3[];
  24904. facetNormals: Vector3[];
  24905. facetPartitioning: number[][];
  24906. facetNb: number;
  24907. partitioningSubdivisions: number;
  24908. partitioningBBoxRatio: number;
  24909. facetDataEnabled: boolean;
  24910. facetParameters: any;
  24911. bbSize: Vector3;
  24912. subDiv: {
  24913. max: number;
  24914. X: number;
  24915. Y: number;
  24916. Z: number;
  24917. };
  24918. facetDepthSort: boolean;
  24919. facetDepthSortEnabled: boolean;
  24920. depthSortedIndices: IndicesArray;
  24921. depthSortedFacets: {
  24922. ind: number;
  24923. sqDistance: number;
  24924. }[];
  24925. facetDepthSortFunction: (f1: {
  24926. ind: number;
  24927. sqDistance: number;
  24928. }, f2: {
  24929. ind: number;
  24930. sqDistance: number;
  24931. }) => number;
  24932. facetDepthSortFrom: Vector3;
  24933. facetDepthSortOrigin: Vector3;
  24934. invertedMatrix: Matrix;
  24935. }
  24936. /**
  24937. * @hidden
  24938. **/
  24939. class _InternalAbstractMeshDataInfo {
  24940. _hasVertexAlpha: boolean;
  24941. _useVertexColors: boolean;
  24942. _numBoneInfluencers: number;
  24943. _applyFog: boolean;
  24944. _receiveShadows: boolean;
  24945. _facetData: _FacetDataStorage;
  24946. _visibility: number;
  24947. _skeleton: Nullable<Skeleton>;
  24948. _layerMask: number;
  24949. _computeBonesUsingShaders: boolean;
  24950. _isActive: boolean;
  24951. _onlyForInstances: boolean;
  24952. _isActiveIntermediate: boolean;
  24953. _onlyForInstancesIntermediate: boolean;
  24954. }
  24955. /**
  24956. * Class used to store all common mesh properties
  24957. */
  24958. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24959. /** No occlusion */
  24960. static OCCLUSION_TYPE_NONE: number;
  24961. /** Occlusion set to optimisitic */
  24962. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24963. /** Occlusion set to strict */
  24964. static OCCLUSION_TYPE_STRICT: number;
  24965. /** Use an accurante occlusion algorithm */
  24966. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24967. /** Use a conservative occlusion algorithm */
  24968. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24969. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24970. * Test order :
  24971. * Is the bounding sphere outside the frustum ?
  24972. * If not, are the bounding box vertices outside the frustum ?
  24973. * It not, then the cullable object is in the frustum.
  24974. */
  24975. static readonly CULLINGSTRATEGY_STANDARD: number;
  24976. /** Culling strategy : Bounding Sphere Only.
  24977. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24978. * It's also less accurate than the standard because some not visible objects can still be selected.
  24979. * Test : is the bounding sphere outside the frustum ?
  24980. * If not, then the cullable object is in the frustum.
  24981. */
  24982. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24983. /** Culling strategy : Optimistic Inclusion.
  24984. * This in an inclusion test first, then the standard exclusion test.
  24985. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24986. * 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.
  24987. * Anyway, it's as accurate as the standard strategy.
  24988. * Test :
  24989. * Is the cullable object bounding sphere center in the frustum ?
  24990. * If not, apply the default culling strategy.
  24991. */
  24992. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24993. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24994. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24995. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24996. * 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.
  24997. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24998. * Test :
  24999. * Is the cullable object bounding sphere center in the frustum ?
  25000. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25001. */
  25002. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25003. /**
  25004. * No billboard
  25005. */
  25006. static readonly BILLBOARDMODE_NONE: number;
  25007. /** Billboard on X axis */
  25008. static readonly BILLBOARDMODE_X: number;
  25009. /** Billboard on Y axis */
  25010. static readonly BILLBOARDMODE_Y: number;
  25011. /** Billboard on Z axis */
  25012. static readonly BILLBOARDMODE_Z: number;
  25013. /** Billboard on all axes */
  25014. static readonly BILLBOARDMODE_ALL: number;
  25015. /** @hidden */
  25016. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25017. /**
  25018. * The culling strategy to use to check whether the mesh must be rendered or not.
  25019. * This value can be changed at any time and will be used on the next render mesh selection.
  25020. * The possible values are :
  25021. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25022. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25023. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25024. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25025. * Please read each static variable documentation to get details about the culling process.
  25026. * */
  25027. cullingStrategy: number;
  25028. /**
  25029. * Gets the number of facets in the mesh
  25030. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25031. */
  25032. readonly facetNb: number;
  25033. /**
  25034. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25035. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25036. */
  25037. partitioningSubdivisions: number;
  25038. /**
  25039. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25040. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25041. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25042. */
  25043. partitioningBBoxRatio: number;
  25044. /**
  25045. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25046. * Works only for updatable meshes.
  25047. * Doesn't work with multi-materials
  25048. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25049. */
  25050. mustDepthSortFacets: boolean;
  25051. /**
  25052. * The location (Vector3) where the facet depth sort must be computed from.
  25053. * By default, the active camera position.
  25054. * Used only when facet depth sort is enabled
  25055. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25056. */
  25057. facetDepthSortFrom: Vector3;
  25058. /**
  25059. * gets a boolean indicating if facetData is enabled
  25060. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25061. */
  25062. readonly isFacetDataEnabled: boolean;
  25063. /** @hidden */
  25064. _updateNonUniformScalingState(value: boolean): boolean;
  25065. /**
  25066. * An event triggered when this mesh collides with another one
  25067. */
  25068. onCollideObservable: Observable<AbstractMesh>;
  25069. /** Set a function to call when this mesh collides with another one */
  25070. onCollide: () => void;
  25071. /**
  25072. * An event triggered when the collision's position changes
  25073. */
  25074. onCollisionPositionChangeObservable: Observable<Vector3>;
  25075. /** Set a function to call when the collision's position changes */
  25076. onCollisionPositionChange: () => void;
  25077. /**
  25078. * An event triggered when material is changed
  25079. */
  25080. onMaterialChangedObservable: Observable<AbstractMesh>;
  25081. /**
  25082. * Gets or sets the orientation for POV movement & rotation
  25083. */
  25084. definedFacingForward: boolean;
  25085. /** @hidden */
  25086. _occlusionQuery: Nullable<WebGLQuery>;
  25087. /** @hidden */
  25088. _renderingGroup: Nullable<RenderingGroup>;
  25089. /**
  25090. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25091. */
  25092. /**
  25093. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25094. */
  25095. visibility: number;
  25096. /** Gets or sets the alpha index used to sort transparent meshes
  25097. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25098. */
  25099. alphaIndex: number;
  25100. /**
  25101. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25102. */
  25103. isVisible: boolean;
  25104. /**
  25105. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25106. */
  25107. isPickable: boolean;
  25108. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25109. showSubMeshesBoundingBox: boolean;
  25110. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25111. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25112. */
  25113. isBlocker: boolean;
  25114. /**
  25115. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25116. */
  25117. enablePointerMoveEvents: boolean;
  25118. /**
  25119. * Specifies the rendering group id for this mesh (0 by default)
  25120. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25121. */
  25122. renderingGroupId: number;
  25123. private _material;
  25124. /** Gets or sets current material */
  25125. material: Nullable<Material>;
  25126. /**
  25127. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25128. * @see http://doc.babylonjs.com/babylon101/shadows
  25129. */
  25130. receiveShadows: boolean;
  25131. /** Defines color to use when rendering outline */
  25132. outlineColor: Color3;
  25133. /** Define width to use when rendering outline */
  25134. outlineWidth: number;
  25135. /** Defines color to use when rendering overlay */
  25136. overlayColor: Color3;
  25137. /** Defines alpha to use when rendering overlay */
  25138. overlayAlpha: number;
  25139. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25140. hasVertexAlpha: boolean;
  25141. /** 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) */
  25142. useVertexColors: boolean;
  25143. /**
  25144. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25145. */
  25146. computeBonesUsingShaders: boolean;
  25147. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25148. numBoneInfluencers: number;
  25149. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25150. applyFog: boolean;
  25151. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25152. useOctreeForRenderingSelection: boolean;
  25153. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25154. useOctreeForPicking: boolean;
  25155. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25156. useOctreeForCollisions: boolean;
  25157. /**
  25158. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25159. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25160. */
  25161. layerMask: number;
  25162. /**
  25163. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25164. */
  25165. alwaysSelectAsActiveMesh: boolean;
  25166. /**
  25167. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25168. */
  25169. doNotSyncBoundingInfo: boolean;
  25170. /**
  25171. * Gets or sets the current action manager
  25172. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25173. */
  25174. actionManager: Nullable<AbstractActionManager>;
  25175. private _meshCollisionData;
  25176. /**
  25177. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25178. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25179. */
  25180. ellipsoid: Vector3;
  25181. /**
  25182. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25183. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25184. */
  25185. ellipsoidOffset: Vector3;
  25186. /**
  25187. * Gets or sets a collision mask used to mask collisions (default is -1).
  25188. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25189. */
  25190. collisionMask: number;
  25191. /**
  25192. * Gets or sets the current collision group mask (-1 by default).
  25193. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25194. */
  25195. collisionGroup: number;
  25196. /**
  25197. * Defines edge width used when edgesRenderer is enabled
  25198. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25199. */
  25200. edgesWidth: number;
  25201. /**
  25202. * Defines edge color used when edgesRenderer is enabled
  25203. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25204. */
  25205. edgesColor: Color4;
  25206. /** @hidden */
  25207. _edgesRenderer: Nullable<IEdgesRenderer>;
  25208. /** @hidden */
  25209. _masterMesh: Nullable<AbstractMesh>;
  25210. /** @hidden */
  25211. _boundingInfo: Nullable<BoundingInfo>;
  25212. /** @hidden */
  25213. _renderId: number;
  25214. /**
  25215. * Gets or sets the list of subMeshes
  25216. * @see http://doc.babylonjs.com/how_to/multi_materials
  25217. */
  25218. subMeshes: SubMesh[];
  25219. /** @hidden */
  25220. _intersectionsInProgress: AbstractMesh[];
  25221. /** @hidden */
  25222. _unIndexed: boolean;
  25223. /** @hidden */
  25224. _lightSources: Light[];
  25225. /** Gets the list of lights affecting that mesh */
  25226. readonly lightSources: Light[];
  25227. /** @hidden */
  25228. readonly _positions: Nullable<Vector3[]>;
  25229. /** @hidden */
  25230. _waitingData: {
  25231. lods: Nullable<any>;
  25232. actions: Nullable<any>;
  25233. freezeWorldMatrix: Nullable<boolean>;
  25234. };
  25235. /** @hidden */
  25236. _bonesTransformMatrices: Nullable<Float32Array>;
  25237. /**
  25238. * Gets or sets a skeleton to apply skining transformations
  25239. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25240. */
  25241. skeleton: Nullable<Skeleton>;
  25242. /**
  25243. * An event triggered when the mesh is rebuilt.
  25244. */
  25245. onRebuildObservable: Observable<AbstractMesh>;
  25246. /**
  25247. * Creates a new AbstractMesh
  25248. * @param name defines the name of the mesh
  25249. * @param scene defines the hosting scene
  25250. */
  25251. constructor(name: string, scene?: Nullable<Scene>);
  25252. /**
  25253. * Returns the string "AbstractMesh"
  25254. * @returns "AbstractMesh"
  25255. */
  25256. getClassName(): string;
  25257. /**
  25258. * Gets a string representation of the current mesh
  25259. * @param fullDetails defines a boolean indicating if full details must be included
  25260. * @returns a string representation of the current mesh
  25261. */
  25262. toString(fullDetails?: boolean): string;
  25263. /**
  25264. * @hidden
  25265. */
  25266. protected _getEffectiveParent(): Nullable<Node>;
  25267. /** @hidden */
  25268. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25269. /** @hidden */
  25270. _rebuild(): void;
  25271. /** @hidden */
  25272. _resyncLightSources(): void;
  25273. /** @hidden */
  25274. _resyncLighSource(light: Light): void;
  25275. /** @hidden */
  25276. _unBindEffect(): void;
  25277. /** @hidden */
  25278. _removeLightSource(light: Light): void;
  25279. private _markSubMeshesAsDirty;
  25280. /** @hidden */
  25281. _markSubMeshesAsLightDirty(): void;
  25282. /** @hidden */
  25283. _markSubMeshesAsAttributesDirty(): void;
  25284. /** @hidden */
  25285. _markSubMeshesAsMiscDirty(): void;
  25286. /**
  25287. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25288. */
  25289. scaling: Vector3;
  25290. /**
  25291. * Returns true if the mesh is blocked. Implemented by child classes
  25292. */
  25293. readonly isBlocked: boolean;
  25294. /**
  25295. * Returns the mesh itself by default. Implemented by child classes
  25296. * @param camera defines the camera to use to pick the right LOD level
  25297. * @returns the currentAbstractMesh
  25298. */
  25299. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25300. /**
  25301. * Returns 0 by default. Implemented by child classes
  25302. * @returns an integer
  25303. */
  25304. getTotalVertices(): number;
  25305. /**
  25306. * Returns a positive integer : the total number of indices in this mesh geometry.
  25307. * @returns the numner of indices or zero if the mesh has no geometry.
  25308. */
  25309. getTotalIndices(): number;
  25310. /**
  25311. * Returns null by default. Implemented by child classes
  25312. * @returns null
  25313. */
  25314. getIndices(): Nullable<IndicesArray>;
  25315. /**
  25316. * Returns the array of the requested vertex data kind. Implemented by child classes
  25317. * @param kind defines the vertex data kind to use
  25318. * @returns null
  25319. */
  25320. getVerticesData(kind: string): Nullable<FloatArray>;
  25321. /**
  25322. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25323. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25324. * Note that a new underlying VertexBuffer object is created each call.
  25325. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25326. * @param kind defines vertex data kind:
  25327. * * VertexBuffer.PositionKind
  25328. * * VertexBuffer.UVKind
  25329. * * VertexBuffer.UV2Kind
  25330. * * VertexBuffer.UV3Kind
  25331. * * VertexBuffer.UV4Kind
  25332. * * VertexBuffer.UV5Kind
  25333. * * VertexBuffer.UV6Kind
  25334. * * VertexBuffer.ColorKind
  25335. * * VertexBuffer.MatricesIndicesKind
  25336. * * VertexBuffer.MatricesIndicesExtraKind
  25337. * * VertexBuffer.MatricesWeightsKind
  25338. * * VertexBuffer.MatricesWeightsExtraKind
  25339. * @param data defines the data source
  25340. * @param updatable defines if the data must be flagged as updatable (or static)
  25341. * @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
  25342. * @returns the current mesh
  25343. */
  25344. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25345. /**
  25346. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25347. * If the mesh has no geometry, it is simply returned as it is.
  25348. * @param kind defines vertex data kind:
  25349. * * VertexBuffer.PositionKind
  25350. * * VertexBuffer.UVKind
  25351. * * VertexBuffer.UV2Kind
  25352. * * VertexBuffer.UV3Kind
  25353. * * VertexBuffer.UV4Kind
  25354. * * VertexBuffer.UV5Kind
  25355. * * VertexBuffer.UV6Kind
  25356. * * VertexBuffer.ColorKind
  25357. * * VertexBuffer.MatricesIndicesKind
  25358. * * VertexBuffer.MatricesIndicesExtraKind
  25359. * * VertexBuffer.MatricesWeightsKind
  25360. * * VertexBuffer.MatricesWeightsExtraKind
  25361. * @param data defines the data source
  25362. * @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
  25363. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25364. * @returns the current mesh
  25365. */
  25366. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25367. /**
  25368. * Sets the mesh indices,
  25369. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25370. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25371. * @param totalVertices Defines the total number of vertices
  25372. * @returns the current mesh
  25373. */
  25374. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25375. /**
  25376. * Gets a boolean indicating if specific vertex data is present
  25377. * @param kind defines the vertex data kind to use
  25378. * @returns true is data kind is present
  25379. */
  25380. isVerticesDataPresent(kind: string): boolean;
  25381. /**
  25382. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25383. * @returns a BoundingInfo
  25384. */
  25385. getBoundingInfo(): BoundingInfo;
  25386. /**
  25387. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25388. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25389. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25390. * @returns the current mesh
  25391. */
  25392. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25393. /**
  25394. * Overwrite the current bounding info
  25395. * @param boundingInfo defines the new bounding info
  25396. * @returns the current mesh
  25397. */
  25398. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25399. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25400. readonly useBones: boolean;
  25401. /** @hidden */
  25402. _preActivate(): void;
  25403. /** @hidden */
  25404. _preActivateForIntermediateRendering(renderId: number): void;
  25405. /** @hidden */
  25406. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25407. /** @hidden */
  25408. _postActivate(): void;
  25409. /** @hidden */
  25410. _freeze(): void;
  25411. /** @hidden */
  25412. _unFreeze(): void;
  25413. /**
  25414. * Gets the current world matrix
  25415. * @returns a Matrix
  25416. */
  25417. getWorldMatrix(): Matrix;
  25418. /** @hidden */
  25419. _getWorldMatrixDeterminant(): number;
  25420. /**
  25421. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25422. */
  25423. readonly isAnInstance: boolean;
  25424. /**
  25425. * Perform relative position change from the point of view of behind the front of the mesh.
  25426. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25427. * Supports definition of mesh facing forward or backward
  25428. * @param amountRight defines the distance on the right axis
  25429. * @param amountUp defines the distance on the up axis
  25430. * @param amountForward defines the distance on the forward axis
  25431. * @returns the current mesh
  25432. */
  25433. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25434. /**
  25435. * Calculate relative position change from the point of view of behind the front of the mesh.
  25436. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25437. * Supports definition of mesh facing forward or backward
  25438. * @param amountRight defines the distance on the right axis
  25439. * @param amountUp defines the distance on the up axis
  25440. * @param amountForward defines the distance on the forward axis
  25441. * @returns the new displacement vector
  25442. */
  25443. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25444. /**
  25445. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25446. * Supports definition of mesh facing forward or backward
  25447. * @param flipBack defines the flip
  25448. * @param twirlClockwise defines the twirl
  25449. * @param tiltRight defines the tilt
  25450. * @returns the current mesh
  25451. */
  25452. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25453. /**
  25454. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25455. * Supports definition of mesh facing forward or backward.
  25456. * @param flipBack defines the flip
  25457. * @param twirlClockwise defines the twirl
  25458. * @param tiltRight defines the tilt
  25459. * @returns the new rotation vector
  25460. */
  25461. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25462. /**
  25463. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25464. * This means the mesh underlying bounding box and sphere are recomputed.
  25465. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25466. * @returns the current mesh
  25467. */
  25468. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25469. /** @hidden */
  25470. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25471. /** @hidden */
  25472. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25473. /** @hidden */
  25474. _updateBoundingInfo(): AbstractMesh;
  25475. /** @hidden */
  25476. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25477. /** @hidden */
  25478. protected _afterComputeWorldMatrix(): void;
  25479. /** @hidden */
  25480. readonly _effectiveMesh: AbstractMesh;
  25481. /**
  25482. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25483. * A mesh is in the frustum if its bounding box intersects the frustum
  25484. * @param frustumPlanes defines the frustum to test
  25485. * @returns true if the mesh is in the frustum planes
  25486. */
  25487. isInFrustum(frustumPlanes: Plane[]): boolean;
  25488. /**
  25489. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25490. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25491. * @param frustumPlanes defines the frustum to test
  25492. * @returns true if the mesh is completely in the frustum planes
  25493. */
  25494. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25495. /**
  25496. * True if the mesh intersects another mesh or a SolidParticle object
  25497. * @param mesh defines a target mesh or SolidParticle to test
  25498. * @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)
  25499. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25500. * @returns true if there is an intersection
  25501. */
  25502. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25503. /**
  25504. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25505. * @param point defines the point to test
  25506. * @returns true if there is an intersection
  25507. */
  25508. intersectsPoint(point: Vector3): boolean;
  25509. /**
  25510. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25511. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25512. */
  25513. checkCollisions: boolean;
  25514. /**
  25515. * Gets Collider object used to compute collisions (not physics)
  25516. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25517. */
  25518. readonly collider: Nullable<Collider>;
  25519. /**
  25520. * Move the mesh using collision engine
  25521. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25522. * @param displacement defines the requested displacement vector
  25523. * @returns the current mesh
  25524. */
  25525. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25526. private _onCollisionPositionChange;
  25527. /** @hidden */
  25528. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25529. /** @hidden */
  25530. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25531. /** @hidden */
  25532. _checkCollision(collider: Collider): AbstractMesh;
  25533. /** @hidden */
  25534. _generatePointsArray(): boolean;
  25535. /**
  25536. * Checks if the passed Ray intersects with the mesh
  25537. * @param ray defines the ray to use
  25538. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25539. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25540. * @returns the picking info
  25541. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25542. */
  25543. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25544. /**
  25545. * Clones the current mesh
  25546. * @param name defines the mesh name
  25547. * @param newParent defines the new mesh parent
  25548. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25549. * @returns the new mesh
  25550. */
  25551. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25552. /**
  25553. * Disposes all the submeshes of the current meshnp
  25554. * @returns the current mesh
  25555. */
  25556. releaseSubMeshes(): AbstractMesh;
  25557. /**
  25558. * Releases resources associated with this abstract mesh.
  25559. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25560. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25561. */
  25562. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25563. /**
  25564. * Adds the passed mesh as a child to the current mesh
  25565. * @param mesh defines the child mesh
  25566. * @returns the current mesh
  25567. */
  25568. addChild(mesh: AbstractMesh): AbstractMesh;
  25569. /**
  25570. * Removes the passed mesh from the current mesh children list
  25571. * @param mesh defines the child mesh
  25572. * @returns the current mesh
  25573. */
  25574. removeChild(mesh: AbstractMesh): AbstractMesh;
  25575. /** @hidden */
  25576. private _initFacetData;
  25577. /**
  25578. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25579. * This method can be called within the render loop.
  25580. * 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
  25581. * @returns the current mesh
  25582. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25583. */
  25584. updateFacetData(): AbstractMesh;
  25585. /**
  25586. * Returns the facetLocalNormals array.
  25587. * The normals are expressed in the mesh local spac
  25588. * @returns an array of Vector3
  25589. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25590. */
  25591. getFacetLocalNormals(): Vector3[];
  25592. /**
  25593. * Returns the facetLocalPositions array.
  25594. * The facet positions are expressed in the mesh local space
  25595. * @returns an array of Vector3
  25596. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25597. */
  25598. getFacetLocalPositions(): Vector3[];
  25599. /**
  25600. * Returns the facetLocalPartioning array
  25601. * @returns an array of array of numbers
  25602. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25603. */
  25604. getFacetLocalPartitioning(): number[][];
  25605. /**
  25606. * Returns the i-th facet position in the world system.
  25607. * This method allocates a new Vector3 per call
  25608. * @param i defines the facet index
  25609. * @returns a new Vector3
  25610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25611. */
  25612. getFacetPosition(i: number): Vector3;
  25613. /**
  25614. * Sets the reference Vector3 with the i-th facet position in the world system
  25615. * @param i defines the facet index
  25616. * @param ref defines the target vector
  25617. * @returns the current mesh
  25618. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25619. */
  25620. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25621. /**
  25622. * Returns the i-th facet normal in the world system.
  25623. * This method allocates a new Vector3 per call
  25624. * @param i defines the facet index
  25625. * @returns a new Vector3
  25626. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25627. */
  25628. getFacetNormal(i: number): Vector3;
  25629. /**
  25630. * Sets the reference Vector3 with the i-th facet normal in the world system
  25631. * @param i defines the facet index
  25632. * @param ref defines the target vector
  25633. * @returns the current mesh
  25634. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25635. */
  25636. getFacetNormalToRef(i: number, ref: Vector3): this;
  25637. /**
  25638. * 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)
  25639. * @param x defines x coordinate
  25640. * @param y defines y coordinate
  25641. * @param z defines z coordinate
  25642. * @returns the array of facet indexes
  25643. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25644. */
  25645. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25646. /**
  25647. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25648. * @param projected sets as the (x,y,z) world projection on the facet
  25649. * @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
  25650. * @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
  25651. * @param x defines x coordinate
  25652. * @param y defines y coordinate
  25653. * @param z defines z coordinate
  25654. * @returns the face index if found (or null instead)
  25655. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25656. */
  25657. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25658. /**
  25659. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25660. * @param projected sets as the (x,y,z) local projection on the facet
  25661. * @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
  25662. * @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
  25663. * @param x defines x coordinate
  25664. * @param y defines y coordinate
  25665. * @param z defines z coordinate
  25666. * @returns the face index if found (or null instead)
  25667. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25668. */
  25669. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25670. /**
  25671. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25672. * @returns the parameters
  25673. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25674. */
  25675. getFacetDataParameters(): any;
  25676. /**
  25677. * Disables the feature FacetData and frees the related memory
  25678. * @returns the current mesh
  25679. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25680. */
  25681. disableFacetData(): AbstractMesh;
  25682. /**
  25683. * Updates the AbstractMesh indices array
  25684. * @param indices defines the data source
  25685. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25686. * @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)
  25687. * @returns the current mesh
  25688. */
  25689. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25690. /**
  25691. * Creates new normals data for the mesh
  25692. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25693. * @returns the current mesh
  25694. */
  25695. createNormals(updatable: boolean): AbstractMesh;
  25696. /**
  25697. * Align the mesh with a normal
  25698. * @param normal defines the normal to use
  25699. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25700. * @returns the current mesh
  25701. */
  25702. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25703. /** @hidden */
  25704. _checkOcclusionQuery(): boolean;
  25705. /**
  25706. * Disables the mesh edge rendering mode
  25707. * @returns the currentAbstractMesh
  25708. */
  25709. disableEdgesRendering(): AbstractMesh;
  25710. /**
  25711. * Enables the edge rendering mode on the mesh.
  25712. * This mode makes the mesh edges visible
  25713. * @param epsilon defines the maximal distance between two angles to detect a face
  25714. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25715. * @returns the currentAbstractMesh
  25716. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25717. */
  25718. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25719. }
  25720. }
  25721. declare module "babylonjs/Actions/actionEvent" {
  25722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25723. import { Nullable } from "babylonjs/types";
  25724. import { Sprite } from "babylonjs/Sprites/sprite";
  25725. import { Scene } from "babylonjs/scene";
  25726. import { Vector2 } from "babylonjs/Maths/math";
  25727. /**
  25728. * Interface used to define ActionEvent
  25729. */
  25730. export interface IActionEvent {
  25731. /** The mesh or sprite that triggered the action */
  25732. source: any;
  25733. /** The X mouse cursor position at the time of the event */
  25734. pointerX: number;
  25735. /** The Y mouse cursor position at the time of the event */
  25736. pointerY: number;
  25737. /** The mesh that is currently pointed at (can be null) */
  25738. meshUnderPointer: Nullable<AbstractMesh>;
  25739. /** the original (browser) event that triggered the ActionEvent */
  25740. sourceEvent?: any;
  25741. /** additional data for the event */
  25742. additionalData?: any;
  25743. }
  25744. /**
  25745. * ActionEvent is the event being sent when an action is triggered.
  25746. */
  25747. export class ActionEvent implements IActionEvent {
  25748. /** The mesh or sprite that triggered the action */
  25749. source: any;
  25750. /** The X mouse cursor position at the time of the event */
  25751. pointerX: number;
  25752. /** The Y mouse cursor position at the time of the event */
  25753. pointerY: number;
  25754. /** The mesh that is currently pointed at (can be null) */
  25755. meshUnderPointer: Nullable<AbstractMesh>;
  25756. /** the original (browser) event that triggered the ActionEvent */
  25757. sourceEvent?: any;
  25758. /** additional data for the event */
  25759. additionalData?: any;
  25760. /**
  25761. * Creates a new ActionEvent
  25762. * @param source The mesh or sprite that triggered the action
  25763. * @param pointerX The X mouse cursor position at the time of the event
  25764. * @param pointerY The Y mouse cursor position at the time of the event
  25765. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25766. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25767. * @param additionalData additional data for the event
  25768. */
  25769. constructor(
  25770. /** The mesh or sprite that triggered the action */
  25771. source: any,
  25772. /** The X mouse cursor position at the time of the event */
  25773. pointerX: number,
  25774. /** The Y mouse cursor position at the time of the event */
  25775. pointerY: number,
  25776. /** The mesh that is currently pointed at (can be null) */
  25777. meshUnderPointer: Nullable<AbstractMesh>,
  25778. /** the original (browser) event that triggered the ActionEvent */
  25779. sourceEvent?: any,
  25780. /** additional data for the event */
  25781. additionalData?: any);
  25782. /**
  25783. * Helper function to auto-create an ActionEvent from a source mesh.
  25784. * @param source The source mesh that triggered the event
  25785. * @param evt The original (browser) event
  25786. * @param additionalData additional data for the event
  25787. * @returns the new ActionEvent
  25788. */
  25789. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25790. /**
  25791. * Helper function to auto-create an ActionEvent from a source sprite
  25792. * @param source The source sprite that triggered the event
  25793. * @param scene Scene associated with the sprite
  25794. * @param evt The original (browser) event
  25795. * @param additionalData additional data for the event
  25796. * @returns the new ActionEvent
  25797. */
  25798. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25799. /**
  25800. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25801. * @param scene the scene where the event occurred
  25802. * @param evt The original (browser) event
  25803. * @returns the new ActionEvent
  25804. */
  25805. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25806. /**
  25807. * Helper function to auto-create an ActionEvent from a primitive
  25808. * @param prim defines the target primitive
  25809. * @param pointerPos defines the pointer position
  25810. * @param evt The original (browser) event
  25811. * @param additionalData additional data for the event
  25812. * @returns the new ActionEvent
  25813. */
  25814. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25815. }
  25816. }
  25817. declare module "babylonjs/Actions/abstractActionManager" {
  25818. import { IDisposable } from "babylonjs/scene";
  25819. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25820. import { IAction } from "babylonjs/Actions/action";
  25821. import { Nullable } from "babylonjs/types";
  25822. /**
  25823. * Abstract class used to decouple action Manager from scene and meshes.
  25824. * Do not instantiate.
  25825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25826. */
  25827. export abstract class AbstractActionManager implements IDisposable {
  25828. /** Gets the list of active triggers */
  25829. static Triggers: {
  25830. [key: string]: number;
  25831. };
  25832. /** Gets the cursor to use when hovering items */
  25833. hoverCursor: string;
  25834. /** Gets the list of actions */
  25835. actions: IAction[];
  25836. /**
  25837. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25838. */
  25839. isRecursive: boolean;
  25840. /**
  25841. * Releases all associated resources
  25842. */
  25843. abstract dispose(): void;
  25844. /**
  25845. * Does this action manager has pointer triggers
  25846. */
  25847. abstract readonly hasPointerTriggers: boolean;
  25848. /**
  25849. * Does this action manager has pick triggers
  25850. */
  25851. abstract readonly hasPickTriggers: boolean;
  25852. /**
  25853. * Process a specific trigger
  25854. * @param trigger defines the trigger to process
  25855. * @param evt defines the event details to be processed
  25856. */
  25857. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25858. /**
  25859. * Does this action manager handles actions of any of the given triggers
  25860. * @param triggers defines the triggers to be tested
  25861. * @return a boolean indicating whether one (or more) of the triggers is handled
  25862. */
  25863. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25864. /**
  25865. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25866. * speed.
  25867. * @param triggerA defines the trigger to be tested
  25868. * @param triggerB defines the trigger to be tested
  25869. * @return a boolean indicating whether one (or more) of the triggers is handled
  25870. */
  25871. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25872. /**
  25873. * Does this action manager handles actions of a given trigger
  25874. * @param trigger defines the trigger to be tested
  25875. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25876. * @return whether the trigger is handled
  25877. */
  25878. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25879. /**
  25880. * Serialize this manager to a JSON object
  25881. * @param name defines the property name to store this manager
  25882. * @returns a JSON representation of this manager
  25883. */
  25884. abstract serialize(name: string): any;
  25885. /**
  25886. * Registers an action to this action manager
  25887. * @param action defines the action to be registered
  25888. * @return the action amended (prepared) after registration
  25889. */
  25890. abstract registerAction(action: IAction): Nullable<IAction>;
  25891. /**
  25892. * Unregisters an action to this action manager
  25893. * @param action defines the action to be unregistered
  25894. * @return a boolean indicating whether the action has been unregistered
  25895. */
  25896. abstract unregisterAction(action: IAction): Boolean;
  25897. /**
  25898. * Does exist one action manager with at least one trigger
  25899. **/
  25900. static readonly HasTriggers: boolean;
  25901. /**
  25902. * Does exist one action manager with at least one pick trigger
  25903. **/
  25904. static readonly HasPickTriggers: boolean;
  25905. /**
  25906. * Does exist one action manager that handles actions of a given trigger
  25907. * @param trigger defines the trigger to be tested
  25908. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25909. **/
  25910. static HasSpecificTrigger(trigger: number): boolean;
  25911. }
  25912. }
  25913. declare module "babylonjs/node" {
  25914. import { Scene } from "babylonjs/scene";
  25915. import { Nullable } from "babylonjs/types";
  25916. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  25917. import { Engine } from "babylonjs/Engines/engine";
  25918. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25919. import { Observable } from "babylonjs/Misc/observable";
  25920. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25921. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25922. import { Animatable } from "babylonjs/Animations/animatable";
  25923. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25924. import { Animation } from "babylonjs/Animations/animation";
  25925. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25927. /**
  25928. * Defines how a node can be built from a string name.
  25929. */
  25930. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25931. /**
  25932. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25933. */
  25934. export class Node implements IBehaviorAware<Node> {
  25935. /** @hidden */
  25936. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25937. private static _NodeConstructors;
  25938. /**
  25939. * Add a new node constructor
  25940. * @param type defines the type name of the node to construct
  25941. * @param constructorFunc defines the constructor function
  25942. */
  25943. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25944. /**
  25945. * Returns a node constructor based on type name
  25946. * @param type defines the type name
  25947. * @param name defines the new node name
  25948. * @param scene defines the hosting scene
  25949. * @param options defines optional options to transmit to constructors
  25950. * @returns the new constructor or null
  25951. */
  25952. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25953. /**
  25954. * Gets or sets the name of the node
  25955. */
  25956. name: string;
  25957. /**
  25958. * Gets or sets the id of the node
  25959. */
  25960. id: string;
  25961. /**
  25962. * Gets or sets the unique id of the node
  25963. */
  25964. uniqueId: number;
  25965. /**
  25966. * Gets or sets a string used to store user defined state for the node
  25967. */
  25968. state: string;
  25969. /**
  25970. * Gets or sets an object used to store user defined information for the node
  25971. */
  25972. metadata: any;
  25973. /**
  25974. * For internal use only. Please do not use.
  25975. */
  25976. reservedDataStore: any;
  25977. /**
  25978. * List of inspectable custom properties (used by the Inspector)
  25979. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25980. */
  25981. inspectableCustomProperties: IInspectable[];
  25982. /**
  25983. * Gets or sets a boolean used to define if the node must be serialized
  25984. */
  25985. doNotSerialize: boolean;
  25986. /** @hidden */
  25987. _isDisposed: boolean;
  25988. /**
  25989. * Gets a list of Animations associated with the node
  25990. */
  25991. animations: import("babylonjs/Animations/animation").Animation[];
  25992. protected _ranges: {
  25993. [name: string]: Nullable<AnimationRange>;
  25994. };
  25995. /**
  25996. * Callback raised when the node is ready to be used
  25997. */
  25998. onReady: Nullable<(node: Node) => void>;
  25999. private _isEnabled;
  26000. private _isParentEnabled;
  26001. private _isReady;
  26002. /** @hidden */
  26003. _currentRenderId: number;
  26004. private _parentUpdateId;
  26005. /** @hidden */
  26006. _childUpdateId: number;
  26007. /** @hidden */
  26008. _waitingParentId: Nullable<string>;
  26009. /** @hidden */
  26010. _scene: Scene;
  26011. /** @hidden */
  26012. _cache: any;
  26013. private _parentNode;
  26014. private _children;
  26015. /** @hidden */
  26016. _worldMatrix: Matrix;
  26017. /** @hidden */
  26018. _worldMatrixDeterminant: number;
  26019. /** @hidden */
  26020. _worldMatrixDeterminantIsDirty: boolean;
  26021. /** @hidden */
  26022. private _sceneRootNodesIndex;
  26023. /**
  26024. * Gets a boolean indicating if the node has been disposed
  26025. * @returns true if the node was disposed
  26026. */
  26027. isDisposed(): boolean;
  26028. /**
  26029. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26030. * @see https://doc.babylonjs.com/how_to/parenting
  26031. */
  26032. parent: Nullable<Node>;
  26033. private addToSceneRootNodes;
  26034. private removeFromSceneRootNodes;
  26035. private _animationPropertiesOverride;
  26036. /**
  26037. * Gets or sets the animation properties override
  26038. */
  26039. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26040. /**
  26041. * Gets a string idenfifying the name of the class
  26042. * @returns "Node" string
  26043. */
  26044. getClassName(): string;
  26045. /** @hidden */
  26046. readonly _isNode: boolean;
  26047. /**
  26048. * An event triggered when the mesh is disposed
  26049. */
  26050. onDisposeObservable: Observable<Node>;
  26051. private _onDisposeObserver;
  26052. /**
  26053. * Sets a callback that will be raised when the node will be disposed
  26054. */
  26055. onDispose: () => void;
  26056. /**
  26057. * Creates a new Node
  26058. * @param name the name and id to be given to this node
  26059. * @param scene the scene this node will be added to
  26060. * @param addToRootNodes the node will be added to scene.rootNodes
  26061. */
  26062. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26063. /**
  26064. * Gets the scene of the node
  26065. * @returns a scene
  26066. */
  26067. getScene(): Scene;
  26068. /**
  26069. * Gets the engine of the node
  26070. * @returns a Engine
  26071. */
  26072. getEngine(): Engine;
  26073. private _behaviors;
  26074. /**
  26075. * Attach a behavior to the node
  26076. * @see http://doc.babylonjs.com/features/behaviour
  26077. * @param behavior defines the behavior to attach
  26078. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26079. * @returns the current Node
  26080. */
  26081. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26082. /**
  26083. * Remove an attached behavior
  26084. * @see http://doc.babylonjs.com/features/behaviour
  26085. * @param behavior defines the behavior to attach
  26086. * @returns the current Node
  26087. */
  26088. removeBehavior(behavior: Behavior<Node>): Node;
  26089. /**
  26090. * Gets the list of attached behaviors
  26091. * @see http://doc.babylonjs.com/features/behaviour
  26092. */
  26093. readonly behaviors: Behavior<Node>[];
  26094. /**
  26095. * Gets an attached behavior by name
  26096. * @param name defines the name of the behavior to look for
  26097. * @see http://doc.babylonjs.com/features/behaviour
  26098. * @returns null if behavior was not found else the requested behavior
  26099. */
  26100. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26101. /**
  26102. * Returns the latest update of the World matrix
  26103. * @returns a Matrix
  26104. */
  26105. getWorldMatrix(): Matrix;
  26106. /** @hidden */
  26107. _getWorldMatrixDeterminant(): number;
  26108. /**
  26109. * Returns directly the latest state of the mesh World matrix.
  26110. * A Matrix is returned.
  26111. */
  26112. readonly worldMatrixFromCache: Matrix;
  26113. /** @hidden */
  26114. _initCache(): void;
  26115. /** @hidden */
  26116. updateCache(force?: boolean): void;
  26117. /** @hidden */
  26118. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26119. /** @hidden */
  26120. _updateCache(ignoreParentClass?: boolean): void;
  26121. /** @hidden */
  26122. _isSynchronized(): boolean;
  26123. /** @hidden */
  26124. _markSyncedWithParent(): void;
  26125. /** @hidden */
  26126. isSynchronizedWithParent(): boolean;
  26127. /** @hidden */
  26128. isSynchronized(): boolean;
  26129. /**
  26130. * Is this node ready to be used/rendered
  26131. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26132. * @return true if the node is ready
  26133. */
  26134. isReady(completeCheck?: boolean): boolean;
  26135. /**
  26136. * Is this node enabled?
  26137. * 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
  26138. * @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
  26139. * @return whether this node (and its parent) is enabled
  26140. */
  26141. isEnabled(checkAncestors?: boolean): boolean;
  26142. /** @hidden */
  26143. protected _syncParentEnabledState(): void;
  26144. /**
  26145. * Set the enabled state of this node
  26146. * @param value defines the new enabled state
  26147. */
  26148. setEnabled(value: boolean): void;
  26149. /**
  26150. * Is this node a descendant of the given node?
  26151. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26152. * @param ancestor defines the parent node to inspect
  26153. * @returns a boolean indicating if this node is a descendant of the given node
  26154. */
  26155. isDescendantOf(ancestor: Node): boolean;
  26156. /** @hidden */
  26157. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26158. /**
  26159. * Will return all nodes that have this node as ascendant
  26160. * @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
  26161. * @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
  26162. * @return all children nodes of all types
  26163. */
  26164. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26165. /**
  26166. * Get all child-meshes of this node
  26167. * @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)
  26168. * @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
  26169. * @returns an array of AbstractMesh
  26170. */
  26171. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26172. /**
  26173. * Get all direct children of this node
  26174. * @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
  26175. * @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)
  26176. * @returns an array of Node
  26177. */
  26178. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26179. /** @hidden */
  26180. _setReady(state: boolean): void;
  26181. /**
  26182. * Get an animation by name
  26183. * @param name defines the name of the animation to look for
  26184. * @returns null if not found else the requested animation
  26185. */
  26186. getAnimationByName(name: string): Nullable<Animation>;
  26187. /**
  26188. * Creates an animation range for this node
  26189. * @param name defines the name of the range
  26190. * @param from defines the starting key
  26191. * @param to defines the end key
  26192. */
  26193. createAnimationRange(name: string, from: number, to: number): void;
  26194. /**
  26195. * Delete a specific animation range
  26196. * @param name defines the name of the range to delete
  26197. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26198. */
  26199. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26200. /**
  26201. * Get an animation range by name
  26202. * @param name defines the name of the animation range to look for
  26203. * @returns null if not found else the requested animation range
  26204. */
  26205. getAnimationRange(name: string): Nullable<AnimationRange>;
  26206. /**
  26207. * Gets the list of all animation ranges defined on this node
  26208. * @returns an array
  26209. */
  26210. getAnimationRanges(): Nullable<AnimationRange>[];
  26211. /**
  26212. * Will start the animation sequence
  26213. * @param name defines the range frames for animation sequence
  26214. * @param loop defines if the animation should loop (false by default)
  26215. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26216. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26217. * @returns the object created for this animation. If range does not exist, it will return null
  26218. */
  26219. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26220. /**
  26221. * Serialize animation ranges into a JSON compatible object
  26222. * @returns serialization object
  26223. */
  26224. serializeAnimationRanges(): any;
  26225. /**
  26226. * Computes the world matrix of the node
  26227. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26228. * @returns the world matrix
  26229. */
  26230. computeWorldMatrix(force?: boolean): Matrix;
  26231. /**
  26232. * Releases resources associated with this node.
  26233. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26234. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26235. */
  26236. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26237. /**
  26238. * Parse animation range data from a serialization object and store them into a given node
  26239. * @param node defines where to store the animation ranges
  26240. * @param parsedNode defines the serialization object to read data from
  26241. * @param scene defines the hosting scene
  26242. */
  26243. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26244. /**
  26245. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26246. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26247. * @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
  26248. * @returns the new bounding vectors
  26249. */
  26250. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26251. min: Vector3;
  26252. max: Vector3;
  26253. };
  26254. }
  26255. }
  26256. declare module "babylonjs/Animations/animation" {
  26257. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26258. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26259. import { Nullable } from "babylonjs/types";
  26260. import { Scene } from "babylonjs/scene";
  26261. import { IAnimatable } from "babylonjs/Misc/tools";
  26262. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26263. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26264. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26265. import { Node } from "babylonjs/node";
  26266. import { Animatable } from "babylonjs/Animations/animatable";
  26267. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26268. /**
  26269. * @hidden
  26270. */
  26271. export class _IAnimationState {
  26272. key: number;
  26273. repeatCount: number;
  26274. workValue?: any;
  26275. loopMode?: number;
  26276. offsetValue?: any;
  26277. highLimitValue?: any;
  26278. }
  26279. /**
  26280. * Class used to store any kind of animation
  26281. */
  26282. export class Animation {
  26283. /**Name of the animation */
  26284. name: string;
  26285. /**Property to animate */
  26286. targetProperty: string;
  26287. /**The frames per second of the animation */
  26288. framePerSecond: number;
  26289. /**The data type of the animation */
  26290. dataType: number;
  26291. /**The loop mode of the animation */
  26292. loopMode?: number | undefined;
  26293. /**Specifies if blending should be enabled */
  26294. enableBlending?: boolean | undefined;
  26295. /**
  26296. * Use matrix interpolation instead of using direct key value when animating matrices
  26297. */
  26298. static AllowMatricesInterpolation: boolean;
  26299. /**
  26300. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26301. */
  26302. static AllowMatrixDecomposeForInterpolation: boolean;
  26303. /**
  26304. * Stores the key frames of the animation
  26305. */
  26306. private _keys;
  26307. /**
  26308. * Stores the easing function of the animation
  26309. */
  26310. private _easingFunction;
  26311. /**
  26312. * @hidden Internal use only
  26313. */
  26314. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26315. /**
  26316. * The set of event that will be linked to this animation
  26317. */
  26318. private _events;
  26319. /**
  26320. * Stores an array of target property paths
  26321. */
  26322. targetPropertyPath: string[];
  26323. /**
  26324. * Stores the blending speed of the animation
  26325. */
  26326. blendingSpeed: number;
  26327. /**
  26328. * Stores the animation ranges for the animation
  26329. */
  26330. private _ranges;
  26331. /**
  26332. * @hidden Internal use
  26333. */
  26334. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26335. /**
  26336. * Sets up an animation
  26337. * @param property The property to animate
  26338. * @param animationType The animation type to apply
  26339. * @param framePerSecond The frames per second of the animation
  26340. * @param easingFunction The easing function used in the animation
  26341. * @returns The created animation
  26342. */
  26343. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26344. /**
  26345. * Create and start an animation on a node
  26346. * @param name defines the name of the global animation that will be run on all nodes
  26347. * @param node defines the root node where the animation will take place
  26348. * @param targetProperty defines property to animate
  26349. * @param framePerSecond defines the number of frame per second yo use
  26350. * @param totalFrame defines the number of frames in total
  26351. * @param from defines the initial value
  26352. * @param to defines the final value
  26353. * @param loopMode defines which loop mode you want to use (off by default)
  26354. * @param easingFunction defines the easing function to use (linear by default)
  26355. * @param onAnimationEnd defines the callback to call when animation end
  26356. * @returns the animatable created for this animation
  26357. */
  26358. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26359. /**
  26360. * Create and start an animation on a node and its descendants
  26361. * @param name defines the name of the global animation that will be run on all nodes
  26362. * @param node defines the root node where the animation will take place
  26363. * @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
  26364. * @param targetProperty defines property to animate
  26365. * @param framePerSecond defines the number of frame per second to use
  26366. * @param totalFrame defines the number of frames in total
  26367. * @param from defines the initial value
  26368. * @param to defines the final value
  26369. * @param loopMode defines which loop mode you want to use (off by default)
  26370. * @param easingFunction defines the easing function to use (linear by default)
  26371. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26372. * @returns the list of animatables created for all nodes
  26373. * @example https://www.babylonjs-playground.com/#MH0VLI
  26374. */
  26375. 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[]>;
  26376. /**
  26377. * Creates a new animation, merges it with the existing animations and starts it
  26378. * @param name Name of the animation
  26379. * @param node Node which contains the scene that begins the animations
  26380. * @param targetProperty Specifies which property to animate
  26381. * @param framePerSecond The frames per second of the animation
  26382. * @param totalFrame The total number of frames
  26383. * @param from The frame at the beginning of the animation
  26384. * @param to The frame at the end of the animation
  26385. * @param loopMode Specifies the loop mode of the animation
  26386. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26387. * @param onAnimationEnd Callback to run once the animation is complete
  26388. * @returns Nullable animation
  26389. */
  26390. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26391. /**
  26392. * Transition property of an host to the target Value
  26393. * @param property The property to transition
  26394. * @param targetValue The target Value of the property
  26395. * @param host The object where the property to animate belongs
  26396. * @param scene Scene used to run the animation
  26397. * @param frameRate Framerate (in frame/s) to use
  26398. * @param transition The transition type we want to use
  26399. * @param duration The duration of the animation, in milliseconds
  26400. * @param onAnimationEnd Callback trigger at the end of the animation
  26401. * @returns Nullable animation
  26402. */
  26403. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26404. /**
  26405. * Return the array of runtime animations currently using this animation
  26406. */
  26407. readonly runtimeAnimations: RuntimeAnimation[];
  26408. /**
  26409. * Specifies if any of the runtime animations are currently running
  26410. */
  26411. readonly hasRunningRuntimeAnimations: boolean;
  26412. /**
  26413. * Initializes the animation
  26414. * @param name Name of the animation
  26415. * @param targetProperty Property to animate
  26416. * @param framePerSecond The frames per second of the animation
  26417. * @param dataType The data type of the animation
  26418. * @param loopMode The loop mode of the animation
  26419. * @param enableBlending Specifies if blending should be enabled
  26420. */
  26421. constructor(
  26422. /**Name of the animation */
  26423. name: string,
  26424. /**Property to animate */
  26425. targetProperty: string,
  26426. /**The frames per second of the animation */
  26427. framePerSecond: number,
  26428. /**The data type of the animation */
  26429. dataType: number,
  26430. /**The loop mode of the animation */
  26431. loopMode?: number | undefined,
  26432. /**Specifies if blending should be enabled */
  26433. enableBlending?: boolean | undefined);
  26434. /**
  26435. * Converts the animation to a string
  26436. * @param fullDetails support for multiple levels of logging within scene loading
  26437. * @returns String form of the animation
  26438. */
  26439. toString(fullDetails?: boolean): string;
  26440. /**
  26441. * Add an event to this animation
  26442. * @param event Event to add
  26443. */
  26444. addEvent(event: AnimationEvent): void;
  26445. /**
  26446. * Remove all events found at the given frame
  26447. * @param frame The frame to remove events from
  26448. */
  26449. removeEvents(frame: number): void;
  26450. /**
  26451. * Retrieves all the events from the animation
  26452. * @returns Events from the animation
  26453. */
  26454. getEvents(): AnimationEvent[];
  26455. /**
  26456. * Creates an animation range
  26457. * @param name Name of the animation range
  26458. * @param from Starting frame of the animation range
  26459. * @param to Ending frame of the animation
  26460. */
  26461. createRange(name: string, from: number, to: number): void;
  26462. /**
  26463. * Deletes an animation range by name
  26464. * @param name Name of the animation range to delete
  26465. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26466. */
  26467. deleteRange(name: string, deleteFrames?: boolean): void;
  26468. /**
  26469. * Gets the animation range by name, or null if not defined
  26470. * @param name Name of the animation range
  26471. * @returns Nullable animation range
  26472. */
  26473. getRange(name: string): Nullable<AnimationRange>;
  26474. /**
  26475. * Gets the key frames from the animation
  26476. * @returns The key frames of the animation
  26477. */
  26478. getKeys(): Array<IAnimationKey>;
  26479. /**
  26480. * Gets the highest frame rate of the animation
  26481. * @returns Highest frame rate of the animation
  26482. */
  26483. getHighestFrame(): number;
  26484. /**
  26485. * Gets the easing function of the animation
  26486. * @returns Easing function of the animation
  26487. */
  26488. getEasingFunction(): IEasingFunction;
  26489. /**
  26490. * Sets the easing function of the animation
  26491. * @param easingFunction A custom mathematical formula for animation
  26492. */
  26493. setEasingFunction(easingFunction: EasingFunction): void;
  26494. /**
  26495. * Interpolates a scalar linearly
  26496. * @param startValue Start value of the animation curve
  26497. * @param endValue End value of the animation curve
  26498. * @param gradient Scalar amount to interpolate
  26499. * @returns Interpolated scalar value
  26500. */
  26501. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26502. /**
  26503. * Interpolates a scalar cubically
  26504. * @param startValue Start value of the animation curve
  26505. * @param outTangent End tangent of the animation
  26506. * @param endValue End value of the animation curve
  26507. * @param inTangent Start tangent of the animation curve
  26508. * @param gradient Scalar amount to interpolate
  26509. * @returns Interpolated scalar value
  26510. */
  26511. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26512. /**
  26513. * Interpolates a quaternion using a spherical linear interpolation
  26514. * @param startValue Start value of the animation curve
  26515. * @param endValue End value of the animation curve
  26516. * @param gradient Scalar amount to interpolate
  26517. * @returns Interpolated quaternion value
  26518. */
  26519. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26520. /**
  26521. * Interpolates a quaternion cubically
  26522. * @param startValue Start value of the animation curve
  26523. * @param outTangent End tangent of the animation curve
  26524. * @param endValue End value of the animation curve
  26525. * @param inTangent Start tangent of the animation curve
  26526. * @param gradient Scalar amount to interpolate
  26527. * @returns Interpolated quaternion value
  26528. */
  26529. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26530. /**
  26531. * Interpolates a Vector3 linearl
  26532. * @param startValue Start value of the animation curve
  26533. * @param endValue End value of the animation curve
  26534. * @param gradient Scalar amount to interpolate
  26535. * @returns Interpolated scalar value
  26536. */
  26537. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26538. /**
  26539. * Interpolates a Vector3 cubically
  26540. * @param startValue Start value of the animation curve
  26541. * @param outTangent End tangent of the animation
  26542. * @param endValue End value of the animation curve
  26543. * @param inTangent Start tangent of the animation curve
  26544. * @param gradient Scalar amount to interpolate
  26545. * @returns InterpolatedVector3 value
  26546. */
  26547. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26548. /**
  26549. * Interpolates a Vector2 linearly
  26550. * @param startValue Start value of the animation curve
  26551. * @param endValue End value of the animation curve
  26552. * @param gradient Scalar amount to interpolate
  26553. * @returns Interpolated Vector2 value
  26554. */
  26555. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26556. /**
  26557. * Interpolates a Vector2 cubically
  26558. * @param startValue Start value of the animation curve
  26559. * @param outTangent End tangent of the animation
  26560. * @param endValue End value of the animation curve
  26561. * @param inTangent Start tangent of the animation curve
  26562. * @param gradient Scalar amount to interpolate
  26563. * @returns Interpolated Vector2 value
  26564. */
  26565. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26566. /**
  26567. * Interpolates a size linearly
  26568. * @param startValue Start value of the animation curve
  26569. * @param endValue End value of the animation curve
  26570. * @param gradient Scalar amount to interpolate
  26571. * @returns Interpolated Size value
  26572. */
  26573. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26574. /**
  26575. * Interpolates a Color3 linearly
  26576. * @param startValue Start value of the animation curve
  26577. * @param endValue End value of the animation curve
  26578. * @param gradient Scalar amount to interpolate
  26579. * @returns Interpolated Color3 value
  26580. */
  26581. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26582. /**
  26583. * @hidden Internal use only
  26584. */
  26585. _getKeyValue(value: any): any;
  26586. /**
  26587. * @hidden Internal use only
  26588. */
  26589. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26590. /**
  26591. * Defines the function to use to interpolate matrices
  26592. * @param startValue defines the start matrix
  26593. * @param endValue defines the end matrix
  26594. * @param gradient defines the gradient between both matrices
  26595. * @param result defines an optional target matrix where to store the interpolation
  26596. * @returns the interpolated matrix
  26597. */
  26598. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26599. /**
  26600. * Makes a copy of the animation
  26601. * @returns Cloned animation
  26602. */
  26603. clone(): Animation;
  26604. /**
  26605. * Sets the key frames of the animation
  26606. * @param values The animation key frames to set
  26607. */
  26608. setKeys(values: Array<IAnimationKey>): void;
  26609. /**
  26610. * Serializes the animation to an object
  26611. * @returns Serialized object
  26612. */
  26613. serialize(): any;
  26614. /**
  26615. * Float animation type
  26616. */
  26617. private static _ANIMATIONTYPE_FLOAT;
  26618. /**
  26619. * Vector3 animation type
  26620. */
  26621. private static _ANIMATIONTYPE_VECTOR3;
  26622. /**
  26623. * Quaternion animation type
  26624. */
  26625. private static _ANIMATIONTYPE_QUATERNION;
  26626. /**
  26627. * Matrix animation type
  26628. */
  26629. private static _ANIMATIONTYPE_MATRIX;
  26630. /**
  26631. * Color3 animation type
  26632. */
  26633. private static _ANIMATIONTYPE_COLOR3;
  26634. /**
  26635. * Vector2 animation type
  26636. */
  26637. private static _ANIMATIONTYPE_VECTOR2;
  26638. /**
  26639. * Size animation type
  26640. */
  26641. private static _ANIMATIONTYPE_SIZE;
  26642. /**
  26643. * Relative Loop Mode
  26644. */
  26645. private static _ANIMATIONLOOPMODE_RELATIVE;
  26646. /**
  26647. * Cycle Loop Mode
  26648. */
  26649. private static _ANIMATIONLOOPMODE_CYCLE;
  26650. /**
  26651. * Constant Loop Mode
  26652. */
  26653. private static _ANIMATIONLOOPMODE_CONSTANT;
  26654. /**
  26655. * Get the float animation type
  26656. */
  26657. static readonly ANIMATIONTYPE_FLOAT: number;
  26658. /**
  26659. * Get the Vector3 animation type
  26660. */
  26661. static readonly ANIMATIONTYPE_VECTOR3: number;
  26662. /**
  26663. * Get the Vector2 animation type
  26664. */
  26665. static readonly ANIMATIONTYPE_VECTOR2: number;
  26666. /**
  26667. * Get the Size animation type
  26668. */
  26669. static readonly ANIMATIONTYPE_SIZE: number;
  26670. /**
  26671. * Get the Quaternion animation type
  26672. */
  26673. static readonly ANIMATIONTYPE_QUATERNION: number;
  26674. /**
  26675. * Get the Matrix animation type
  26676. */
  26677. static readonly ANIMATIONTYPE_MATRIX: number;
  26678. /**
  26679. * Get the Color3 animation type
  26680. */
  26681. static readonly ANIMATIONTYPE_COLOR3: number;
  26682. /**
  26683. * Get the Relative Loop Mode
  26684. */
  26685. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26686. /**
  26687. * Get the Cycle Loop Mode
  26688. */
  26689. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26690. /**
  26691. * Get the Constant Loop Mode
  26692. */
  26693. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26694. /** @hidden */
  26695. static _UniversalLerp(left: any, right: any, amount: number): any;
  26696. /**
  26697. * Parses an animation object and creates an animation
  26698. * @param parsedAnimation Parsed animation object
  26699. * @returns Animation object
  26700. */
  26701. static Parse(parsedAnimation: any): Animation;
  26702. /**
  26703. * Appends the serialized animations from the source animations
  26704. * @param source Source containing the animations
  26705. * @param destination Target to store the animations
  26706. */
  26707. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26708. }
  26709. }
  26710. declare module "babylonjs/Materials/Textures/baseTexture" {
  26711. import { Observable } from "babylonjs/Misc/observable";
  26712. import { IAnimatable } from "babylonjs/Misc/tools";
  26713. import { Nullable } from "babylonjs/types";
  26714. import { Scene } from "babylonjs/scene";
  26715. import { Matrix, ISize } from "babylonjs/Maths/math";
  26716. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26717. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26718. /**
  26719. * Base class of all the textures in babylon.
  26720. * It groups all the common properties the materials, post process, lights... might need
  26721. * in order to make a correct use of the texture.
  26722. */
  26723. export class BaseTexture implements IAnimatable {
  26724. /**
  26725. * Default anisotropic filtering level for the application.
  26726. * It is set to 4 as a good tradeoff between perf and quality.
  26727. */
  26728. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26729. /**
  26730. * Gets or sets the unique id of the texture
  26731. */
  26732. uniqueId: number;
  26733. /**
  26734. * Define the name of the texture.
  26735. */
  26736. name: string;
  26737. /**
  26738. * Gets or sets an object used to store user defined information.
  26739. */
  26740. metadata: any;
  26741. /**
  26742. * For internal use only. Please do not use.
  26743. */
  26744. reservedDataStore: any;
  26745. private _hasAlpha;
  26746. /**
  26747. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26748. */
  26749. hasAlpha: boolean;
  26750. /**
  26751. * Defines if the alpha value should be determined via the rgb values.
  26752. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26753. */
  26754. getAlphaFromRGB: boolean;
  26755. /**
  26756. * Intensity or strength of the texture.
  26757. * It is commonly used by materials to fine tune the intensity of the texture
  26758. */
  26759. level: number;
  26760. /**
  26761. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26762. * This is part of the texture as textures usually maps to one uv set.
  26763. */
  26764. coordinatesIndex: number;
  26765. private _coordinatesMode;
  26766. /**
  26767. * How a texture is mapped.
  26768. *
  26769. * | Value | Type | Description |
  26770. * | ----- | ----------------------------------- | ----------- |
  26771. * | 0 | EXPLICIT_MODE | |
  26772. * | 1 | SPHERICAL_MODE | |
  26773. * | 2 | PLANAR_MODE | |
  26774. * | 3 | CUBIC_MODE | |
  26775. * | 4 | PROJECTION_MODE | |
  26776. * | 5 | SKYBOX_MODE | |
  26777. * | 6 | INVCUBIC_MODE | |
  26778. * | 7 | EQUIRECTANGULAR_MODE | |
  26779. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26780. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26781. */
  26782. coordinatesMode: number;
  26783. /**
  26784. * | Value | Type | Description |
  26785. * | ----- | ------------------ | ----------- |
  26786. * | 0 | CLAMP_ADDRESSMODE | |
  26787. * | 1 | WRAP_ADDRESSMODE | |
  26788. * | 2 | MIRROR_ADDRESSMODE | |
  26789. */
  26790. wrapU: number;
  26791. /**
  26792. * | Value | Type | Description |
  26793. * | ----- | ------------------ | ----------- |
  26794. * | 0 | CLAMP_ADDRESSMODE | |
  26795. * | 1 | WRAP_ADDRESSMODE | |
  26796. * | 2 | MIRROR_ADDRESSMODE | |
  26797. */
  26798. wrapV: number;
  26799. /**
  26800. * | Value | Type | Description |
  26801. * | ----- | ------------------ | ----------- |
  26802. * | 0 | CLAMP_ADDRESSMODE | |
  26803. * | 1 | WRAP_ADDRESSMODE | |
  26804. * | 2 | MIRROR_ADDRESSMODE | |
  26805. */
  26806. wrapR: number;
  26807. /**
  26808. * With compliant hardware and browser (supporting anisotropic filtering)
  26809. * this defines the level of anisotropic filtering in the texture.
  26810. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26811. */
  26812. anisotropicFilteringLevel: number;
  26813. /**
  26814. * Define if the texture is a cube texture or if false a 2d texture.
  26815. */
  26816. isCube: boolean;
  26817. /**
  26818. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26819. */
  26820. is3D: boolean;
  26821. /**
  26822. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26823. * HDR texture are usually stored in linear space.
  26824. * This only impacts the PBR and Background materials
  26825. */
  26826. gammaSpace: boolean;
  26827. /**
  26828. * Gets whether or not the texture contains RGBD data.
  26829. */
  26830. readonly isRGBD: boolean;
  26831. /**
  26832. * Is Z inverted in the texture (useful in a cube texture).
  26833. */
  26834. invertZ: boolean;
  26835. /**
  26836. * Are mip maps generated for this texture or not.
  26837. */
  26838. readonly noMipmap: boolean;
  26839. /**
  26840. * @hidden
  26841. */
  26842. lodLevelInAlpha: boolean;
  26843. /**
  26844. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26845. */
  26846. lodGenerationOffset: number;
  26847. /**
  26848. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26849. */
  26850. lodGenerationScale: number;
  26851. /**
  26852. * Define if the texture is a render target.
  26853. */
  26854. isRenderTarget: boolean;
  26855. /**
  26856. * Define the unique id of the texture in the scene.
  26857. */
  26858. readonly uid: string;
  26859. /**
  26860. * Return a string representation of the texture.
  26861. * @returns the texture as a string
  26862. */
  26863. toString(): string;
  26864. /**
  26865. * Get the class name of the texture.
  26866. * @returns "BaseTexture"
  26867. */
  26868. getClassName(): string;
  26869. /**
  26870. * Define the list of animation attached to the texture.
  26871. */
  26872. animations: import("babylonjs/Animations/animation").Animation[];
  26873. /**
  26874. * An event triggered when the texture is disposed.
  26875. */
  26876. onDisposeObservable: Observable<BaseTexture>;
  26877. private _onDisposeObserver;
  26878. /**
  26879. * Callback triggered when the texture has been disposed.
  26880. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26881. */
  26882. onDispose: () => void;
  26883. /**
  26884. * Define the current state of the loading sequence when in delayed load mode.
  26885. */
  26886. delayLoadState: number;
  26887. private _scene;
  26888. /** @hidden */
  26889. _texture: Nullable<InternalTexture>;
  26890. private _uid;
  26891. /**
  26892. * Define if the texture is preventinga material to render or not.
  26893. * If not and the texture is not ready, the engine will use a default black texture instead.
  26894. */
  26895. readonly isBlocking: boolean;
  26896. /**
  26897. * Instantiates a new BaseTexture.
  26898. * Base class of all the textures in babylon.
  26899. * It groups all the common properties the materials, post process, lights... might need
  26900. * in order to make a correct use of the texture.
  26901. * @param scene Define the scene the texture blongs to
  26902. */
  26903. constructor(scene: Nullable<Scene>);
  26904. /**
  26905. * Get the scene the texture belongs to.
  26906. * @returns the scene or null if undefined
  26907. */
  26908. getScene(): Nullable<Scene>;
  26909. /**
  26910. * Get the texture transform matrix used to offset tile the texture for istance.
  26911. * @returns the transformation matrix
  26912. */
  26913. getTextureMatrix(): Matrix;
  26914. /**
  26915. * Get the texture reflection matrix used to rotate/transform the reflection.
  26916. * @returns the reflection matrix
  26917. */
  26918. getReflectionTextureMatrix(): Matrix;
  26919. /**
  26920. * Get the underlying lower level texture from Babylon.
  26921. * @returns the insternal texture
  26922. */
  26923. getInternalTexture(): Nullable<InternalTexture>;
  26924. /**
  26925. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26926. * @returns true if ready or not blocking
  26927. */
  26928. isReadyOrNotBlocking(): boolean;
  26929. /**
  26930. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26931. * @returns true if fully ready
  26932. */
  26933. isReady(): boolean;
  26934. private _cachedSize;
  26935. /**
  26936. * Get the size of the texture.
  26937. * @returns the texture size.
  26938. */
  26939. getSize(): ISize;
  26940. /**
  26941. * Get the base size of the texture.
  26942. * It can be different from the size if the texture has been resized for POT for instance
  26943. * @returns the base size
  26944. */
  26945. getBaseSize(): ISize;
  26946. /**
  26947. * Update the sampling mode of the texture.
  26948. * Default is Trilinear mode.
  26949. *
  26950. * | Value | Type | Description |
  26951. * | ----- | ------------------ | ----------- |
  26952. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26953. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26954. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26955. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26956. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26957. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26958. * | 7 | NEAREST_LINEAR | |
  26959. * | 8 | NEAREST_NEAREST | |
  26960. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26961. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26962. * | 11 | LINEAR_LINEAR | |
  26963. * | 12 | LINEAR_NEAREST | |
  26964. *
  26965. * > _mag_: magnification filter (close to the viewer)
  26966. * > _min_: minification filter (far from the viewer)
  26967. * > _mip_: filter used between mip map levels
  26968. *@param samplingMode Define the new sampling mode of the texture
  26969. */
  26970. updateSamplingMode(samplingMode: number): void;
  26971. /**
  26972. * Scales the texture if is `canRescale()`
  26973. * @param ratio the resize factor we want to use to rescale
  26974. */
  26975. scale(ratio: number): void;
  26976. /**
  26977. * Get if the texture can rescale.
  26978. */
  26979. readonly canRescale: boolean;
  26980. /** @hidden */
  26981. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26982. /** @hidden */
  26983. _rebuild(): void;
  26984. /**
  26985. * Triggers the load sequence in delayed load mode.
  26986. */
  26987. delayLoad(): void;
  26988. /**
  26989. * Clones the texture.
  26990. * @returns the cloned texture
  26991. */
  26992. clone(): Nullable<BaseTexture>;
  26993. /**
  26994. * Get the texture underlying type (INT, FLOAT...)
  26995. */
  26996. readonly textureType: number;
  26997. /**
  26998. * Get the texture underlying format (RGB, RGBA...)
  26999. */
  27000. readonly textureFormat: number;
  27001. /**
  27002. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27003. * This will returns an RGBA array buffer containing either in values (0-255) or
  27004. * float values (0-1) depending of the underlying buffer type.
  27005. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27006. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27007. * @param buffer defines a user defined buffer to fill with data (can be null)
  27008. * @returns The Array buffer containing the pixels data.
  27009. */
  27010. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27011. /**
  27012. * Release and destroy the underlying lower level texture aka internalTexture.
  27013. */
  27014. releaseInternalTexture(): void;
  27015. /**
  27016. * Get the polynomial representation of the texture data.
  27017. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27018. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27019. */
  27020. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27021. /** @hidden */
  27022. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27023. /** @hidden */
  27024. readonly _lodTextureMid: Nullable<BaseTexture>;
  27025. /** @hidden */
  27026. readonly _lodTextureLow: Nullable<BaseTexture>;
  27027. /**
  27028. * Dispose the texture and release its associated resources.
  27029. */
  27030. dispose(): void;
  27031. /**
  27032. * Serialize the texture into a JSON representation that can be parsed later on.
  27033. * @returns the JSON representation of the texture
  27034. */
  27035. serialize(): any;
  27036. /**
  27037. * Helper function to be called back once a list of texture contains only ready textures.
  27038. * @param textures Define the list of textures to wait for
  27039. * @param callback Define the callback triggered once the entire list will be ready
  27040. */
  27041. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27042. }
  27043. }
  27044. declare module "babylonjs/Materials/uniformBuffer" {
  27045. import { Nullable, FloatArray } from "babylonjs/types";
  27046. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27047. import { Engine } from "babylonjs/Engines/engine";
  27048. import { Effect } from "babylonjs/Materials/effect";
  27049. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27050. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27051. /**
  27052. * Uniform buffer objects.
  27053. *
  27054. * Handles blocks of uniform on the GPU.
  27055. *
  27056. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27057. *
  27058. * For more information, please refer to :
  27059. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27060. */
  27061. export class UniformBuffer {
  27062. private _engine;
  27063. private _buffer;
  27064. private _data;
  27065. private _bufferData;
  27066. private _dynamic?;
  27067. private _uniformLocations;
  27068. private _uniformSizes;
  27069. private _uniformLocationPointer;
  27070. private _needSync;
  27071. private _noUBO;
  27072. private _currentEffect;
  27073. private static _MAX_UNIFORM_SIZE;
  27074. private static _tempBuffer;
  27075. /**
  27076. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27077. * This is dynamic to allow compat with webgl 1 and 2.
  27078. * You will need to pass the name of the uniform as well as the value.
  27079. */
  27080. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27081. /**
  27082. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27083. * This is dynamic to allow compat with webgl 1 and 2.
  27084. * You will need to pass the name of the uniform as well as the value.
  27085. */
  27086. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27087. /**
  27088. * Lambda to Update a single float in a uniform buffer.
  27089. * This is dynamic to allow compat with webgl 1 and 2.
  27090. * You will need to pass the name of the uniform as well as the value.
  27091. */
  27092. updateFloat: (name: string, x: number) => void;
  27093. /**
  27094. * Lambda to Update a vec2 of float in a uniform buffer.
  27095. * This is dynamic to allow compat with webgl 1 and 2.
  27096. * You will need to pass the name of the uniform as well as the value.
  27097. */
  27098. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27099. /**
  27100. * Lambda to Update a vec3 of float in a uniform buffer.
  27101. * This is dynamic to allow compat with webgl 1 and 2.
  27102. * You will need to pass the name of the uniform as well as the value.
  27103. */
  27104. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27105. /**
  27106. * Lambda to Update a vec4 of float in a uniform buffer.
  27107. * This is dynamic to allow compat with webgl 1 and 2.
  27108. * You will need to pass the name of the uniform as well as the value.
  27109. */
  27110. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27111. /**
  27112. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27113. * This is dynamic to allow compat with webgl 1 and 2.
  27114. * You will need to pass the name of the uniform as well as the value.
  27115. */
  27116. updateMatrix: (name: string, mat: Matrix) => void;
  27117. /**
  27118. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27119. * This is dynamic to allow compat with webgl 1 and 2.
  27120. * You will need to pass the name of the uniform as well as the value.
  27121. */
  27122. updateVector3: (name: string, vector: Vector3) => void;
  27123. /**
  27124. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27125. * This is dynamic to allow compat with webgl 1 and 2.
  27126. * You will need to pass the name of the uniform as well as the value.
  27127. */
  27128. updateVector4: (name: string, vector: Vector4) => void;
  27129. /**
  27130. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27131. * This is dynamic to allow compat with webgl 1 and 2.
  27132. * You will need to pass the name of the uniform as well as the value.
  27133. */
  27134. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27135. /**
  27136. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27137. * This is dynamic to allow compat with webgl 1 and 2.
  27138. * You will need to pass the name of the uniform as well as the value.
  27139. */
  27140. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27141. /**
  27142. * Instantiates a new Uniform buffer objects.
  27143. *
  27144. * Handles blocks of uniform on the GPU.
  27145. *
  27146. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27147. *
  27148. * For more information, please refer to :
  27149. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27150. * @param engine Define the engine the buffer is associated with
  27151. * @param data Define the data contained in the buffer
  27152. * @param dynamic Define if the buffer is updatable
  27153. */
  27154. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27155. /**
  27156. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27157. * or just falling back on setUniformXXX calls.
  27158. */
  27159. readonly useUbo: boolean;
  27160. /**
  27161. * Indicates if the WebGL underlying uniform buffer is in sync
  27162. * with the javascript cache data.
  27163. */
  27164. readonly isSync: boolean;
  27165. /**
  27166. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27167. * Also, a dynamic UniformBuffer will disable cache verification and always
  27168. * update the underlying WebGL uniform buffer to the GPU.
  27169. * @returns if Dynamic, otherwise false
  27170. */
  27171. isDynamic(): boolean;
  27172. /**
  27173. * The data cache on JS side.
  27174. * @returns the underlying data as a float array
  27175. */
  27176. getData(): Float32Array;
  27177. /**
  27178. * The underlying WebGL Uniform buffer.
  27179. * @returns the webgl buffer
  27180. */
  27181. getBuffer(): Nullable<DataBuffer>;
  27182. /**
  27183. * std140 layout specifies how to align data within an UBO structure.
  27184. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27185. * for specs.
  27186. */
  27187. private _fillAlignment;
  27188. /**
  27189. * Adds an uniform in the buffer.
  27190. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27191. * for the layout to be correct !
  27192. * @param name Name of the uniform, as used in the uniform block in the shader.
  27193. * @param size Data size, or data directly.
  27194. */
  27195. addUniform(name: string, size: number | number[]): void;
  27196. /**
  27197. * Adds a Matrix 4x4 to the uniform buffer.
  27198. * @param name Name of the uniform, as used in the uniform block in the shader.
  27199. * @param mat A 4x4 matrix.
  27200. */
  27201. addMatrix(name: string, mat: Matrix): void;
  27202. /**
  27203. * Adds a vec2 to the uniform buffer.
  27204. * @param name Name of the uniform, as used in the uniform block in the shader.
  27205. * @param x Define the x component value of the vec2
  27206. * @param y Define the y component value of the vec2
  27207. */
  27208. addFloat2(name: string, x: number, y: number): void;
  27209. /**
  27210. * Adds a vec3 to the uniform buffer.
  27211. * @param name Name of the uniform, as used in the uniform block in the shader.
  27212. * @param x Define the x component value of the vec3
  27213. * @param y Define the y component value of the vec3
  27214. * @param z Define the z component value of the vec3
  27215. */
  27216. addFloat3(name: string, x: number, y: number, z: number): void;
  27217. /**
  27218. * Adds a vec3 to the uniform buffer.
  27219. * @param name Name of the uniform, as used in the uniform block in the shader.
  27220. * @param color Define the vec3 from a Color
  27221. */
  27222. addColor3(name: string, color: Color3): void;
  27223. /**
  27224. * Adds a vec4 to the uniform buffer.
  27225. * @param name Name of the uniform, as used in the uniform block in the shader.
  27226. * @param color Define the rgb components from a Color
  27227. * @param alpha Define the a component of the vec4
  27228. */
  27229. addColor4(name: string, color: Color3, alpha: number): void;
  27230. /**
  27231. * Adds a vec3 to the uniform buffer.
  27232. * @param name Name of the uniform, as used in the uniform block in the shader.
  27233. * @param vector Define the vec3 components from a Vector
  27234. */
  27235. addVector3(name: string, vector: Vector3): void;
  27236. /**
  27237. * Adds a Matrix 3x3 to the uniform buffer.
  27238. * @param name Name of the uniform, as used in the uniform block in the shader.
  27239. */
  27240. addMatrix3x3(name: string): void;
  27241. /**
  27242. * Adds a Matrix 2x2 to the uniform buffer.
  27243. * @param name Name of the uniform, as used in the uniform block in the shader.
  27244. */
  27245. addMatrix2x2(name: string): void;
  27246. /**
  27247. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27248. */
  27249. create(): void;
  27250. /** @hidden */
  27251. _rebuild(): void;
  27252. /**
  27253. * Updates the WebGL Uniform Buffer on the GPU.
  27254. * If the `dynamic` flag is set to true, no cache comparison is done.
  27255. * Otherwise, the buffer will be updated only if the cache differs.
  27256. */
  27257. update(): void;
  27258. /**
  27259. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27260. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27261. * @param data Define the flattened data
  27262. * @param size Define the size of the data.
  27263. */
  27264. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27265. private _updateMatrix3x3ForUniform;
  27266. private _updateMatrix3x3ForEffect;
  27267. private _updateMatrix2x2ForEffect;
  27268. private _updateMatrix2x2ForUniform;
  27269. private _updateFloatForEffect;
  27270. private _updateFloatForUniform;
  27271. private _updateFloat2ForEffect;
  27272. private _updateFloat2ForUniform;
  27273. private _updateFloat3ForEffect;
  27274. private _updateFloat3ForUniform;
  27275. private _updateFloat4ForEffect;
  27276. private _updateFloat4ForUniform;
  27277. private _updateMatrixForEffect;
  27278. private _updateMatrixForUniform;
  27279. private _updateVector3ForEffect;
  27280. private _updateVector3ForUniform;
  27281. private _updateVector4ForEffect;
  27282. private _updateVector4ForUniform;
  27283. private _updateColor3ForEffect;
  27284. private _updateColor3ForUniform;
  27285. private _updateColor4ForEffect;
  27286. private _updateColor4ForUniform;
  27287. /**
  27288. * Sets a sampler uniform on the effect.
  27289. * @param name Define the name of the sampler.
  27290. * @param texture Define the texture to set in the sampler
  27291. */
  27292. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27293. /**
  27294. * Directly updates the value of the uniform in the cache AND on the GPU.
  27295. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27296. * @param data Define the flattened data
  27297. */
  27298. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27299. /**
  27300. * Binds this uniform buffer to an effect.
  27301. * @param effect Define the effect to bind the buffer to
  27302. * @param name Name of the uniform block in the shader.
  27303. */
  27304. bindToEffect(effect: Effect, name: string): void;
  27305. /**
  27306. * Disposes the uniform buffer.
  27307. */
  27308. dispose(): void;
  27309. }
  27310. }
  27311. declare module "babylonjs/Audio/analyser" {
  27312. import { Scene } from "babylonjs/scene";
  27313. /**
  27314. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27316. */
  27317. export class Analyser {
  27318. /**
  27319. * Gets or sets the smoothing
  27320. * @ignorenaming
  27321. */
  27322. SMOOTHING: number;
  27323. /**
  27324. * Gets or sets the FFT table size
  27325. * @ignorenaming
  27326. */
  27327. FFT_SIZE: number;
  27328. /**
  27329. * Gets or sets the bar graph amplitude
  27330. * @ignorenaming
  27331. */
  27332. BARGRAPHAMPLITUDE: number;
  27333. /**
  27334. * Gets or sets the position of the debug canvas
  27335. * @ignorenaming
  27336. */
  27337. DEBUGCANVASPOS: {
  27338. x: number;
  27339. y: number;
  27340. };
  27341. /**
  27342. * Gets or sets the debug canvas size
  27343. * @ignorenaming
  27344. */
  27345. DEBUGCANVASSIZE: {
  27346. width: number;
  27347. height: number;
  27348. };
  27349. private _byteFreqs;
  27350. private _byteTime;
  27351. private _floatFreqs;
  27352. private _webAudioAnalyser;
  27353. private _debugCanvas;
  27354. private _debugCanvasContext;
  27355. private _scene;
  27356. private _registerFunc;
  27357. private _audioEngine;
  27358. /**
  27359. * Creates a new analyser
  27360. * @param scene defines hosting scene
  27361. */
  27362. constructor(scene: Scene);
  27363. /**
  27364. * Get the number of data values you will have to play with for the visualization
  27365. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27366. * @returns a number
  27367. */
  27368. getFrequencyBinCount(): number;
  27369. /**
  27370. * Gets the current frequency data as a byte array
  27371. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27372. * @returns a Uint8Array
  27373. */
  27374. getByteFrequencyData(): Uint8Array;
  27375. /**
  27376. * Gets the current waveform as a byte array
  27377. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27378. * @returns a Uint8Array
  27379. */
  27380. getByteTimeDomainData(): Uint8Array;
  27381. /**
  27382. * Gets the current frequency data as a float array
  27383. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27384. * @returns a Float32Array
  27385. */
  27386. getFloatFrequencyData(): Float32Array;
  27387. /**
  27388. * Renders the debug canvas
  27389. */
  27390. drawDebugCanvas(): void;
  27391. /**
  27392. * Stops rendering the debug canvas and removes it
  27393. */
  27394. stopDebugCanvas(): void;
  27395. /**
  27396. * Connects two audio nodes
  27397. * @param inputAudioNode defines first node to connect
  27398. * @param outputAudioNode defines second node to connect
  27399. */
  27400. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27401. /**
  27402. * Releases all associated resources
  27403. */
  27404. dispose(): void;
  27405. }
  27406. }
  27407. declare module "babylonjs/Audio/audioEngine" {
  27408. import { IDisposable } from "babylonjs/scene";
  27409. import { Analyser } from "babylonjs/Audio/analyser";
  27410. import { Nullable } from "babylonjs/types";
  27411. import { Observable } from "babylonjs/Misc/observable";
  27412. /**
  27413. * This represents an audio engine and it is responsible
  27414. * to play, synchronize and analyse sounds throughout the application.
  27415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27416. */
  27417. export interface IAudioEngine extends IDisposable {
  27418. /**
  27419. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27420. */
  27421. readonly canUseWebAudio: boolean;
  27422. /**
  27423. * Gets the current AudioContext if available.
  27424. */
  27425. readonly audioContext: Nullable<AudioContext>;
  27426. /**
  27427. * The master gain node defines the global audio volume of your audio engine.
  27428. */
  27429. readonly masterGain: GainNode;
  27430. /**
  27431. * Gets whether or not mp3 are supported by your browser.
  27432. */
  27433. readonly isMP3supported: boolean;
  27434. /**
  27435. * Gets whether or not ogg are supported by your browser.
  27436. */
  27437. readonly isOGGsupported: boolean;
  27438. /**
  27439. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27440. * @ignoreNaming
  27441. */
  27442. WarnedWebAudioUnsupported: boolean;
  27443. /**
  27444. * Defines if the audio engine relies on a custom unlocked button.
  27445. * In this case, the embedded button will not be displayed.
  27446. */
  27447. useCustomUnlockedButton: boolean;
  27448. /**
  27449. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27450. */
  27451. readonly unlocked: boolean;
  27452. /**
  27453. * Event raised when audio has been unlocked on the browser.
  27454. */
  27455. onAudioUnlockedObservable: Observable<AudioEngine>;
  27456. /**
  27457. * Event raised when audio has been locked on the browser.
  27458. */
  27459. onAudioLockedObservable: Observable<AudioEngine>;
  27460. /**
  27461. * Flags the audio engine in Locked state.
  27462. * This happens due to new browser policies preventing audio to autoplay.
  27463. */
  27464. lock(): void;
  27465. /**
  27466. * Unlocks the audio engine once a user action has been done on the dom.
  27467. * This is helpful to resume play once browser policies have been satisfied.
  27468. */
  27469. unlock(): void;
  27470. }
  27471. /**
  27472. * This represents the default audio engine used in babylon.
  27473. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27475. */
  27476. export class AudioEngine implements IAudioEngine {
  27477. private _audioContext;
  27478. private _audioContextInitialized;
  27479. private _muteButton;
  27480. private _hostElement;
  27481. /**
  27482. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27483. */
  27484. canUseWebAudio: boolean;
  27485. /**
  27486. * The master gain node defines the global audio volume of your audio engine.
  27487. */
  27488. masterGain: GainNode;
  27489. /**
  27490. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27491. * @ignoreNaming
  27492. */
  27493. WarnedWebAudioUnsupported: boolean;
  27494. /**
  27495. * Gets whether or not mp3 are supported by your browser.
  27496. */
  27497. isMP3supported: boolean;
  27498. /**
  27499. * Gets whether or not ogg are supported by your browser.
  27500. */
  27501. isOGGsupported: boolean;
  27502. /**
  27503. * Gets whether audio has been unlocked on the device.
  27504. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27505. * a user interaction has happened.
  27506. */
  27507. unlocked: boolean;
  27508. /**
  27509. * Defines if the audio engine relies on a custom unlocked button.
  27510. * In this case, the embedded button will not be displayed.
  27511. */
  27512. useCustomUnlockedButton: boolean;
  27513. /**
  27514. * Event raised when audio has been unlocked on the browser.
  27515. */
  27516. onAudioUnlockedObservable: Observable<AudioEngine>;
  27517. /**
  27518. * Event raised when audio has been locked on the browser.
  27519. */
  27520. onAudioLockedObservable: Observable<AudioEngine>;
  27521. /**
  27522. * Gets the current AudioContext if available.
  27523. */
  27524. readonly audioContext: Nullable<AudioContext>;
  27525. private _connectedAnalyser;
  27526. /**
  27527. * Instantiates a new audio engine.
  27528. *
  27529. * There should be only one per page as some browsers restrict the number
  27530. * of audio contexts you can create.
  27531. * @param hostElement defines the host element where to display the mute icon if necessary
  27532. */
  27533. constructor(hostElement?: Nullable<HTMLElement>);
  27534. /**
  27535. * Flags the audio engine in Locked state.
  27536. * This happens due to new browser policies preventing audio to autoplay.
  27537. */
  27538. lock(): void;
  27539. /**
  27540. * Unlocks the audio engine once a user action has been done on the dom.
  27541. * This is helpful to resume play once browser policies have been satisfied.
  27542. */
  27543. unlock(): void;
  27544. private _resumeAudioContext;
  27545. private _initializeAudioContext;
  27546. private _tryToRun;
  27547. private _triggerRunningState;
  27548. private _triggerSuspendedState;
  27549. private _displayMuteButton;
  27550. private _moveButtonToTopLeft;
  27551. private _onResize;
  27552. private _hideMuteButton;
  27553. /**
  27554. * Destroy and release the resources associated with the audio ccontext.
  27555. */
  27556. dispose(): void;
  27557. /**
  27558. * Gets the global volume sets on the master gain.
  27559. * @returns the global volume if set or -1 otherwise
  27560. */
  27561. getGlobalVolume(): number;
  27562. /**
  27563. * Sets the global volume of your experience (sets on the master gain).
  27564. * @param newVolume Defines the new global volume of the application
  27565. */
  27566. setGlobalVolume(newVolume: number): void;
  27567. /**
  27568. * Connect the audio engine to an audio analyser allowing some amazing
  27569. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27571. * @param analyser The analyser to connect to the engine
  27572. */
  27573. connectToAnalyser(analyser: Analyser): void;
  27574. }
  27575. }
  27576. declare module "babylonjs/Loading/loadingScreen" {
  27577. /**
  27578. * Interface used to present a loading screen while loading a scene
  27579. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27580. */
  27581. export interface ILoadingScreen {
  27582. /**
  27583. * Function called to display the loading screen
  27584. */
  27585. displayLoadingUI: () => void;
  27586. /**
  27587. * Function called to hide the loading screen
  27588. */
  27589. hideLoadingUI: () => void;
  27590. /**
  27591. * Gets or sets the color to use for the background
  27592. */
  27593. loadingUIBackgroundColor: string;
  27594. /**
  27595. * Gets or sets the text to display while loading
  27596. */
  27597. loadingUIText: string;
  27598. }
  27599. /**
  27600. * Class used for the default loading screen
  27601. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27602. */
  27603. export class DefaultLoadingScreen implements ILoadingScreen {
  27604. private _renderingCanvas;
  27605. private _loadingText;
  27606. private _loadingDivBackgroundColor;
  27607. private _loadingDiv;
  27608. private _loadingTextDiv;
  27609. /** Gets or sets the logo url to use for the default loading screen */
  27610. static DefaultLogoUrl: string;
  27611. /** Gets or sets the spinner url to use for the default loading screen */
  27612. static DefaultSpinnerUrl: string;
  27613. /**
  27614. * Creates a new default loading screen
  27615. * @param _renderingCanvas defines the canvas used to render the scene
  27616. * @param _loadingText defines the default text to display
  27617. * @param _loadingDivBackgroundColor defines the default background color
  27618. */
  27619. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27620. /**
  27621. * Function called to display the loading screen
  27622. */
  27623. displayLoadingUI(): void;
  27624. /**
  27625. * Function called to hide the loading screen
  27626. */
  27627. hideLoadingUI(): void;
  27628. /**
  27629. * Gets or sets the text to display while loading
  27630. */
  27631. loadingUIText: string;
  27632. /**
  27633. * Gets or sets the color to use for the background
  27634. */
  27635. loadingUIBackgroundColor: string;
  27636. private _resizeLoadingUI;
  27637. }
  27638. }
  27639. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27640. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27641. import { Engine } from "babylonjs/Engines/engine";
  27642. import { Nullable } from "babylonjs/types";
  27643. /** @hidden */
  27644. export class WebGLPipelineContext implements IPipelineContext {
  27645. engine: Engine;
  27646. program: Nullable<WebGLProgram>;
  27647. context?: WebGLRenderingContext;
  27648. vertexShader?: WebGLShader;
  27649. fragmentShader?: WebGLShader;
  27650. isParallelCompiled: boolean;
  27651. onCompiled?: () => void;
  27652. transformFeedback?: WebGLTransformFeedback | null;
  27653. readonly isAsync: boolean;
  27654. readonly isReady: boolean;
  27655. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27656. }
  27657. }
  27658. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27659. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27660. /** @hidden */
  27661. export class WebGLDataBuffer extends DataBuffer {
  27662. private _buffer;
  27663. constructor(resource: WebGLBuffer);
  27664. readonly underlyingResource: any;
  27665. }
  27666. }
  27667. declare module "babylonjs/Materials/Textures/videoTexture" {
  27668. import { Observable } from "babylonjs/Misc/observable";
  27669. import { Nullable } from "babylonjs/types";
  27670. import { Scene } from "babylonjs/scene";
  27671. import { Texture } from "babylonjs/Materials/Textures/texture";
  27672. /**
  27673. * Settings for finer control over video usage
  27674. */
  27675. export interface VideoTextureSettings {
  27676. /**
  27677. * Applies `autoplay` to video, if specified
  27678. */
  27679. autoPlay?: boolean;
  27680. /**
  27681. * Applies `loop` to video, if specified
  27682. */
  27683. loop?: boolean;
  27684. /**
  27685. * Automatically updates internal texture from video at every frame in the render loop
  27686. */
  27687. autoUpdateTexture: boolean;
  27688. /**
  27689. * Image src displayed during the video loading or until the user interacts with the video.
  27690. */
  27691. poster?: string;
  27692. }
  27693. /**
  27694. * If you want to display a video in your scene, this is the special texture for that.
  27695. * This special texture works similar to other textures, with the exception of a few parameters.
  27696. * @see https://doc.babylonjs.com/how_to/video_texture
  27697. */
  27698. export class VideoTexture extends Texture {
  27699. /**
  27700. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27701. */
  27702. readonly autoUpdateTexture: boolean;
  27703. /**
  27704. * The video instance used by the texture internally
  27705. */
  27706. readonly video: HTMLVideoElement;
  27707. private _onUserActionRequestedObservable;
  27708. /**
  27709. * Event triggerd when a dom action is required by the user to play the video.
  27710. * This happens due to recent changes in browser policies preventing video to auto start.
  27711. */
  27712. readonly onUserActionRequestedObservable: Observable<Texture>;
  27713. private _generateMipMaps;
  27714. private _engine;
  27715. private _stillImageCaptured;
  27716. private _displayingPosterTexture;
  27717. private _settings;
  27718. private _createInternalTextureOnEvent;
  27719. /**
  27720. * Creates a video texture.
  27721. * If you want to display a video in your scene, this is the special texture for that.
  27722. * This special texture works similar to other textures, with the exception of a few parameters.
  27723. * @see https://doc.babylonjs.com/how_to/video_texture
  27724. * @param name optional name, will detect from video source, if not defined
  27725. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27726. * @param scene is obviously the current scene.
  27727. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27728. * @param invertY is false by default but can be used to invert video on Y axis
  27729. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27730. * @param settings allows finer control over video usage
  27731. */
  27732. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27733. private _getName;
  27734. private _getVideo;
  27735. private _createInternalTexture;
  27736. private reset;
  27737. /**
  27738. * @hidden Internal method to initiate `update`.
  27739. */
  27740. _rebuild(): void;
  27741. /**
  27742. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27743. */
  27744. update(): void;
  27745. /**
  27746. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27747. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27748. */
  27749. updateTexture(isVisible: boolean): void;
  27750. protected _updateInternalTexture: () => void;
  27751. /**
  27752. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27753. * @param url New url.
  27754. */
  27755. updateURL(url: string): void;
  27756. /**
  27757. * Dispose the texture and release its associated resources.
  27758. */
  27759. dispose(): void;
  27760. /**
  27761. * Creates a video texture straight from a stream.
  27762. * @param scene Define the scene the texture should be created in
  27763. * @param stream Define the stream the texture should be created from
  27764. * @returns The created video texture as a promise
  27765. */
  27766. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27767. /**
  27768. * Creates a video texture straight from your WebCam video feed.
  27769. * @param scene Define the scene the texture should be created in
  27770. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27771. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27772. * @returns The created video texture as a promise
  27773. */
  27774. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27775. minWidth: number;
  27776. maxWidth: number;
  27777. minHeight: number;
  27778. maxHeight: number;
  27779. deviceId: string;
  27780. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27781. /**
  27782. * Creates a video texture straight from your WebCam video feed.
  27783. * @param scene Define the scene the texture should be created in
  27784. * @param onReady Define a callback to triggered once the texture will be ready
  27785. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27786. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27787. */
  27788. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27789. minWidth: number;
  27790. maxWidth: number;
  27791. minHeight: number;
  27792. maxHeight: number;
  27793. deviceId: string;
  27794. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27795. }
  27796. }
  27797. declare module "babylonjs/Engines/engine" {
  27798. import { Observable } from "babylonjs/Misc/observable";
  27799. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27800. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27801. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27802. import { Camera } from "babylonjs/Cameras/camera";
  27803. import { Scene } from "babylonjs/scene";
  27804. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27805. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27806. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27807. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27808. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27809. import { Material } from "babylonjs/Materials/material";
  27810. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27811. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27812. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27813. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27814. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27815. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27816. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27817. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27818. import { WebRequest } from "babylonjs/Misc/webRequest";
  27819. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27820. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27821. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27822. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27823. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27824. /**
  27825. * Interface for attribute information associated with buffer instanciation
  27826. */
  27827. export class InstancingAttributeInfo {
  27828. /**
  27829. * Index/offset of the attribute in the vertex shader
  27830. */
  27831. index: number;
  27832. /**
  27833. * size of the attribute, 1, 2, 3 or 4
  27834. */
  27835. attributeSize: number;
  27836. /**
  27837. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27838. * default is FLOAT
  27839. */
  27840. attribyteType: number;
  27841. /**
  27842. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27843. */
  27844. normalized: boolean;
  27845. /**
  27846. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27847. */
  27848. offset: number;
  27849. /**
  27850. * Name of the GLSL attribute, for debugging purpose only
  27851. */
  27852. attributeName: string;
  27853. }
  27854. /**
  27855. * Define options used to create a depth texture
  27856. */
  27857. export class DepthTextureCreationOptions {
  27858. /** Specifies whether or not a stencil should be allocated in the texture */
  27859. generateStencil?: boolean;
  27860. /** Specifies whether or not bilinear filtering is enable on the texture */
  27861. bilinearFiltering?: boolean;
  27862. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27863. comparisonFunction?: number;
  27864. /** Specifies if the created texture is a cube texture */
  27865. isCube?: boolean;
  27866. }
  27867. /**
  27868. * Class used to describe the capabilities of the engine relatively to the current browser
  27869. */
  27870. export class EngineCapabilities {
  27871. /** Maximum textures units per fragment shader */
  27872. maxTexturesImageUnits: number;
  27873. /** Maximum texture units per vertex shader */
  27874. maxVertexTextureImageUnits: number;
  27875. /** Maximum textures units in the entire pipeline */
  27876. maxCombinedTexturesImageUnits: number;
  27877. /** Maximum texture size */
  27878. maxTextureSize: number;
  27879. /** Maximum cube texture size */
  27880. maxCubemapTextureSize: number;
  27881. /** Maximum render texture size */
  27882. maxRenderTextureSize: number;
  27883. /** Maximum number of vertex attributes */
  27884. maxVertexAttribs: number;
  27885. /** Maximum number of varyings */
  27886. maxVaryingVectors: number;
  27887. /** Maximum number of uniforms per vertex shader */
  27888. maxVertexUniformVectors: number;
  27889. /** Maximum number of uniforms per fragment shader */
  27890. maxFragmentUniformVectors: number;
  27891. /** Defines if standard derivates (dx/dy) are supported */
  27892. standardDerivatives: boolean;
  27893. /** Defines if s3tc texture compression is supported */
  27894. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27895. /** Defines if pvrtc texture compression is supported */
  27896. pvrtc: any;
  27897. /** Defines if etc1 texture compression is supported */
  27898. etc1: any;
  27899. /** Defines if etc2 texture compression is supported */
  27900. etc2: any;
  27901. /** Defines if astc texture compression is supported */
  27902. astc: any;
  27903. /** Defines if float textures are supported */
  27904. textureFloat: boolean;
  27905. /** Defines if vertex array objects are supported */
  27906. vertexArrayObject: boolean;
  27907. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27908. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27909. /** Gets the maximum level of anisotropy supported */
  27910. maxAnisotropy: number;
  27911. /** Defines if instancing is supported */
  27912. instancedArrays: boolean;
  27913. /** Defines if 32 bits indices are supported */
  27914. uintIndices: boolean;
  27915. /** Defines if high precision shaders are supported */
  27916. highPrecisionShaderSupported: boolean;
  27917. /** Defines if depth reading in the fragment shader is supported */
  27918. fragmentDepthSupported: boolean;
  27919. /** Defines if float texture linear filtering is supported*/
  27920. textureFloatLinearFiltering: boolean;
  27921. /** Defines if rendering to float textures is supported */
  27922. textureFloatRender: boolean;
  27923. /** Defines if half float textures are supported*/
  27924. textureHalfFloat: boolean;
  27925. /** Defines if half float texture linear filtering is supported*/
  27926. textureHalfFloatLinearFiltering: boolean;
  27927. /** Defines if rendering to half float textures is supported */
  27928. textureHalfFloatRender: boolean;
  27929. /** Defines if textureLOD shader command is supported */
  27930. textureLOD: boolean;
  27931. /** Defines if draw buffers extension is supported */
  27932. drawBuffersExtension: boolean;
  27933. /** Defines if depth textures are supported */
  27934. depthTextureExtension: boolean;
  27935. /** Defines if float color buffer are supported */
  27936. colorBufferFloat: boolean;
  27937. /** Gets disjoint timer query extension (null if not supported) */
  27938. timerQuery: EXT_disjoint_timer_query;
  27939. /** Defines if timestamp can be used with timer query */
  27940. canUseTimestampForTimerQuery: boolean;
  27941. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27942. multiview: any;
  27943. /** Function used to let the system compiles shaders in background */
  27944. parallelShaderCompile: {
  27945. COMPLETION_STATUS_KHR: number;
  27946. };
  27947. }
  27948. /** Interface defining initialization parameters for Engine class */
  27949. export interface EngineOptions extends WebGLContextAttributes {
  27950. /**
  27951. * Defines if the engine should no exceed a specified device ratio
  27952. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27953. */
  27954. limitDeviceRatio?: number;
  27955. /**
  27956. * Defines if webvr should be enabled automatically
  27957. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27958. */
  27959. autoEnableWebVR?: boolean;
  27960. /**
  27961. * Defines if webgl2 should be turned off even if supported
  27962. * @see http://doc.babylonjs.com/features/webgl2
  27963. */
  27964. disableWebGL2Support?: boolean;
  27965. /**
  27966. * Defines if webaudio should be initialized as well
  27967. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27968. */
  27969. audioEngine?: boolean;
  27970. /**
  27971. * Defines if animations should run using a deterministic lock step
  27972. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27973. */
  27974. deterministicLockstep?: boolean;
  27975. /** Defines the maximum steps to use with deterministic lock step mode */
  27976. lockstepMaxSteps?: number;
  27977. /**
  27978. * Defines that engine should ignore context lost events
  27979. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27980. */
  27981. doNotHandleContextLost?: boolean;
  27982. /**
  27983. * Defines that engine should ignore modifying touch action attribute and style
  27984. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27985. */
  27986. doNotHandleTouchAction?: boolean;
  27987. /**
  27988. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27989. */
  27990. useHighPrecisionFloats?: boolean;
  27991. }
  27992. /**
  27993. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27994. */
  27995. export class Engine {
  27996. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27997. static ExceptionList: ({
  27998. key: string;
  27999. capture: string;
  28000. captureConstraint: number;
  28001. targets: string[];
  28002. } | {
  28003. key: string;
  28004. capture: null;
  28005. captureConstraint: null;
  28006. targets: string[];
  28007. })[];
  28008. /** Gets the list of created engines */
  28009. static readonly Instances: Engine[];
  28010. /**
  28011. * Gets the latest created engine
  28012. */
  28013. static readonly LastCreatedEngine: Nullable<Engine>;
  28014. /**
  28015. * Gets the latest created scene
  28016. */
  28017. static readonly LastCreatedScene: Nullable<Scene>;
  28018. /**
  28019. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28020. * @param flag defines which part of the materials must be marked as dirty
  28021. * @param predicate defines a predicate used to filter which materials should be affected
  28022. */
  28023. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28024. /**
  28025. * Hidden
  28026. */
  28027. static _TextureLoaders: IInternalTextureLoader[];
  28028. /** Defines that alpha blending is disabled */
  28029. static readonly ALPHA_DISABLE: number;
  28030. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28031. static readonly ALPHA_ADD: number;
  28032. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28033. static readonly ALPHA_COMBINE: number;
  28034. /** Defines that alpha blending to DEST - SRC * DEST */
  28035. static readonly ALPHA_SUBTRACT: number;
  28036. /** Defines that alpha blending to SRC * DEST */
  28037. static readonly ALPHA_MULTIPLY: number;
  28038. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28039. static readonly ALPHA_MAXIMIZED: number;
  28040. /** Defines that alpha blending to SRC + DEST */
  28041. static readonly ALPHA_ONEONE: number;
  28042. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28043. static readonly ALPHA_PREMULTIPLIED: number;
  28044. /**
  28045. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28046. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28047. */
  28048. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28049. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28050. static readonly ALPHA_INTERPOLATE: number;
  28051. /**
  28052. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28053. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28054. */
  28055. static readonly ALPHA_SCREENMODE: number;
  28056. /** Defines that the ressource is not delayed*/
  28057. static readonly DELAYLOADSTATE_NONE: number;
  28058. /** Defines that the ressource was successfully delay loaded */
  28059. static readonly DELAYLOADSTATE_LOADED: number;
  28060. /** Defines that the ressource is currently delay loading */
  28061. static readonly DELAYLOADSTATE_LOADING: number;
  28062. /** Defines that the ressource is delayed and has not started loading */
  28063. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28064. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28065. static readonly NEVER: number;
  28066. /** 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 */
  28067. static readonly ALWAYS: number;
  28068. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28069. static readonly LESS: number;
  28070. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28071. static readonly EQUAL: number;
  28072. /** 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 */
  28073. static readonly LEQUAL: number;
  28074. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28075. static readonly GREATER: number;
  28076. /** 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 */
  28077. static readonly GEQUAL: number;
  28078. /** 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 */
  28079. static readonly NOTEQUAL: number;
  28080. /** Passed to stencilOperation to specify that stencil value must be kept */
  28081. static readonly KEEP: number;
  28082. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28083. static readonly REPLACE: number;
  28084. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28085. static readonly INCR: number;
  28086. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28087. static readonly DECR: number;
  28088. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28089. static readonly INVERT: number;
  28090. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28091. static readonly INCR_WRAP: number;
  28092. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28093. static readonly DECR_WRAP: number;
  28094. /** Texture is not repeating outside of 0..1 UVs */
  28095. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28096. /** Texture is repeating outside of 0..1 UVs */
  28097. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28098. /** Texture is repeating and mirrored */
  28099. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28100. /** ALPHA */
  28101. static readonly TEXTUREFORMAT_ALPHA: number;
  28102. /** LUMINANCE */
  28103. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28104. /** LUMINANCE_ALPHA */
  28105. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28106. /** RGB */
  28107. static readonly TEXTUREFORMAT_RGB: number;
  28108. /** RGBA */
  28109. static readonly TEXTUREFORMAT_RGBA: number;
  28110. /** RED */
  28111. static readonly TEXTUREFORMAT_RED: number;
  28112. /** RED (2nd reference) */
  28113. static readonly TEXTUREFORMAT_R: number;
  28114. /** RG */
  28115. static readonly TEXTUREFORMAT_RG: number;
  28116. /** RED_INTEGER */
  28117. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28118. /** RED_INTEGER (2nd reference) */
  28119. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28120. /** RG_INTEGER */
  28121. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28122. /** RGB_INTEGER */
  28123. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28124. /** RGBA_INTEGER */
  28125. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28126. /** UNSIGNED_BYTE */
  28127. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28128. /** UNSIGNED_BYTE (2nd reference) */
  28129. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28130. /** FLOAT */
  28131. static readonly TEXTURETYPE_FLOAT: number;
  28132. /** HALF_FLOAT */
  28133. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28134. /** BYTE */
  28135. static readonly TEXTURETYPE_BYTE: number;
  28136. /** SHORT */
  28137. static readonly TEXTURETYPE_SHORT: number;
  28138. /** UNSIGNED_SHORT */
  28139. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28140. /** INT */
  28141. static readonly TEXTURETYPE_INT: number;
  28142. /** UNSIGNED_INT */
  28143. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28144. /** UNSIGNED_SHORT_4_4_4_4 */
  28145. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28146. /** UNSIGNED_SHORT_5_5_5_1 */
  28147. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28148. /** UNSIGNED_SHORT_5_6_5 */
  28149. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28150. /** UNSIGNED_INT_2_10_10_10_REV */
  28151. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28152. /** UNSIGNED_INT_24_8 */
  28153. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28154. /** UNSIGNED_INT_10F_11F_11F_REV */
  28155. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28156. /** UNSIGNED_INT_5_9_9_9_REV */
  28157. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28158. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28159. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28160. /** nearest is mag = nearest and min = nearest and mip = linear */
  28161. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28162. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28163. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28164. /** Trilinear is mag = linear and min = linear and mip = linear */
  28165. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28166. /** nearest is mag = nearest and min = nearest and mip = linear */
  28167. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28168. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28169. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28170. /** Trilinear is mag = linear and min = linear and mip = linear */
  28171. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28172. /** mag = nearest and min = nearest and mip = nearest */
  28173. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28174. /** mag = nearest and min = linear and mip = nearest */
  28175. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28176. /** mag = nearest and min = linear and mip = linear */
  28177. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28178. /** mag = nearest and min = linear and mip = none */
  28179. static readonly TEXTURE_NEAREST_LINEAR: number;
  28180. /** mag = nearest and min = nearest and mip = none */
  28181. static readonly TEXTURE_NEAREST_NEAREST: number;
  28182. /** mag = linear and min = nearest and mip = nearest */
  28183. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28184. /** mag = linear and min = nearest and mip = linear */
  28185. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28186. /** mag = linear and min = linear and mip = none */
  28187. static readonly TEXTURE_LINEAR_LINEAR: number;
  28188. /** mag = linear and min = nearest and mip = none */
  28189. static readonly TEXTURE_LINEAR_NEAREST: number;
  28190. /** Explicit coordinates mode */
  28191. static readonly TEXTURE_EXPLICIT_MODE: number;
  28192. /** Spherical coordinates mode */
  28193. static readonly TEXTURE_SPHERICAL_MODE: number;
  28194. /** Planar coordinates mode */
  28195. static readonly TEXTURE_PLANAR_MODE: number;
  28196. /** Cubic coordinates mode */
  28197. static readonly TEXTURE_CUBIC_MODE: number;
  28198. /** Projection coordinates mode */
  28199. static readonly TEXTURE_PROJECTION_MODE: number;
  28200. /** Skybox coordinates mode */
  28201. static readonly TEXTURE_SKYBOX_MODE: number;
  28202. /** Inverse Cubic coordinates mode */
  28203. static readonly TEXTURE_INVCUBIC_MODE: number;
  28204. /** Equirectangular coordinates mode */
  28205. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28206. /** Equirectangular Fixed coordinates mode */
  28207. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28208. /** Equirectangular Fixed Mirrored coordinates mode */
  28209. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28210. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28211. static readonly SCALEMODE_FLOOR: number;
  28212. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28213. static readonly SCALEMODE_NEAREST: number;
  28214. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28215. static readonly SCALEMODE_CEILING: number;
  28216. /**
  28217. * Returns the current npm package of the sdk
  28218. */
  28219. static readonly NpmPackage: string;
  28220. /**
  28221. * Returns the current version of the framework
  28222. */
  28223. static readonly Version: string;
  28224. /**
  28225. * Returns a string describing the current engine
  28226. */
  28227. readonly description: string;
  28228. /**
  28229. * Gets or sets the epsilon value used by collision engine
  28230. */
  28231. static CollisionsEpsilon: number;
  28232. /**
  28233. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28234. */
  28235. static ShadersRepository: string;
  28236. /**
  28237. * Method called to create the default loading screen.
  28238. * This can be overriden in your own app.
  28239. * @param canvas The rendering canvas element
  28240. * @returns The loading screen
  28241. */
  28242. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28243. /**
  28244. * Method called to create the default rescale post process on each engine.
  28245. */
  28246. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28247. /**
  28248. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28249. */
  28250. forcePOTTextures: boolean;
  28251. /**
  28252. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28253. */
  28254. isFullscreen: boolean;
  28255. /**
  28256. * Gets a boolean indicating if the pointer is currently locked
  28257. */
  28258. isPointerLock: boolean;
  28259. /**
  28260. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28261. */
  28262. cullBackFaces: boolean;
  28263. /**
  28264. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28265. */
  28266. renderEvenInBackground: boolean;
  28267. /**
  28268. * Gets or sets a boolean indicating that cache can be kept between frames
  28269. */
  28270. preventCacheWipeBetweenFrames: boolean;
  28271. /**
  28272. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28273. **/
  28274. enableOfflineSupport: boolean;
  28275. /**
  28276. * 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)
  28277. **/
  28278. disableManifestCheck: boolean;
  28279. /**
  28280. * Gets the list of created scenes
  28281. */
  28282. scenes: Scene[];
  28283. /**
  28284. * Event raised when a new scene is created
  28285. */
  28286. onNewSceneAddedObservable: Observable<Scene>;
  28287. /**
  28288. * Gets the list of created postprocesses
  28289. */
  28290. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28291. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28292. validateShaderPrograms: boolean;
  28293. /**
  28294. * Observable event triggered each time the rendering canvas is resized
  28295. */
  28296. onResizeObservable: Observable<Engine>;
  28297. /**
  28298. * Observable event triggered each time the canvas loses focus
  28299. */
  28300. onCanvasBlurObservable: Observable<Engine>;
  28301. /**
  28302. * Observable event triggered each time the canvas gains focus
  28303. */
  28304. onCanvasFocusObservable: Observable<Engine>;
  28305. /**
  28306. * Observable event triggered each time the canvas receives pointerout event
  28307. */
  28308. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28309. /**
  28310. * Observable event triggered before each texture is initialized
  28311. */
  28312. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28313. /**
  28314. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28315. */
  28316. disableUniformBuffers: boolean;
  28317. /** @hidden */
  28318. _uniformBuffers: UniformBuffer[];
  28319. /**
  28320. * Gets a boolean indicating that the engine supports uniform buffers
  28321. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28322. */
  28323. readonly supportsUniformBuffers: boolean;
  28324. /**
  28325. * Observable raised when the engine begins a new frame
  28326. */
  28327. onBeginFrameObservable: Observable<Engine>;
  28328. /**
  28329. * If set, will be used to request the next animation frame for the render loop
  28330. */
  28331. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28332. /**
  28333. * Observable raised when the engine ends the current frame
  28334. */
  28335. onEndFrameObservable: Observable<Engine>;
  28336. /**
  28337. * Observable raised when the engine is about to compile a shader
  28338. */
  28339. onBeforeShaderCompilationObservable: Observable<Engine>;
  28340. /**
  28341. * Observable raised when the engine has jsut compiled a shader
  28342. */
  28343. onAfterShaderCompilationObservable: Observable<Engine>;
  28344. /** @hidden */
  28345. _gl: WebGLRenderingContext;
  28346. private _renderingCanvas;
  28347. private _windowIsBackground;
  28348. private _webGLVersion;
  28349. protected _highPrecisionShadersAllowed: boolean;
  28350. /** @hidden */
  28351. readonly _shouldUseHighPrecisionShader: boolean;
  28352. /**
  28353. * Gets a boolean indicating that only power of 2 textures are supported
  28354. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28355. */
  28356. readonly needPOTTextures: boolean;
  28357. /** @hidden */
  28358. _badOS: boolean;
  28359. /** @hidden */
  28360. _badDesktopOS: boolean;
  28361. /**
  28362. * Gets the audio engine
  28363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28364. * @ignorenaming
  28365. */
  28366. static audioEngine: IAudioEngine;
  28367. /**
  28368. * Default AudioEngine factory responsible of creating the Audio Engine.
  28369. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28370. */
  28371. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28372. /**
  28373. * Default offline support factory responsible of creating a tool used to store data locally.
  28374. * By default, this will create a Database object if the workload has been embedded.
  28375. */
  28376. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28377. private _onFocus;
  28378. private _onBlur;
  28379. private _onCanvasPointerOut;
  28380. private _onCanvasBlur;
  28381. private _onCanvasFocus;
  28382. private _onFullscreenChange;
  28383. private _onPointerLockChange;
  28384. private _hardwareScalingLevel;
  28385. /** @hidden */
  28386. _caps: EngineCapabilities;
  28387. private _pointerLockRequested;
  28388. private _isStencilEnable;
  28389. private _colorWrite;
  28390. private _loadingScreen;
  28391. /** @hidden */
  28392. _drawCalls: PerfCounter;
  28393. private _glVersion;
  28394. private _glRenderer;
  28395. private _glVendor;
  28396. private _videoTextureSupported;
  28397. private _renderingQueueLaunched;
  28398. private _activeRenderLoops;
  28399. private _deterministicLockstep;
  28400. private _lockstepMaxSteps;
  28401. /**
  28402. * Observable signaled when a context lost event is raised
  28403. */
  28404. onContextLostObservable: Observable<Engine>;
  28405. /**
  28406. * Observable signaled when a context restored event is raised
  28407. */
  28408. onContextRestoredObservable: Observable<Engine>;
  28409. private _onContextLost;
  28410. private _onContextRestored;
  28411. private _contextWasLost;
  28412. /** @hidden */
  28413. _doNotHandleContextLost: boolean;
  28414. /**
  28415. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28416. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28417. */
  28418. doNotHandleContextLost: boolean;
  28419. private _performanceMonitor;
  28420. private _fps;
  28421. private _deltaTime;
  28422. /**
  28423. * Turn this value on if you want to pause FPS computation when in background
  28424. */
  28425. disablePerformanceMonitorInBackground: boolean;
  28426. /**
  28427. * Gets the performance monitor attached to this engine
  28428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28429. */
  28430. readonly performanceMonitor: PerformanceMonitor;
  28431. /**
  28432. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28433. */
  28434. disableVertexArrayObjects: boolean;
  28435. /** @hidden */
  28436. protected _depthCullingState: _DepthCullingState;
  28437. /** @hidden */
  28438. protected _stencilState: _StencilState;
  28439. /** @hidden */
  28440. protected _alphaState: _AlphaState;
  28441. /** @hidden */
  28442. protected _alphaMode: number;
  28443. /** @hidden */
  28444. _internalTexturesCache: InternalTexture[];
  28445. /** @hidden */
  28446. protected _activeChannel: number;
  28447. private _currentTextureChannel;
  28448. /** @hidden */
  28449. protected _boundTexturesCache: {
  28450. [key: string]: Nullable<InternalTexture>;
  28451. };
  28452. /** @hidden */
  28453. protected _currentEffect: Nullable<Effect>;
  28454. /** @hidden */
  28455. protected _currentProgram: Nullable<WebGLProgram>;
  28456. private _compiledEffects;
  28457. private _vertexAttribArraysEnabled;
  28458. /** @hidden */
  28459. protected _cachedViewport: Nullable<Viewport>;
  28460. private _cachedVertexArrayObject;
  28461. /** @hidden */
  28462. protected _cachedVertexBuffers: any;
  28463. /** @hidden */
  28464. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28465. /** @hidden */
  28466. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28467. /** @hidden */
  28468. _currentRenderTarget: Nullable<InternalTexture>;
  28469. private _uintIndicesCurrentlySet;
  28470. private _currentBoundBuffer;
  28471. /** @hidden */
  28472. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28473. private _currentBufferPointers;
  28474. private _currentInstanceLocations;
  28475. private _currentInstanceBuffers;
  28476. private _textureUnits;
  28477. /** @hidden */
  28478. _workingCanvas: Nullable<HTMLCanvasElement>;
  28479. /** @hidden */
  28480. _workingContext: Nullable<CanvasRenderingContext2D>;
  28481. private _rescalePostProcess;
  28482. private _dummyFramebuffer;
  28483. private _externalData;
  28484. /** @hidden */
  28485. _bindedRenderFunction: any;
  28486. private _vaoRecordInProgress;
  28487. private _mustWipeVertexAttributes;
  28488. private _emptyTexture;
  28489. private _emptyCubeTexture;
  28490. private _emptyTexture3D;
  28491. /** @hidden */
  28492. _frameHandler: number;
  28493. private _nextFreeTextureSlots;
  28494. private _maxSimultaneousTextures;
  28495. private _activeRequests;
  28496. private _texturesSupported;
  28497. /** @hidden */
  28498. _textureFormatInUse: Nullable<string>;
  28499. /**
  28500. * Gets the list of texture formats supported
  28501. */
  28502. readonly texturesSupported: Array<string>;
  28503. /**
  28504. * Gets the list of texture formats in use
  28505. */
  28506. readonly textureFormatInUse: Nullable<string>;
  28507. /**
  28508. * Gets the current viewport
  28509. */
  28510. readonly currentViewport: Nullable<Viewport>;
  28511. /**
  28512. * Gets the default empty texture
  28513. */
  28514. readonly emptyTexture: InternalTexture;
  28515. /**
  28516. * Gets the default empty 3D texture
  28517. */
  28518. readonly emptyTexture3D: InternalTexture;
  28519. /**
  28520. * Gets the default empty cube texture
  28521. */
  28522. readonly emptyCubeTexture: InternalTexture;
  28523. /**
  28524. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28525. */
  28526. readonly premultipliedAlpha: boolean;
  28527. /**
  28528. * Creates a new engine
  28529. * @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
  28530. * @param antialias defines enable antialiasing (default: false)
  28531. * @param options defines further options to be sent to the getContext() function
  28532. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28533. */
  28534. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28535. /**
  28536. * Initializes a webVR display and starts listening to display change events
  28537. * The onVRDisplayChangedObservable will be notified upon these changes
  28538. * @returns The onVRDisplayChangedObservable
  28539. */
  28540. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28541. /** @hidden */
  28542. _prepareVRComponent(): void;
  28543. /** @hidden */
  28544. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28545. /** @hidden */
  28546. _submitVRFrame(): void;
  28547. /**
  28548. * Call this function to leave webVR mode
  28549. * Will do nothing if webVR is not supported or if there is no webVR device
  28550. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28551. */
  28552. disableVR(): void;
  28553. /**
  28554. * Gets a boolean indicating that the system is in VR mode and is presenting
  28555. * @returns true if VR mode is engaged
  28556. */
  28557. isVRPresenting(): boolean;
  28558. /** @hidden */
  28559. _requestVRFrame(): void;
  28560. private _disableTouchAction;
  28561. private _rebuildInternalTextures;
  28562. private _rebuildEffects;
  28563. /**
  28564. * Gets a boolean indicating if all created effects are ready
  28565. * @returns true if all effects are ready
  28566. */
  28567. areAllEffectsReady(): boolean;
  28568. private _rebuildBuffers;
  28569. private _initGLContext;
  28570. /**
  28571. * Gets version of the current webGL context
  28572. */
  28573. readonly webGLVersion: number;
  28574. /**
  28575. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28576. */
  28577. readonly isStencilEnable: boolean;
  28578. /** @hidden */
  28579. _prepareWorkingCanvas(): void;
  28580. /**
  28581. * Reset the texture cache to empty state
  28582. */
  28583. resetTextureCache(): void;
  28584. /**
  28585. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28586. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28587. * @returns true if engine is in deterministic lock step mode
  28588. */
  28589. isDeterministicLockStep(): boolean;
  28590. /**
  28591. * Gets the max steps when engine is running in deterministic lock step
  28592. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28593. * @returns the max steps
  28594. */
  28595. getLockstepMaxSteps(): number;
  28596. /**
  28597. * Gets an object containing information about the current webGL context
  28598. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28599. */
  28600. getGlInfo(): {
  28601. vendor: string;
  28602. renderer: string;
  28603. version: string;
  28604. };
  28605. /**
  28606. * Gets current aspect ratio
  28607. * @param camera defines the camera to use to get the aspect ratio
  28608. * @param useScreen defines if screen size must be used (or the current render target if any)
  28609. * @returns a number defining the aspect ratio
  28610. */
  28611. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28612. /**
  28613. * Gets current screen aspect ratio
  28614. * @returns a number defining the aspect ratio
  28615. */
  28616. getScreenAspectRatio(): number;
  28617. /**
  28618. * Gets the current render width
  28619. * @param useScreen defines if screen size must be used (or the current render target if any)
  28620. * @returns a number defining the current render width
  28621. */
  28622. getRenderWidth(useScreen?: boolean): number;
  28623. /**
  28624. * Gets the current render height
  28625. * @param useScreen defines if screen size must be used (or the current render target if any)
  28626. * @returns a number defining the current render height
  28627. */
  28628. getRenderHeight(useScreen?: boolean): number;
  28629. /**
  28630. * Gets the HTML canvas attached with the current webGL context
  28631. * @returns a HTML canvas
  28632. */
  28633. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28634. /**
  28635. * Gets the client rect of the HTML canvas attached with the current webGL context
  28636. * @returns a client rectanglee
  28637. */
  28638. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28639. /**
  28640. * Defines the hardware scaling level.
  28641. * By default the hardware scaling level is computed from the window device ratio.
  28642. * 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.
  28643. * @param level defines the level to use
  28644. */
  28645. setHardwareScalingLevel(level: number): void;
  28646. /**
  28647. * Gets the current hardware scaling level.
  28648. * By default the hardware scaling level is computed from the window device ratio.
  28649. * 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.
  28650. * @returns a number indicating the current hardware scaling level
  28651. */
  28652. getHardwareScalingLevel(): number;
  28653. /**
  28654. * Gets the list of loaded textures
  28655. * @returns an array containing all loaded textures
  28656. */
  28657. getLoadedTexturesCache(): InternalTexture[];
  28658. /**
  28659. * Gets the object containing all engine capabilities
  28660. * @returns the EngineCapabilities object
  28661. */
  28662. getCaps(): EngineCapabilities;
  28663. /**
  28664. * Gets the current depth function
  28665. * @returns a number defining the depth function
  28666. */
  28667. getDepthFunction(): Nullable<number>;
  28668. /**
  28669. * Sets the current depth function
  28670. * @param depthFunc defines the function to use
  28671. */
  28672. setDepthFunction(depthFunc: number): void;
  28673. /**
  28674. * Sets the current depth function to GREATER
  28675. */
  28676. setDepthFunctionToGreater(): void;
  28677. /**
  28678. * Sets the current depth function to GEQUAL
  28679. */
  28680. setDepthFunctionToGreaterOrEqual(): void;
  28681. /**
  28682. * Sets the current depth function to LESS
  28683. */
  28684. setDepthFunctionToLess(): void;
  28685. private _cachedStencilBuffer;
  28686. private _cachedStencilFunction;
  28687. private _cachedStencilMask;
  28688. private _cachedStencilOperationPass;
  28689. private _cachedStencilOperationFail;
  28690. private _cachedStencilOperationDepthFail;
  28691. private _cachedStencilReference;
  28692. /**
  28693. * Caches the the state of the stencil buffer
  28694. */
  28695. cacheStencilState(): void;
  28696. /**
  28697. * Restores the state of the stencil buffer
  28698. */
  28699. restoreStencilState(): void;
  28700. /**
  28701. * Sets the current depth function to LEQUAL
  28702. */
  28703. setDepthFunctionToLessOrEqual(): void;
  28704. /**
  28705. * Gets a boolean indicating if stencil buffer is enabled
  28706. * @returns the current stencil buffer state
  28707. */
  28708. getStencilBuffer(): boolean;
  28709. /**
  28710. * Enable or disable the stencil buffer
  28711. * @param enable defines if the stencil buffer must be enabled or disabled
  28712. */
  28713. setStencilBuffer(enable: boolean): void;
  28714. /**
  28715. * Gets the current stencil mask
  28716. * @returns a number defining the new stencil mask to use
  28717. */
  28718. getStencilMask(): number;
  28719. /**
  28720. * Sets the current stencil mask
  28721. * @param mask defines the new stencil mask to use
  28722. */
  28723. setStencilMask(mask: number): void;
  28724. /**
  28725. * Gets the current stencil function
  28726. * @returns a number defining the stencil function to use
  28727. */
  28728. getStencilFunction(): number;
  28729. /**
  28730. * Gets the current stencil reference value
  28731. * @returns a number defining the stencil reference value to use
  28732. */
  28733. getStencilFunctionReference(): number;
  28734. /**
  28735. * Gets the current stencil mask
  28736. * @returns a number defining the stencil mask to use
  28737. */
  28738. getStencilFunctionMask(): number;
  28739. /**
  28740. * Sets the current stencil function
  28741. * @param stencilFunc defines the new stencil function to use
  28742. */
  28743. setStencilFunction(stencilFunc: number): void;
  28744. /**
  28745. * Sets the current stencil reference
  28746. * @param reference defines the new stencil reference to use
  28747. */
  28748. setStencilFunctionReference(reference: number): void;
  28749. /**
  28750. * Sets the current stencil mask
  28751. * @param mask defines the new stencil mask to use
  28752. */
  28753. setStencilFunctionMask(mask: number): void;
  28754. /**
  28755. * Gets the current stencil operation when stencil fails
  28756. * @returns a number defining stencil operation to use when stencil fails
  28757. */
  28758. getStencilOperationFail(): number;
  28759. /**
  28760. * Gets the current stencil operation when depth fails
  28761. * @returns a number defining stencil operation to use when depth fails
  28762. */
  28763. getStencilOperationDepthFail(): number;
  28764. /**
  28765. * Gets the current stencil operation when stencil passes
  28766. * @returns a number defining stencil operation to use when stencil passes
  28767. */
  28768. getStencilOperationPass(): number;
  28769. /**
  28770. * Sets the stencil operation to use when stencil fails
  28771. * @param operation defines the stencil operation to use when stencil fails
  28772. */
  28773. setStencilOperationFail(operation: number): void;
  28774. /**
  28775. * Sets the stencil operation to use when depth fails
  28776. * @param operation defines the stencil operation to use when depth fails
  28777. */
  28778. setStencilOperationDepthFail(operation: number): void;
  28779. /**
  28780. * Sets the stencil operation to use when stencil passes
  28781. * @param operation defines the stencil operation to use when stencil passes
  28782. */
  28783. setStencilOperationPass(operation: number): void;
  28784. /**
  28785. * Sets a boolean indicating if the dithering state is enabled or disabled
  28786. * @param value defines the dithering state
  28787. */
  28788. setDitheringState(value: boolean): void;
  28789. /**
  28790. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28791. * @param value defines the rasterizer state
  28792. */
  28793. setRasterizerState(value: boolean): void;
  28794. /**
  28795. * stop executing a render loop function and remove it from the execution array
  28796. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28797. */
  28798. stopRenderLoop(renderFunction?: () => void): void;
  28799. /** @hidden */
  28800. _renderLoop(): void;
  28801. /**
  28802. * Register and execute a render loop. The engine can have more than one render function
  28803. * @param renderFunction defines the function to continuously execute
  28804. */
  28805. runRenderLoop(renderFunction: () => void): void;
  28806. /**
  28807. * Toggle full screen mode
  28808. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28809. */
  28810. switchFullscreen(requestPointerLock: boolean): void;
  28811. /**
  28812. * Enters full screen mode
  28813. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28814. */
  28815. enterFullscreen(requestPointerLock: boolean): void;
  28816. /**
  28817. * Exits full screen mode
  28818. */
  28819. exitFullscreen(): void;
  28820. /**
  28821. * Clear the current render buffer or the current render target (if any is set up)
  28822. * @param color defines the color to use
  28823. * @param backBuffer defines if the back buffer must be cleared
  28824. * @param depth defines if the depth buffer must be cleared
  28825. * @param stencil defines if the stencil buffer must be cleared
  28826. */
  28827. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28828. /**
  28829. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28830. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28831. * @param y defines the y-coordinate of the corner of the clear rectangle
  28832. * @param width defines the width of the clear rectangle
  28833. * @param height defines the height of the clear rectangle
  28834. * @param clearColor defines the clear color
  28835. */
  28836. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28837. /**
  28838. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28839. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28840. * @param y defines the y-coordinate of the corner of the clear rectangle
  28841. * @param width defines the width of the clear rectangle
  28842. * @param height defines the height of the clear rectangle
  28843. */
  28844. enableScissor(x: number, y: number, width: number, height: number): void;
  28845. /**
  28846. * Disable previously set scissor test rectangle
  28847. */
  28848. disableScissor(): void;
  28849. private _viewportCached;
  28850. /** @hidden */
  28851. _viewport(x: number, y: number, width: number, height: number): void;
  28852. /**
  28853. * Set the WebGL's viewport
  28854. * @param viewport defines the viewport element to be used
  28855. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28856. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28857. */
  28858. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28859. /**
  28860. * Directly set the WebGL Viewport
  28861. * @param x defines the x coordinate of the viewport (in screen space)
  28862. * @param y defines the y coordinate of the viewport (in screen space)
  28863. * @param width defines the width of the viewport (in screen space)
  28864. * @param height defines the height of the viewport (in screen space)
  28865. * @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
  28866. */
  28867. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28868. /**
  28869. * Begin a new frame
  28870. */
  28871. beginFrame(): void;
  28872. /**
  28873. * Enf the current frame
  28874. */
  28875. endFrame(): void;
  28876. /**
  28877. * Resize the view according to the canvas' size
  28878. */
  28879. resize(): void;
  28880. /**
  28881. * Force a specific size of the canvas
  28882. * @param width defines the new canvas' width
  28883. * @param height defines the new canvas' height
  28884. */
  28885. setSize(width: number, height: number): void;
  28886. /**
  28887. * Binds the frame buffer to the specified texture.
  28888. * @param texture The texture to render to or null for the default canvas
  28889. * @param faceIndex The face of the texture to render to in case of cube texture
  28890. * @param requiredWidth The width of the target to render to
  28891. * @param requiredHeight The height of the target to render to
  28892. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28893. * @param depthStencilTexture The depth stencil texture to use to render
  28894. * @param lodLevel defines le lod level to bind to the frame buffer
  28895. */
  28896. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28897. /** @hidden */
  28898. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28899. /**
  28900. * Unbind the current render target texture from the webGL context
  28901. * @param texture defines the render target texture to unbind
  28902. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28903. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28904. */
  28905. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28906. /**
  28907. * Force the mipmap generation for the given render target texture
  28908. * @param texture defines the render target texture to use
  28909. */
  28910. generateMipMapsForCubemap(texture: InternalTexture): void;
  28911. /**
  28912. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28913. */
  28914. flushFramebuffer(): void;
  28915. /**
  28916. * Unbind the current render target and bind the default framebuffer
  28917. */
  28918. restoreDefaultFramebuffer(): void;
  28919. /**
  28920. * Create an uniform buffer
  28921. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28922. * @param elements defines the content of the uniform buffer
  28923. * @returns the webGL uniform buffer
  28924. */
  28925. createUniformBuffer(elements: FloatArray): DataBuffer;
  28926. /**
  28927. * Create a dynamic uniform buffer
  28928. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28929. * @param elements defines the content of the uniform buffer
  28930. * @returns the webGL uniform buffer
  28931. */
  28932. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28933. /**
  28934. * Update an existing uniform buffer
  28935. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28936. * @param uniformBuffer defines the target uniform buffer
  28937. * @param elements defines the content to update
  28938. * @param offset defines the offset in the uniform buffer where update should start
  28939. * @param count defines the size of the data to update
  28940. */
  28941. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28942. private _resetVertexBufferBinding;
  28943. /**
  28944. * Creates a vertex buffer
  28945. * @param data the data for the vertex buffer
  28946. * @returns the new WebGL static buffer
  28947. */
  28948. createVertexBuffer(data: DataArray): DataBuffer;
  28949. /**
  28950. * Creates a dynamic vertex buffer
  28951. * @param data the data for the dynamic vertex buffer
  28952. * @returns the new WebGL dynamic buffer
  28953. */
  28954. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28955. /**
  28956. * Update a dynamic index buffer
  28957. * @param indexBuffer defines the target index buffer
  28958. * @param indices defines the data to update
  28959. * @param offset defines the offset in the target index buffer where update should start
  28960. */
  28961. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28962. /**
  28963. * Updates a dynamic vertex buffer.
  28964. * @param vertexBuffer the vertex buffer to update
  28965. * @param data the data used to update the vertex buffer
  28966. * @param byteOffset the byte offset of the data
  28967. * @param byteLength the byte length of the data
  28968. */
  28969. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28970. private _resetIndexBufferBinding;
  28971. /**
  28972. * Creates a new index buffer
  28973. * @param indices defines the content of the index buffer
  28974. * @param updatable defines if the index buffer must be updatable
  28975. * @returns a new webGL buffer
  28976. */
  28977. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28978. /**
  28979. * Bind a webGL buffer to the webGL context
  28980. * @param buffer defines the buffer to bind
  28981. */
  28982. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28983. /**
  28984. * Bind an uniform buffer to the current webGL context
  28985. * @param buffer defines the buffer to bind
  28986. */
  28987. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28988. /**
  28989. * Bind a buffer to the current webGL context at a given location
  28990. * @param buffer defines the buffer to bind
  28991. * @param location defines the index where to bind the buffer
  28992. */
  28993. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28994. /**
  28995. * Bind a specific block at a given index in a specific shader program
  28996. * @param pipelineContext defines the pipeline context to use
  28997. * @param blockName defines the block name
  28998. * @param index defines the index where to bind the block
  28999. */
  29000. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29001. private bindIndexBuffer;
  29002. private bindBuffer;
  29003. /**
  29004. * update the bound buffer with the given data
  29005. * @param data defines the data to update
  29006. */
  29007. updateArrayBuffer(data: Float32Array): void;
  29008. private _vertexAttribPointer;
  29009. private _bindIndexBufferWithCache;
  29010. private _bindVertexBuffersAttributes;
  29011. /**
  29012. * Records a vertex array object
  29013. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29014. * @param vertexBuffers defines the list of vertex buffers to store
  29015. * @param indexBuffer defines the index buffer to store
  29016. * @param effect defines the effect to store
  29017. * @returns the new vertex array object
  29018. */
  29019. recordVertexArrayObject(vertexBuffers: {
  29020. [key: string]: VertexBuffer;
  29021. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29022. /**
  29023. * Bind a specific vertex array object
  29024. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29025. * @param vertexArrayObject defines the vertex array object to bind
  29026. * @param indexBuffer defines the index buffer to bind
  29027. */
  29028. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29029. /**
  29030. * Bind webGl buffers directly to the webGL context
  29031. * @param vertexBuffer defines the vertex buffer to bind
  29032. * @param indexBuffer defines the index buffer to bind
  29033. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29034. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29035. * @param effect defines the effect associated with the vertex buffer
  29036. */
  29037. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29038. private _unbindVertexArrayObject;
  29039. /**
  29040. * Bind a list of vertex buffers to the webGL context
  29041. * @param vertexBuffers defines the list of vertex buffers to bind
  29042. * @param indexBuffer defines the index buffer to bind
  29043. * @param effect defines the effect associated with the vertex buffers
  29044. */
  29045. bindBuffers(vertexBuffers: {
  29046. [key: string]: Nullable<VertexBuffer>;
  29047. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29048. /**
  29049. * Unbind all instance attributes
  29050. */
  29051. unbindInstanceAttributes(): void;
  29052. /**
  29053. * Release and free the memory of a vertex array object
  29054. * @param vao defines the vertex array object to delete
  29055. */
  29056. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29057. /** @hidden */
  29058. _releaseBuffer(buffer: DataBuffer): boolean;
  29059. /**
  29060. * Creates a webGL buffer to use with instanciation
  29061. * @param capacity defines the size of the buffer
  29062. * @returns the webGL buffer
  29063. */
  29064. createInstancesBuffer(capacity: number): DataBuffer;
  29065. /**
  29066. * Delete a webGL buffer used with instanciation
  29067. * @param buffer defines the webGL buffer to delete
  29068. */
  29069. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29070. /**
  29071. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29072. * @param instancesBuffer defines the webGL buffer to update and bind
  29073. * @param data defines the data to store in the buffer
  29074. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29075. */
  29076. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29077. /**
  29078. * Apply all cached states (depth, culling, stencil and alpha)
  29079. */
  29080. applyStates(): void;
  29081. /**
  29082. * Send a draw order
  29083. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29084. * @param indexStart defines the starting index
  29085. * @param indexCount defines the number of index to draw
  29086. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29087. */
  29088. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29089. /**
  29090. * Draw a list of points
  29091. * @param verticesStart defines the index of first vertex to draw
  29092. * @param verticesCount defines the count of vertices to draw
  29093. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29094. */
  29095. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29096. /**
  29097. * Draw a list of unindexed primitives
  29098. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29099. * @param verticesStart defines the index of first vertex to draw
  29100. * @param verticesCount defines the count of vertices to draw
  29101. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29102. */
  29103. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29104. /**
  29105. * Draw a list of indexed primitives
  29106. * @param fillMode defines the primitive to use
  29107. * @param indexStart defines the starting index
  29108. * @param indexCount defines the number of index to draw
  29109. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29110. */
  29111. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29112. /**
  29113. * Draw a list of unindexed primitives
  29114. * @param fillMode defines the primitive to use
  29115. * @param verticesStart defines the index of first vertex to draw
  29116. * @param verticesCount defines the count of vertices to draw
  29117. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29118. */
  29119. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29120. private _drawMode;
  29121. /** @hidden */
  29122. _releaseEffect(effect: Effect): void;
  29123. /** @hidden */
  29124. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29125. /**
  29126. * Create a new effect (used to store vertex/fragment shaders)
  29127. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29128. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29129. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29130. * @param samplers defines an array of string used to represent textures
  29131. * @param defines defines the string containing the defines to use to compile the shaders
  29132. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29133. * @param onCompiled defines a function to call when the effect creation is successful
  29134. * @param onError defines a function to call when the effect creation has failed
  29135. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29136. * @returns the new Effect
  29137. */
  29138. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29139. private _compileShader;
  29140. private _compileRawShader;
  29141. /**
  29142. * Directly creates a webGL program
  29143. * @param pipelineContext defines the pipeline context to attach to
  29144. * @param vertexCode defines the vertex shader code to use
  29145. * @param fragmentCode defines the fragment shader code to use
  29146. * @param context defines the webGL context to use (if not set, the current one will be used)
  29147. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29148. * @returns the new webGL program
  29149. */
  29150. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29151. /**
  29152. * Creates a webGL program
  29153. * @param pipelineContext defines the pipeline context to attach to
  29154. * @param vertexCode defines the vertex shader code to use
  29155. * @param fragmentCode defines the fragment shader code to use
  29156. * @param defines defines the string containing the defines to use to compile the shaders
  29157. * @param context defines the webGL context to use (if not set, the current one will be used)
  29158. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29159. * @returns the new webGL program
  29160. */
  29161. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29162. /**
  29163. * Creates a new pipeline context
  29164. * @returns the new pipeline
  29165. */
  29166. createPipelineContext(): WebGLPipelineContext;
  29167. private _createShaderProgram;
  29168. private _finalizePipelineContext;
  29169. /** @hidden */
  29170. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29171. /** @hidden */
  29172. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29173. /** @hidden */
  29174. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29175. /**
  29176. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29177. * @param pipelineContext defines the pipeline context to use
  29178. * @param uniformsNames defines the list of uniform names
  29179. * @returns an array of webGL uniform locations
  29180. */
  29181. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29182. /**
  29183. * Gets the lsit of active attributes for a given webGL program
  29184. * @param pipelineContext defines the pipeline context to use
  29185. * @param attributesNames defines the list of attribute names to get
  29186. * @returns an array of indices indicating the offset of each attribute
  29187. */
  29188. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29189. /**
  29190. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29191. * @param effect defines the effect to activate
  29192. */
  29193. enableEffect(effect: Nullable<Effect>): void;
  29194. /**
  29195. * Set the value of an uniform to an array of int32
  29196. * @param uniform defines the webGL uniform location where to store the value
  29197. * @param array defines the array of int32 to store
  29198. */
  29199. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29200. /**
  29201. * Set the value of an uniform to an array of int32 (stored as vec2)
  29202. * @param uniform defines the webGL uniform location where to store the value
  29203. * @param array defines the array of int32 to store
  29204. */
  29205. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29206. /**
  29207. * Set the value of an uniform to an array of int32 (stored as vec3)
  29208. * @param uniform defines the webGL uniform location where to store the value
  29209. * @param array defines the array of int32 to store
  29210. */
  29211. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29212. /**
  29213. * Set the value of an uniform to an array of int32 (stored as vec4)
  29214. * @param uniform defines the webGL uniform location where to store the value
  29215. * @param array defines the array of int32 to store
  29216. */
  29217. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29218. /**
  29219. * Set the value of an uniform to an array of float32
  29220. * @param uniform defines the webGL uniform location where to store the value
  29221. * @param array defines the array of float32 to store
  29222. */
  29223. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29224. /**
  29225. * Set the value of an uniform to an array of float32 (stored as vec2)
  29226. * @param uniform defines the webGL uniform location where to store the value
  29227. * @param array defines the array of float32 to store
  29228. */
  29229. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29230. /**
  29231. * Set the value of an uniform to an array of float32 (stored as vec3)
  29232. * @param uniform defines the webGL uniform location where to store the value
  29233. * @param array defines the array of float32 to store
  29234. */
  29235. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29236. /**
  29237. * Set the value of an uniform to an array of float32 (stored as vec4)
  29238. * @param uniform defines the webGL uniform location where to store the value
  29239. * @param array defines the array of float32 to store
  29240. */
  29241. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29242. /**
  29243. * Set the value of an uniform to an array of number
  29244. * @param uniform defines the webGL uniform location where to store the value
  29245. * @param array defines the array of number to store
  29246. */
  29247. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29248. /**
  29249. * Set the value of an uniform to an array of number (stored as vec2)
  29250. * @param uniform defines the webGL uniform location where to store the value
  29251. * @param array defines the array of number to store
  29252. */
  29253. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29254. /**
  29255. * Set the value of an uniform to an array of number (stored as vec3)
  29256. * @param uniform defines the webGL uniform location where to store the value
  29257. * @param array defines the array of number to store
  29258. */
  29259. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29260. /**
  29261. * Set the value of an uniform to an array of number (stored as vec4)
  29262. * @param uniform defines the webGL uniform location where to store the value
  29263. * @param array defines the array of number to store
  29264. */
  29265. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29266. /**
  29267. * Set the value of an uniform to an array of float32 (stored as matrices)
  29268. * @param uniform defines the webGL uniform location where to store the value
  29269. * @param matrices defines the array of float32 to store
  29270. */
  29271. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29272. /**
  29273. * Set the value of an uniform to a matrix
  29274. * @param uniform defines the webGL uniform location where to store the value
  29275. * @param matrix defines the matrix to store
  29276. */
  29277. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29278. /**
  29279. * Set the value of an uniform to a matrix (3x3)
  29280. * @param uniform defines the webGL uniform location where to store the value
  29281. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29282. */
  29283. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29284. /**
  29285. * Set the value of an uniform to a matrix (2x2)
  29286. * @param uniform defines the webGL uniform location where to store the value
  29287. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29288. */
  29289. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29290. /**
  29291. * Set the value of an uniform to a number (int)
  29292. * @param uniform defines the webGL uniform location where to store the value
  29293. * @param value defines the int number to store
  29294. */
  29295. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29296. /**
  29297. * Set the value of an uniform to a number (float)
  29298. * @param uniform defines the webGL uniform location where to store the value
  29299. * @param value defines the float number to store
  29300. */
  29301. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29302. /**
  29303. * Set the value of an uniform to a vec2
  29304. * @param uniform defines the webGL uniform location where to store the value
  29305. * @param x defines the 1st component of the value
  29306. * @param y defines the 2nd component of the value
  29307. */
  29308. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29309. /**
  29310. * Set the value of an uniform to a vec3
  29311. * @param uniform defines the webGL uniform location where to store the value
  29312. * @param x defines the 1st component of the value
  29313. * @param y defines the 2nd component of the value
  29314. * @param z defines the 3rd component of the value
  29315. */
  29316. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29317. /**
  29318. * Set the value of an uniform to a boolean
  29319. * @param uniform defines the webGL uniform location where to store the value
  29320. * @param bool defines the boolean to store
  29321. */
  29322. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29323. /**
  29324. * Set the value of an uniform to a vec4
  29325. * @param uniform defines the webGL uniform location where to store the value
  29326. * @param x defines the 1st component of the value
  29327. * @param y defines the 2nd component of the value
  29328. * @param z defines the 3rd component of the value
  29329. * @param w defines the 4th component of the value
  29330. */
  29331. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29332. /**
  29333. * Set the value of an uniform to a Color3
  29334. * @param uniform defines the webGL uniform location where to store the value
  29335. * @param color3 defines the color to store
  29336. */
  29337. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29338. /**
  29339. * Set the value of an uniform to a Color3 and an alpha value
  29340. * @param uniform defines the webGL uniform location where to store the value
  29341. * @param color3 defines the color to store
  29342. * @param alpha defines the alpha component to store
  29343. */
  29344. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29345. /**
  29346. * Sets a Color4 on a uniform variable
  29347. * @param uniform defines the uniform location
  29348. * @param color4 defines the value to be set
  29349. */
  29350. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29351. /**
  29352. * Set various states to the webGL context
  29353. * @param culling defines backface culling state
  29354. * @param zOffset defines the value to apply to zOffset (0 by default)
  29355. * @param force defines if states must be applied even if cache is up to date
  29356. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29357. */
  29358. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29359. /**
  29360. * Set the z offset to apply to current rendering
  29361. * @param value defines the offset to apply
  29362. */
  29363. setZOffset(value: number): void;
  29364. /**
  29365. * Gets the current value of the zOffset
  29366. * @returns the current zOffset state
  29367. */
  29368. getZOffset(): number;
  29369. /**
  29370. * Enable or disable depth buffering
  29371. * @param enable defines the state to set
  29372. */
  29373. setDepthBuffer(enable: boolean): void;
  29374. /**
  29375. * Gets a boolean indicating if depth writing is enabled
  29376. * @returns the current depth writing state
  29377. */
  29378. getDepthWrite(): boolean;
  29379. /**
  29380. * Enable or disable depth writing
  29381. * @param enable defines the state to set
  29382. */
  29383. setDepthWrite(enable: boolean): void;
  29384. /**
  29385. * Enable or disable color writing
  29386. * @param enable defines the state to set
  29387. */
  29388. setColorWrite(enable: boolean): void;
  29389. /**
  29390. * Gets a boolean indicating if color writing is enabled
  29391. * @returns the current color writing state
  29392. */
  29393. getColorWrite(): boolean;
  29394. /**
  29395. * Sets alpha constants used by some alpha blending modes
  29396. * @param r defines the red component
  29397. * @param g defines the green component
  29398. * @param b defines the blue component
  29399. * @param a defines the alpha component
  29400. */
  29401. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29402. /**
  29403. * Sets the current alpha mode
  29404. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29405. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29406. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29407. */
  29408. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29409. /**
  29410. * Gets the current alpha mode
  29411. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29412. * @returns the current alpha mode
  29413. */
  29414. getAlphaMode(): number;
  29415. /**
  29416. * Clears the list of texture accessible through engine.
  29417. * This can help preventing texture load conflict due to name collision.
  29418. */
  29419. clearInternalTexturesCache(): void;
  29420. /**
  29421. * Force the entire cache to be cleared
  29422. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29423. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29424. */
  29425. wipeCaches(bruteForce?: boolean): void;
  29426. /**
  29427. * Set the compressed texture format to use, based on the formats you have, and the formats
  29428. * supported by the hardware / browser.
  29429. *
  29430. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29431. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29432. * to API arguments needed to compressed textures. This puts the burden on the container
  29433. * generator to house the arcane code for determining these for current & future formats.
  29434. *
  29435. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29436. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29437. *
  29438. * Note: The result of this call is not taken into account when a texture is base64.
  29439. *
  29440. * @param formatsAvailable defines the list of those format families you have created
  29441. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29442. *
  29443. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29444. * @returns The extension selected.
  29445. */
  29446. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29447. /** @hidden */
  29448. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29449. min: number;
  29450. mag: number;
  29451. };
  29452. /** @hidden */
  29453. _createTexture(): WebGLTexture;
  29454. /**
  29455. * Usually called from Texture.ts.
  29456. * Passed information to create a WebGLTexture
  29457. * @param urlArg defines a value which contains one of the following:
  29458. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29459. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29460. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29461. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29462. * @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)
  29463. * @param scene needed for loading to the correct scene
  29464. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29465. * @param onLoad optional callback to be called upon successful completion
  29466. * @param onError optional callback to be called upon failure
  29467. * @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
  29468. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29469. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29470. * @param forcedExtension defines the extension to use to pick the right loader
  29471. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29472. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29473. */
  29474. 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;
  29475. private _rescaleTexture;
  29476. private _unpackFlipYCached;
  29477. /**
  29478. * In case you are sharing the context with other applications, it might
  29479. * be interested to not cache the unpack flip y state to ensure a consistent
  29480. * value would be set.
  29481. */
  29482. enableUnpackFlipYCached: boolean;
  29483. /** @hidden */
  29484. _unpackFlipY(value: boolean): void;
  29485. /** @hidden */
  29486. _getUnpackAlignement(): number;
  29487. /**
  29488. * Creates a dynamic texture
  29489. * @param width defines the width of the texture
  29490. * @param height defines the height of the texture
  29491. * @param generateMipMaps defines if the engine should generate the mip levels
  29492. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29493. * @returns the dynamic texture inside an InternalTexture
  29494. */
  29495. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29496. /**
  29497. * Update the sampling mode of a given texture
  29498. * @param samplingMode defines the required sampling mode
  29499. * @param texture defines the texture to update
  29500. */
  29501. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29502. /**
  29503. * Update the content of a dynamic texture
  29504. * @param texture defines the texture to update
  29505. * @param canvas defines the canvas containing the source
  29506. * @param invertY defines if data must be stored with Y axis inverted
  29507. * @param premulAlpha defines if alpha is stored as premultiplied
  29508. * @param format defines the format of the data
  29509. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29510. */
  29511. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29512. /**
  29513. * Update a video texture
  29514. * @param texture defines the texture to update
  29515. * @param video defines the video element to use
  29516. * @param invertY defines if data must be stored with Y axis inverted
  29517. */
  29518. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29519. /**
  29520. * Updates a depth texture Comparison Mode and Function.
  29521. * If the comparison Function is equal to 0, the mode will be set to none.
  29522. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29523. * @param texture The texture to set the comparison function for
  29524. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29525. */
  29526. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29527. /** @hidden */
  29528. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29529. width: number;
  29530. height: number;
  29531. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29532. /**
  29533. * Creates a depth stencil texture.
  29534. * This is only available in WebGL 2 or with the depth texture extension available.
  29535. * @param size The size of face edge in the texture.
  29536. * @param options The options defining the texture.
  29537. * @returns The texture
  29538. */
  29539. createDepthStencilTexture(size: number | {
  29540. width: number;
  29541. height: number;
  29542. }, options: DepthTextureCreationOptions): InternalTexture;
  29543. /**
  29544. * Creates a depth stencil texture.
  29545. * This is only available in WebGL 2 or with the depth texture extension available.
  29546. * @param size The size of face edge in the texture.
  29547. * @param options The options defining the texture.
  29548. * @returns The texture
  29549. */
  29550. private _createDepthStencilTexture;
  29551. /**
  29552. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29553. * @param renderTarget The render target to set the frame buffer for
  29554. */
  29555. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29556. /**
  29557. * Creates a new render target texture
  29558. * @param size defines the size of the texture
  29559. * @param options defines the options used to create the texture
  29560. * @returns a new render target texture stored in an InternalTexture
  29561. */
  29562. createRenderTargetTexture(size: number | {
  29563. width: number;
  29564. height: number;
  29565. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29566. /** @hidden */
  29567. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29568. /**
  29569. * Updates the sample count of a render target texture
  29570. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29571. * @param texture defines the texture to update
  29572. * @param samples defines the sample count to set
  29573. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29574. */
  29575. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29576. /** @hidden */
  29577. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29578. /** @hidden */
  29579. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29580. /** @hidden */
  29581. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29582. /** @hidden */
  29583. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29584. /**
  29585. * @hidden
  29586. */
  29587. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29588. private _prepareWebGLTextureContinuation;
  29589. private _prepareWebGLTexture;
  29590. /** @hidden */
  29591. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29592. /** @hidden */
  29593. _releaseFramebufferObjects(texture: InternalTexture): void;
  29594. /** @hidden */
  29595. _releaseTexture(texture: InternalTexture): void;
  29596. private setProgram;
  29597. private _boundUniforms;
  29598. /**
  29599. * Binds an effect to the webGL context
  29600. * @param effect defines the effect to bind
  29601. */
  29602. bindSamplers(effect: Effect): void;
  29603. private _activateCurrentTexture;
  29604. /** @hidden */
  29605. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29606. /** @hidden */
  29607. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29608. /**
  29609. * Sets a texture to the webGL context from a postprocess
  29610. * @param channel defines the channel to use
  29611. * @param postProcess defines the source postprocess
  29612. */
  29613. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29614. /**
  29615. * Binds the output of the passed in post process to the texture channel specified
  29616. * @param channel The channel the texture should be bound to
  29617. * @param postProcess The post process which's output should be bound
  29618. */
  29619. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29620. /**
  29621. * Unbind all textures from the webGL context
  29622. */
  29623. unbindAllTextures(): void;
  29624. /**
  29625. * Sets a texture to the according uniform.
  29626. * @param channel The texture channel
  29627. * @param uniform The uniform to set
  29628. * @param texture The texture to apply
  29629. */
  29630. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29631. /**
  29632. * Sets a depth stencil texture from a render target to the according uniform.
  29633. * @param channel The texture channel
  29634. * @param uniform The uniform to set
  29635. * @param texture The render target texture containing the depth stencil texture to apply
  29636. */
  29637. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29638. private _bindSamplerUniformToChannel;
  29639. private _getTextureWrapMode;
  29640. private _setTexture;
  29641. /**
  29642. * Sets an array of texture to the webGL context
  29643. * @param channel defines the channel where the texture array must be set
  29644. * @param uniform defines the associated uniform location
  29645. * @param textures defines the array of textures to bind
  29646. */
  29647. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29648. /** @hidden */
  29649. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29650. private _setTextureParameterFloat;
  29651. private _setTextureParameterInteger;
  29652. /**
  29653. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29654. * @param x defines the x coordinate of the rectangle where pixels must be read
  29655. * @param y defines the y coordinate of the rectangle where pixels must be read
  29656. * @param width defines the width of the rectangle where pixels must be read
  29657. * @param height defines the height of the rectangle where pixels must be read
  29658. * @returns a Uint8Array containing RGBA colors
  29659. */
  29660. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29661. /**
  29662. * Add an externaly attached data from its key.
  29663. * This method call will fail and return false, if such key already exists.
  29664. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29665. * @param key the unique key that identifies the data
  29666. * @param data the data object to associate to the key for this Engine instance
  29667. * @return true if no such key were already present and the data was added successfully, false otherwise
  29668. */
  29669. addExternalData<T>(key: string, data: T): boolean;
  29670. /**
  29671. * Get an externaly attached data from its key
  29672. * @param key the unique key that identifies the data
  29673. * @return the associated data, if present (can be null), or undefined if not present
  29674. */
  29675. getExternalData<T>(key: string): T;
  29676. /**
  29677. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29678. * @param key the unique key that identifies the data
  29679. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29680. * @return the associated data, can be null if the factory returned null.
  29681. */
  29682. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29683. /**
  29684. * Remove an externaly attached data from the Engine instance
  29685. * @param key the unique key that identifies the data
  29686. * @return true if the data was successfully removed, false if it doesn't exist
  29687. */
  29688. removeExternalData(key: string): boolean;
  29689. /**
  29690. * Unbind all vertex attributes from the webGL context
  29691. */
  29692. unbindAllAttributes(): void;
  29693. /**
  29694. * 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
  29695. */
  29696. releaseEffects(): void;
  29697. /**
  29698. * Dispose and release all associated resources
  29699. */
  29700. dispose(): void;
  29701. /**
  29702. * Display the loading screen
  29703. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29704. */
  29705. displayLoadingUI(): void;
  29706. /**
  29707. * Hide the loading screen
  29708. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29709. */
  29710. hideLoadingUI(): void;
  29711. /**
  29712. * Gets the current loading screen object
  29713. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29714. */
  29715. /**
  29716. * Sets the current loading screen object
  29717. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29718. */
  29719. loadingScreen: ILoadingScreen;
  29720. /**
  29721. * Sets the current loading screen text
  29722. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29723. */
  29724. loadingUIText: string;
  29725. /**
  29726. * Sets the current loading screen background color
  29727. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29728. */
  29729. loadingUIBackgroundColor: string;
  29730. /**
  29731. * Attach a new callback raised when context lost event is fired
  29732. * @param callback defines the callback to call
  29733. */
  29734. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29735. /**
  29736. * Attach a new callback raised when context restored event is fired
  29737. * @param callback defines the callback to call
  29738. */
  29739. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29740. /**
  29741. * Gets the source code of the vertex shader associated with a specific webGL program
  29742. * @param program defines the program to use
  29743. * @returns a string containing the source code of the vertex shader associated with the program
  29744. */
  29745. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29746. /**
  29747. * Gets the source code of the fragment shader associated with a specific webGL program
  29748. * @param program defines the program to use
  29749. * @returns a string containing the source code of the fragment shader associated with the program
  29750. */
  29751. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29752. /**
  29753. * Get the current error code of the webGL context
  29754. * @returns the error code
  29755. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29756. */
  29757. getError(): number;
  29758. /**
  29759. * Gets the current framerate
  29760. * @returns a number representing the framerate
  29761. */
  29762. getFps(): number;
  29763. /**
  29764. * Gets the time spent between current and previous frame
  29765. * @returns a number representing the delta time in ms
  29766. */
  29767. getDeltaTime(): number;
  29768. private _measureFps;
  29769. /** @hidden */
  29770. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29771. private _canRenderToFloatFramebuffer;
  29772. private _canRenderToHalfFloatFramebuffer;
  29773. private _canRenderToFramebuffer;
  29774. /** @hidden */
  29775. _getWebGLTextureType(type: number): number;
  29776. /** @hidden */
  29777. _getInternalFormat(format: number): number;
  29778. /** @hidden */
  29779. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29780. /** @hidden */
  29781. _getRGBAMultiSampleBufferFormat(type: number): number;
  29782. /** @hidden */
  29783. _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;
  29784. /** @hidden */
  29785. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29786. /**
  29787. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29788. * @returns true if the engine can be created
  29789. * @ignorenaming
  29790. */
  29791. static isSupported(): boolean;
  29792. }
  29793. }
  29794. declare module "babylonjs/Materials/effect" {
  29795. import { Observable } from "babylonjs/Misc/observable";
  29796. import { Nullable } from "babylonjs/types";
  29797. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29798. import { IDisposable } from "babylonjs/scene";
  29799. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29800. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29801. import { Engine } from "babylonjs/Engines/engine";
  29802. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29803. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29804. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29805. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29807. /**
  29808. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29809. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29810. */
  29811. export class EffectFallbacks {
  29812. private _defines;
  29813. private _currentRank;
  29814. private _maxRank;
  29815. private _mesh;
  29816. /**
  29817. * Removes the fallback from the bound mesh.
  29818. */
  29819. unBindMesh(): void;
  29820. /**
  29821. * Adds a fallback on the specified property.
  29822. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29823. * @param define The name of the define in the shader
  29824. */
  29825. addFallback(rank: number, define: string): void;
  29826. /**
  29827. * Sets the mesh to use CPU skinning when needing to fallback.
  29828. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29829. * @param mesh The mesh to use the fallbacks.
  29830. */
  29831. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29832. /**
  29833. * Checks to see if more fallbacks are still availible.
  29834. */
  29835. readonly isMoreFallbacks: boolean;
  29836. /**
  29837. * Removes the defines that shoould be removed when falling back.
  29838. * @param currentDefines defines the current define statements for the shader.
  29839. * @param effect defines the current effect we try to compile
  29840. * @returns The resulting defines with defines of the current rank removed.
  29841. */
  29842. reduce(currentDefines: string, effect: Effect): string;
  29843. }
  29844. /**
  29845. * Options to be used when creating an effect.
  29846. */
  29847. export class EffectCreationOptions {
  29848. /**
  29849. * Atrributes that will be used in the shader.
  29850. */
  29851. attributes: string[];
  29852. /**
  29853. * Uniform varible names that will be set in the shader.
  29854. */
  29855. uniformsNames: string[];
  29856. /**
  29857. * Uniform buffer varible names that will be set in the shader.
  29858. */
  29859. uniformBuffersNames: string[];
  29860. /**
  29861. * Sampler texture variable names that will be set in the shader.
  29862. */
  29863. samplers: string[];
  29864. /**
  29865. * Define statements that will be set in the shader.
  29866. */
  29867. defines: any;
  29868. /**
  29869. * Possible fallbacks for this effect to improve performance when needed.
  29870. */
  29871. fallbacks: Nullable<EffectFallbacks>;
  29872. /**
  29873. * Callback that will be called when the shader is compiled.
  29874. */
  29875. onCompiled: Nullable<(effect: Effect) => void>;
  29876. /**
  29877. * Callback that will be called if an error occurs during shader compilation.
  29878. */
  29879. onError: Nullable<(effect: Effect, errors: string) => void>;
  29880. /**
  29881. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29882. */
  29883. indexParameters: any;
  29884. /**
  29885. * Max number of lights that can be used in the shader.
  29886. */
  29887. maxSimultaneousLights: number;
  29888. /**
  29889. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29890. */
  29891. transformFeedbackVaryings: Nullable<string[]>;
  29892. }
  29893. /**
  29894. * Effect containing vertex and fragment shader that can be executed on an object.
  29895. */
  29896. export class Effect implements IDisposable {
  29897. /**
  29898. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29899. */
  29900. static ShadersRepository: string;
  29901. /**
  29902. * Name of the effect.
  29903. */
  29904. name: any;
  29905. /**
  29906. * String container all the define statements that should be set on the shader.
  29907. */
  29908. defines: string;
  29909. /**
  29910. * Callback that will be called when the shader is compiled.
  29911. */
  29912. onCompiled: Nullable<(effect: Effect) => void>;
  29913. /**
  29914. * Callback that will be called if an error occurs during shader compilation.
  29915. */
  29916. onError: Nullable<(effect: Effect, errors: string) => void>;
  29917. /**
  29918. * Callback that will be called when effect is bound.
  29919. */
  29920. onBind: Nullable<(effect: Effect) => void>;
  29921. /**
  29922. * Unique ID of the effect.
  29923. */
  29924. uniqueId: number;
  29925. /**
  29926. * Observable that will be called when the shader is compiled.
  29927. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29928. */
  29929. onCompileObservable: Observable<Effect>;
  29930. /**
  29931. * Observable that will be called if an error occurs during shader compilation.
  29932. */
  29933. onErrorObservable: Observable<Effect>;
  29934. /** @hidden */
  29935. _onBindObservable: Nullable<Observable<Effect>>;
  29936. /**
  29937. * Observable that will be called when effect is bound.
  29938. */
  29939. readonly onBindObservable: Observable<Effect>;
  29940. /** @hidden */
  29941. _bonesComputationForcedToCPU: boolean;
  29942. private static _uniqueIdSeed;
  29943. private _engine;
  29944. private _uniformBuffersNames;
  29945. private _uniformsNames;
  29946. private _samplerList;
  29947. private _samplers;
  29948. private _isReady;
  29949. private _compilationError;
  29950. private _attributesNames;
  29951. private _attributes;
  29952. private _uniforms;
  29953. /**
  29954. * Key for the effect.
  29955. * @hidden
  29956. */
  29957. _key: string;
  29958. private _indexParameters;
  29959. private _fallbacks;
  29960. private _vertexSourceCode;
  29961. private _fragmentSourceCode;
  29962. private _vertexSourceCodeOverride;
  29963. private _fragmentSourceCodeOverride;
  29964. private _transformFeedbackVaryings;
  29965. /**
  29966. * Compiled shader to webGL program.
  29967. * @hidden
  29968. */
  29969. _pipelineContext: Nullable<IPipelineContext>;
  29970. private _valueCache;
  29971. private static _baseCache;
  29972. /**
  29973. * Instantiates an effect.
  29974. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29975. * @param baseName Name of the effect.
  29976. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29977. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29978. * @param samplers List of sampler variables that will be passed to the shader.
  29979. * @param engine Engine to be used to render the effect
  29980. * @param defines Define statements to be added to the shader.
  29981. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29982. * @param onCompiled Callback that will be called when the shader is compiled.
  29983. * @param onError Callback that will be called if an error occurs during shader compilation.
  29984. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29985. */
  29986. 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);
  29987. /**
  29988. * Unique key for this effect
  29989. */
  29990. readonly key: string;
  29991. /**
  29992. * If the effect has been compiled and prepared.
  29993. * @returns if the effect is compiled and prepared.
  29994. */
  29995. isReady(): boolean;
  29996. /**
  29997. * The engine the effect was initialized with.
  29998. * @returns the engine.
  29999. */
  30000. getEngine(): Engine;
  30001. /**
  30002. * The pipeline context for this effect
  30003. * @returns the associated pipeline context
  30004. */
  30005. getPipelineContext(): Nullable<IPipelineContext>;
  30006. /**
  30007. * The set of names of attribute variables for the shader.
  30008. * @returns An array of attribute names.
  30009. */
  30010. getAttributesNames(): string[];
  30011. /**
  30012. * Returns the attribute at the given index.
  30013. * @param index The index of the attribute.
  30014. * @returns The location of the attribute.
  30015. */
  30016. getAttributeLocation(index: number): number;
  30017. /**
  30018. * Returns the attribute based on the name of the variable.
  30019. * @param name of the attribute to look up.
  30020. * @returns the attribute location.
  30021. */
  30022. getAttributeLocationByName(name: string): number;
  30023. /**
  30024. * The number of attributes.
  30025. * @returns the numnber of attributes.
  30026. */
  30027. getAttributesCount(): number;
  30028. /**
  30029. * Gets the index of a uniform variable.
  30030. * @param uniformName of the uniform to look up.
  30031. * @returns the index.
  30032. */
  30033. getUniformIndex(uniformName: string): number;
  30034. /**
  30035. * Returns the attribute based on the name of the variable.
  30036. * @param uniformName of the uniform to look up.
  30037. * @returns the location of the uniform.
  30038. */
  30039. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30040. /**
  30041. * Returns an array of sampler variable names
  30042. * @returns The array of sampler variable neames.
  30043. */
  30044. getSamplers(): string[];
  30045. /**
  30046. * The error from the last compilation.
  30047. * @returns the error string.
  30048. */
  30049. getCompilationError(): string;
  30050. /**
  30051. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30052. * @param func The callback to be used.
  30053. */
  30054. executeWhenCompiled(func: (effect: Effect) => void): void;
  30055. private _checkIsReady;
  30056. /** @hidden */
  30057. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30058. /** @hidden */
  30059. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30060. /** @hidden */
  30061. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30062. private _processShaderConversion;
  30063. private _processIncludes;
  30064. private _processPrecision;
  30065. /**
  30066. * Recompiles the webGL program
  30067. * @param vertexSourceCode The source code for the vertex shader.
  30068. * @param fragmentSourceCode The source code for the fragment shader.
  30069. * @param onCompiled Callback called when completed.
  30070. * @param onError Callback called on error.
  30071. * @hidden
  30072. */
  30073. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30074. /**
  30075. * Prepares the effect
  30076. * @hidden
  30077. */
  30078. _prepareEffect(): void;
  30079. /**
  30080. * Checks if the effect is supported. (Must be called after compilation)
  30081. */
  30082. readonly isSupported: boolean;
  30083. /**
  30084. * Binds a texture to the engine to be used as output of the shader.
  30085. * @param channel Name of the output variable.
  30086. * @param texture Texture to bind.
  30087. * @hidden
  30088. */
  30089. _bindTexture(channel: string, texture: InternalTexture): void;
  30090. /**
  30091. * Sets a texture on the engine to be used in the shader.
  30092. * @param channel Name of the sampler variable.
  30093. * @param texture Texture to set.
  30094. */
  30095. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30096. /**
  30097. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30098. * @param channel Name of the sampler variable.
  30099. * @param texture Texture to set.
  30100. */
  30101. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30102. /**
  30103. * Sets an array of textures on the engine to be used in the shader.
  30104. * @param channel Name of the variable.
  30105. * @param textures Textures to set.
  30106. */
  30107. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30108. /**
  30109. * 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)
  30110. * @param channel Name of the sampler variable.
  30111. * @param postProcess Post process to get the input texture from.
  30112. */
  30113. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30114. /**
  30115. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30116. * 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)
  30117. * @param channel Name of the sampler variable.
  30118. * @param postProcess Post process to get the output texture from.
  30119. */
  30120. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30121. /** @hidden */
  30122. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30123. /** @hidden */
  30124. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30125. /** @hidden */
  30126. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30127. /** @hidden */
  30128. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30129. /**
  30130. * Binds a buffer to a uniform.
  30131. * @param buffer Buffer to bind.
  30132. * @param name Name of the uniform variable to bind to.
  30133. */
  30134. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30135. /**
  30136. * Binds block to a uniform.
  30137. * @param blockName Name of the block to bind.
  30138. * @param index Index to bind.
  30139. */
  30140. bindUniformBlock(blockName: string, index: number): void;
  30141. /**
  30142. * Sets an interger value on a uniform variable.
  30143. * @param uniformName Name of the variable.
  30144. * @param value Value to be set.
  30145. * @returns this effect.
  30146. */
  30147. setInt(uniformName: string, value: number): Effect;
  30148. /**
  30149. * Sets an int array on a uniform variable.
  30150. * @param uniformName Name of the variable.
  30151. * @param array array to be set.
  30152. * @returns this effect.
  30153. */
  30154. setIntArray(uniformName: string, array: Int32Array): Effect;
  30155. /**
  30156. * 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)
  30157. * @param uniformName Name of the variable.
  30158. * @param array array to be set.
  30159. * @returns this effect.
  30160. */
  30161. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30162. /**
  30163. * 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)
  30164. * @param uniformName Name of the variable.
  30165. * @param array array to be set.
  30166. * @returns this effect.
  30167. */
  30168. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30169. /**
  30170. * 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)
  30171. * @param uniformName Name of the variable.
  30172. * @param array array to be set.
  30173. * @returns this effect.
  30174. */
  30175. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30176. /**
  30177. * Sets an float array on a uniform variable.
  30178. * @param uniformName Name of the variable.
  30179. * @param array array to be set.
  30180. * @returns this effect.
  30181. */
  30182. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30183. /**
  30184. * 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)
  30185. * @param uniformName Name of the variable.
  30186. * @param array array to be set.
  30187. * @returns this effect.
  30188. */
  30189. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30190. /**
  30191. * 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)
  30192. * @param uniformName Name of the variable.
  30193. * @param array array to be set.
  30194. * @returns this effect.
  30195. */
  30196. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30197. /**
  30198. * 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)
  30199. * @param uniformName Name of the variable.
  30200. * @param array array to be set.
  30201. * @returns this effect.
  30202. */
  30203. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30204. /**
  30205. * Sets an array on a uniform variable.
  30206. * @param uniformName Name of the variable.
  30207. * @param array array to be set.
  30208. * @returns this effect.
  30209. */
  30210. setArray(uniformName: string, array: number[]): Effect;
  30211. /**
  30212. * 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)
  30213. * @param uniformName Name of the variable.
  30214. * @param array array to be set.
  30215. * @returns this effect.
  30216. */
  30217. setArray2(uniformName: string, array: number[]): Effect;
  30218. /**
  30219. * 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)
  30220. * @param uniformName Name of the variable.
  30221. * @param array array to be set.
  30222. * @returns this effect.
  30223. */
  30224. setArray3(uniformName: string, array: number[]): Effect;
  30225. /**
  30226. * 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)
  30227. * @param uniformName Name of the variable.
  30228. * @param array array to be set.
  30229. * @returns this effect.
  30230. */
  30231. setArray4(uniformName: string, array: number[]): Effect;
  30232. /**
  30233. * Sets matrices on a uniform variable.
  30234. * @param uniformName Name of the variable.
  30235. * @param matrices matrices to be set.
  30236. * @returns this effect.
  30237. */
  30238. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30239. /**
  30240. * Sets matrix on a uniform variable.
  30241. * @param uniformName Name of the variable.
  30242. * @param matrix matrix to be set.
  30243. * @returns this effect.
  30244. */
  30245. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30246. /**
  30247. * 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)
  30248. * @param uniformName Name of the variable.
  30249. * @param matrix matrix to be set.
  30250. * @returns this effect.
  30251. */
  30252. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30253. /**
  30254. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30255. * @param uniformName Name of the variable.
  30256. * @param matrix matrix to be set.
  30257. * @returns this effect.
  30258. */
  30259. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30260. /**
  30261. * Sets a float on a uniform variable.
  30262. * @param uniformName Name of the variable.
  30263. * @param value value to be set.
  30264. * @returns this effect.
  30265. */
  30266. setFloat(uniformName: string, value: number): Effect;
  30267. /**
  30268. * Sets a boolean on a uniform variable.
  30269. * @param uniformName Name of the variable.
  30270. * @param bool value to be set.
  30271. * @returns this effect.
  30272. */
  30273. setBool(uniformName: string, bool: boolean): Effect;
  30274. /**
  30275. * Sets a Vector2 on a uniform variable.
  30276. * @param uniformName Name of the variable.
  30277. * @param vector2 vector2 to be set.
  30278. * @returns this effect.
  30279. */
  30280. setVector2(uniformName: string, vector2: Vector2): Effect;
  30281. /**
  30282. * Sets a float2 on a uniform variable.
  30283. * @param uniformName Name of the variable.
  30284. * @param x First float in float2.
  30285. * @param y Second float in float2.
  30286. * @returns this effect.
  30287. */
  30288. setFloat2(uniformName: string, x: number, y: number): Effect;
  30289. /**
  30290. * Sets a Vector3 on a uniform variable.
  30291. * @param uniformName Name of the variable.
  30292. * @param vector3 Value to be set.
  30293. * @returns this effect.
  30294. */
  30295. setVector3(uniformName: string, vector3: Vector3): Effect;
  30296. /**
  30297. * Sets a float3 on a uniform variable.
  30298. * @param uniformName Name of the variable.
  30299. * @param x First float in float3.
  30300. * @param y Second float in float3.
  30301. * @param z Third float in float3.
  30302. * @returns this effect.
  30303. */
  30304. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30305. /**
  30306. * Sets a Vector4 on a uniform variable.
  30307. * @param uniformName Name of the variable.
  30308. * @param vector4 Value to be set.
  30309. * @returns this effect.
  30310. */
  30311. setVector4(uniformName: string, vector4: Vector4): Effect;
  30312. /**
  30313. * Sets a float4 on a uniform variable.
  30314. * @param uniformName Name of the variable.
  30315. * @param x First float in float4.
  30316. * @param y Second float in float4.
  30317. * @param z Third float in float4.
  30318. * @param w Fourth float in float4.
  30319. * @returns this effect.
  30320. */
  30321. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30322. /**
  30323. * Sets a Color3 on a uniform variable.
  30324. * @param uniformName Name of the variable.
  30325. * @param color3 Value to be set.
  30326. * @returns this effect.
  30327. */
  30328. setColor3(uniformName: string, color3: Color3): Effect;
  30329. /**
  30330. * Sets a Color4 on a uniform variable.
  30331. * @param uniformName Name of the variable.
  30332. * @param color3 Value to be set.
  30333. * @param alpha Alpha value to be set.
  30334. * @returns this effect.
  30335. */
  30336. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30337. /**
  30338. * Sets a Color4 on a uniform variable
  30339. * @param uniformName defines the name of the variable
  30340. * @param color4 defines the value to be set
  30341. * @returns this effect.
  30342. */
  30343. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30344. /** Release all associated resources */
  30345. dispose(): void;
  30346. /**
  30347. * This function will add a new shader to the shader store
  30348. * @param name the name of the shader
  30349. * @param pixelShader optional pixel shader content
  30350. * @param vertexShader optional vertex shader content
  30351. */
  30352. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30353. /**
  30354. * Store of each shader (The can be looked up using effect.key)
  30355. */
  30356. static ShadersStore: {
  30357. [key: string]: string;
  30358. };
  30359. /**
  30360. * Store of each included file for a shader (The can be looked up using effect.key)
  30361. */
  30362. static IncludesShadersStore: {
  30363. [key: string]: string;
  30364. };
  30365. /**
  30366. * Resets the cache of effects.
  30367. */
  30368. static ResetCache(): void;
  30369. }
  30370. }
  30371. declare module "babylonjs/Materials/colorCurves" {
  30372. import { Effect } from "babylonjs/Materials/effect";
  30373. /**
  30374. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30375. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30376. * 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;
  30377. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30378. */
  30379. export class ColorCurves {
  30380. private _dirty;
  30381. private _tempColor;
  30382. private _globalCurve;
  30383. private _highlightsCurve;
  30384. private _midtonesCurve;
  30385. private _shadowsCurve;
  30386. private _positiveCurve;
  30387. private _negativeCurve;
  30388. private _globalHue;
  30389. private _globalDensity;
  30390. private _globalSaturation;
  30391. private _globalExposure;
  30392. /**
  30393. * Gets the global Hue value.
  30394. * 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).
  30395. */
  30396. /**
  30397. * Sets the global Hue value.
  30398. * 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).
  30399. */
  30400. globalHue: number;
  30401. /**
  30402. * Gets the global Density value.
  30403. * 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.
  30404. * Values less than zero provide a filter of opposite hue.
  30405. */
  30406. /**
  30407. * Sets the global Density value.
  30408. * 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.
  30409. * Values less than zero provide a filter of opposite hue.
  30410. */
  30411. globalDensity: number;
  30412. /**
  30413. * Gets the global Saturation value.
  30414. * 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.
  30415. */
  30416. /**
  30417. * Sets the global Saturation value.
  30418. * 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.
  30419. */
  30420. globalSaturation: number;
  30421. /**
  30422. * Gets the global Exposure value.
  30423. * 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.
  30424. */
  30425. /**
  30426. * Sets the global Exposure value.
  30427. * 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.
  30428. */
  30429. globalExposure: number;
  30430. private _highlightsHue;
  30431. private _highlightsDensity;
  30432. private _highlightsSaturation;
  30433. private _highlightsExposure;
  30434. /**
  30435. * Gets the highlights Hue value.
  30436. * 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).
  30437. */
  30438. /**
  30439. * Sets the highlights Hue value.
  30440. * 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).
  30441. */
  30442. highlightsHue: number;
  30443. /**
  30444. * Gets the highlights Density value.
  30445. * 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.
  30446. * Values less than zero provide a filter of opposite hue.
  30447. */
  30448. /**
  30449. * Sets the highlights Density value.
  30450. * 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.
  30451. * Values less than zero provide a filter of opposite hue.
  30452. */
  30453. highlightsDensity: number;
  30454. /**
  30455. * Gets the highlights Saturation value.
  30456. * 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.
  30457. */
  30458. /**
  30459. * Sets the highlights Saturation value.
  30460. * 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.
  30461. */
  30462. highlightsSaturation: number;
  30463. /**
  30464. * Gets the highlights Exposure value.
  30465. * 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.
  30466. */
  30467. /**
  30468. * Sets the highlights Exposure value.
  30469. * 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.
  30470. */
  30471. highlightsExposure: number;
  30472. private _midtonesHue;
  30473. private _midtonesDensity;
  30474. private _midtonesSaturation;
  30475. private _midtonesExposure;
  30476. /**
  30477. * Gets the midtones Hue value.
  30478. * 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).
  30479. */
  30480. /**
  30481. * Sets the midtones Hue value.
  30482. * 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).
  30483. */
  30484. midtonesHue: number;
  30485. /**
  30486. * Gets the midtones Density value.
  30487. * 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.
  30488. * Values less than zero provide a filter of opposite hue.
  30489. */
  30490. /**
  30491. * Sets the midtones Density value.
  30492. * 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.
  30493. * Values less than zero provide a filter of opposite hue.
  30494. */
  30495. midtonesDensity: number;
  30496. /**
  30497. * Gets the midtones Saturation value.
  30498. * 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.
  30499. */
  30500. /**
  30501. * Sets the midtones Saturation value.
  30502. * 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.
  30503. */
  30504. midtonesSaturation: number;
  30505. /**
  30506. * Gets the midtones Exposure value.
  30507. * 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.
  30508. */
  30509. /**
  30510. * Sets the midtones Exposure value.
  30511. * 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.
  30512. */
  30513. midtonesExposure: number;
  30514. private _shadowsHue;
  30515. private _shadowsDensity;
  30516. private _shadowsSaturation;
  30517. private _shadowsExposure;
  30518. /**
  30519. * Gets the shadows Hue value.
  30520. * 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).
  30521. */
  30522. /**
  30523. * Sets the shadows Hue value.
  30524. * 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).
  30525. */
  30526. shadowsHue: number;
  30527. /**
  30528. * Gets the shadows Density value.
  30529. * 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.
  30530. * Values less than zero provide a filter of opposite hue.
  30531. */
  30532. /**
  30533. * Sets the shadows Density value.
  30534. * 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.
  30535. * Values less than zero provide a filter of opposite hue.
  30536. */
  30537. shadowsDensity: number;
  30538. /**
  30539. * Gets the shadows Saturation value.
  30540. * 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.
  30541. */
  30542. /**
  30543. * Sets the shadows Saturation value.
  30544. * 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.
  30545. */
  30546. shadowsSaturation: number;
  30547. /**
  30548. * Gets the shadows Exposure value.
  30549. * 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.
  30550. */
  30551. /**
  30552. * Sets the shadows Exposure value.
  30553. * 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.
  30554. */
  30555. shadowsExposure: number;
  30556. /**
  30557. * Returns the class name
  30558. * @returns The class name
  30559. */
  30560. getClassName(): string;
  30561. /**
  30562. * Binds the color curves to the shader.
  30563. * @param colorCurves The color curve to bind
  30564. * @param effect The effect to bind to
  30565. * @param positiveUniform The positive uniform shader parameter
  30566. * @param neutralUniform The neutral uniform shader parameter
  30567. * @param negativeUniform The negative uniform shader parameter
  30568. */
  30569. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30570. /**
  30571. * Prepare the list of uniforms associated with the ColorCurves effects.
  30572. * @param uniformsList The list of uniforms used in the effect
  30573. */
  30574. static PrepareUniforms(uniformsList: string[]): void;
  30575. /**
  30576. * Returns color grading data based on a hue, density, saturation and exposure value.
  30577. * @param filterHue The hue of the color filter.
  30578. * @param filterDensity The density of the color filter.
  30579. * @param saturation The saturation.
  30580. * @param exposure The exposure.
  30581. * @param result The result data container.
  30582. */
  30583. private getColorGradingDataToRef;
  30584. /**
  30585. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30586. * @param value The input slider value in range [-100,100].
  30587. * @returns Adjusted value.
  30588. */
  30589. private static applyColorGradingSliderNonlinear;
  30590. /**
  30591. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30592. * @param hue The hue (H) input.
  30593. * @param saturation The saturation (S) input.
  30594. * @param brightness The brightness (B) input.
  30595. * @result An RGBA color represented as Vector4.
  30596. */
  30597. private static fromHSBToRef;
  30598. /**
  30599. * Returns a value clamped between min and max
  30600. * @param value The value to clamp
  30601. * @param min The minimum of value
  30602. * @param max The maximum of value
  30603. * @returns The clamped value.
  30604. */
  30605. private static clamp;
  30606. /**
  30607. * Clones the current color curve instance.
  30608. * @return The cloned curves
  30609. */
  30610. clone(): ColorCurves;
  30611. /**
  30612. * Serializes the current color curve instance to a json representation.
  30613. * @return a JSON representation
  30614. */
  30615. serialize(): any;
  30616. /**
  30617. * Parses the color curve from a json representation.
  30618. * @param source the JSON source to parse
  30619. * @return The parsed curves
  30620. */
  30621. static Parse(source: any): ColorCurves;
  30622. }
  30623. }
  30624. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30625. import { Observable } from "babylonjs/Misc/observable";
  30626. import { Nullable } from "babylonjs/types";
  30627. import { Color4 } from "babylonjs/Maths/math";
  30628. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30629. import { Effect } from "babylonjs/Materials/effect";
  30630. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30631. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30632. /**
  30633. * Interface to follow in your material defines to integrate easily the
  30634. * Image proccessing functions.
  30635. * @hidden
  30636. */
  30637. export interface IImageProcessingConfigurationDefines {
  30638. IMAGEPROCESSING: boolean;
  30639. VIGNETTE: boolean;
  30640. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30641. VIGNETTEBLENDMODEOPAQUE: boolean;
  30642. TONEMAPPING: boolean;
  30643. TONEMAPPING_ACES: boolean;
  30644. CONTRAST: boolean;
  30645. EXPOSURE: boolean;
  30646. COLORCURVES: boolean;
  30647. COLORGRADING: boolean;
  30648. COLORGRADING3D: boolean;
  30649. SAMPLER3DGREENDEPTH: boolean;
  30650. SAMPLER3DBGRMAP: boolean;
  30651. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30652. }
  30653. /**
  30654. * @hidden
  30655. */
  30656. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30657. IMAGEPROCESSING: boolean;
  30658. VIGNETTE: boolean;
  30659. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30660. VIGNETTEBLENDMODEOPAQUE: boolean;
  30661. TONEMAPPING: boolean;
  30662. TONEMAPPING_ACES: boolean;
  30663. CONTRAST: boolean;
  30664. COLORCURVES: boolean;
  30665. COLORGRADING: boolean;
  30666. COLORGRADING3D: boolean;
  30667. SAMPLER3DGREENDEPTH: boolean;
  30668. SAMPLER3DBGRMAP: boolean;
  30669. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30670. EXPOSURE: boolean;
  30671. constructor();
  30672. }
  30673. /**
  30674. * This groups together the common properties used for image processing either in direct forward pass
  30675. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30676. * or not.
  30677. */
  30678. export class ImageProcessingConfiguration {
  30679. /**
  30680. * Default tone mapping applied in BabylonJS.
  30681. */
  30682. static readonly TONEMAPPING_STANDARD: number;
  30683. /**
  30684. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30685. * to other engines rendering to increase portability.
  30686. */
  30687. static readonly TONEMAPPING_ACES: number;
  30688. /**
  30689. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30690. */
  30691. colorCurves: Nullable<ColorCurves>;
  30692. private _colorCurvesEnabled;
  30693. /**
  30694. * Gets wether the color curves effect is enabled.
  30695. */
  30696. /**
  30697. * Sets wether the color curves effect is enabled.
  30698. */
  30699. colorCurvesEnabled: boolean;
  30700. private _colorGradingTexture;
  30701. /**
  30702. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30703. */
  30704. /**
  30705. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30706. */
  30707. colorGradingTexture: Nullable<BaseTexture>;
  30708. private _colorGradingEnabled;
  30709. /**
  30710. * Gets wether the color grading effect is enabled.
  30711. */
  30712. /**
  30713. * Sets wether the color grading effect is enabled.
  30714. */
  30715. colorGradingEnabled: boolean;
  30716. private _colorGradingWithGreenDepth;
  30717. /**
  30718. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30719. */
  30720. /**
  30721. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30722. */
  30723. colorGradingWithGreenDepth: boolean;
  30724. private _colorGradingBGR;
  30725. /**
  30726. * Gets wether the color grading texture contains BGR values.
  30727. */
  30728. /**
  30729. * Sets wether the color grading texture contains BGR values.
  30730. */
  30731. colorGradingBGR: boolean;
  30732. /** @hidden */
  30733. _exposure: number;
  30734. /**
  30735. * Gets the Exposure used in the effect.
  30736. */
  30737. /**
  30738. * Sets the Exposure used in the effect.
  30739. */
  30740. exposure: number;
  30741. private _toneMappingEnabled;
  30742. /**
  30743. * Gets wether the tone mapping effect is enabled.
  30744. */
  30745. /**
  30746. * Sets wether the tone mapping effect is enabled.
  30747. */
  30748. toneMappingEnabled: boolean;
  30749. private _toneMappingType;
  30750. /**
  30751. * Gets the type of tone mapping effect.
  30752. */
  30753. /**
  30754. * Sets the type of tone mapping effect used in BabylonJS.
  30755. */
  30756. toneMappingType: number;
  30757. protected _contrast: number;
  30758. /**
  30759. * Gets the contrast used in the effect.
  30760. */
  30761. /**
  30762. * Sets the contrast used in the effect.
  30763. */
  30764. contrast: number;
  30765. /**
  30766. * Vignette stretch size.
  30767. */
  30768. vignetteStretch: number;
  30769. /**
  30770. * Vignette centre X Offset.
  30771. */
  30772. vignetteCentreX: number;
  30773. /**
  30774. * Vignette centre Y Offset.
  30775. */
  30776. vignetteCentreY: number;
  30777. /**
  30778. * Vignette weight or intensity of the vignette effect.
  30779. */
  30780. vignetteWeight: number;
  30781. /**
  30782. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30783. * if vignetteEnabled is set to true.
  30784. */
  30785. vignetteColor: Color4;
  30786. /**
  30787. * Camera field of view used by the Vignette effect.
  30788. */
  30789. vignetteCameraFov: number;
  30790. private _vignetteBlendMode;
  30791. /**
  30792. * Gets the vignette blend mode allowing different kind of effect.
  30793. */
  30794. /**
  30795. * Sets the vignette blend mode allowing different kind of effect.
  30796. */
  30797. vignetteBlendMode: number;
  30798. private _vignetteEnabled;
  30799. /**
  30800. * Gets wether the vignette effect is enabled.
  30801. */
  30802. /**
  30803. * Sets wether the vignette effect is enabled.
  30804. */
  30805. vignetteEnabled: boolean;
  30806. private _applyByPostProcess;
  30807. /**
  30808. * Gets wether the image processing is applied through a post process or not.
  30809. */
  30810. /**
  30811. * Sets wether the image processing is applied through a post process or not.
  30812. */
  30813. applyByPostProcess: boolean;
  30814. private _isEnabled;
  30815. /**
  30816. * Gets wether the image processing is enabled or not.
  30817. */
  30818. /**
  30819. * Sets wether the image processing is enabled or not.
  30820. */
  30821. isEnabled: boolean;
  30822. /**
  30823. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30824. */
  30825. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30826. /**
  30827. * Method called each time the image processing information changes requires to recompile the effect.
  30828. */
  30829. protected _updateParameters(): void;
  30830. /**
  30831. * Gets the current class name.
  30832. * @return "ImageProcessingConfiguration"
  30833. */
  30834. getClassName(): string;
  30835. /**
  30836. * Prepare the list of uniforms associated with the Image Processing effects.
  30837. * @param uniforms The list of uniforms used in the effect
  30838. * @param defines the list of defines currently in use
  30839. */
  30840. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30841. /**
  30842. * Prepare the list of samplers associated with the Image Processing effects.
  30843. * @param samplersList The list of uniforms used in the effect
  30844. * @param defines the list of defines currently in use
  30845. */
  30846. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30847. /**
  30848. * Prepare the list of defines associated to the shader.
  30849. * @param defines the list of defines to complete
  30850. * @param forPostProcess Define if we are currently in post process mode or not
  30851. */
  30852. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30853. /**
  30854. * Returns true if all the image processing information are ready.
  30855. * @returns True if ready, otherwise, false
  30856. */
  30857. isReady(): boolean;
  30858. /**
  30859. * Binds the image processing to the shader.
  30860. * @param effect The effect to bind to
  30861. * @param aspectRatio Define the current aspect ratio of the effect
  30862. */
  30863. bind(effect: Effect, aspectRatio?: number): void;
  30864. /**
  30865. * Clones the current image processing instance.
  30866. * @return The cloned image processing
  30867. */
  30868. clone(): ImageProcessingConfiguration;
  30869. /**
  30870. * Serializes the current image processing instance to a json representation.
  30871. * @return a JSON representation
  30872. */
  30873. serialize(): any;
  30874. /**
  30875. * Parses the image processing from a json representation.
  30876. * @param source the JSON source to parse
  30877. * @return The parsed image processing
  30878. */
  30879. static Parse(source: any): ImageProcessingConfiguration;
  30880. private static _VIGNETTEMODE_MULTIPLY;
  30881. private static _VIGNETTEMODE_OPAQUE;
  30882. /**
  30883. * Used to apply the vignette as a mix with the pixel color.
  30884. */
  30885. static readonly VIGNETTEMODE_MULTIPLY: number;
  30886. /**
  30887. * Used to apply the vignette as a replacement of the pixel color.
  30888. */
  30889. static readonly VIGNETTEMODE_OPAQUE: number;
  30890. }
  30891. }
  30892. declare module "babylonjs/Materials/fresnelParameters" {
  30893. import { Color3 } from "babylonjs/Maths/math";
  30894. /**
  30895. * This represents all the required information to add a fresnel effect on a material:
  30896. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30897. */
  30898. export class FresnelParameters {
  30899. private _isEnabled;
  30900. /**
  30901. * Define if the fresnel effect is enable or not.
  30902. */
  30903. isEnabled: boolean;
  30904. /**
  30905. * Define the color used on edges (grazing angle)
  30906. */
  30907. leftColor: Color3;
  30908. /**
  30909. * Define the color used on center
  30910. */
  30911. rightColor: Color3;
  30912. /**
  30913. * Define bias applied to computed fresnel term
  30914. */
  30915. bias: number;
  30916. /**
  30917. * Defined the power exponent applied to fresnel term
  30918. */
  30919. power: number;
  30920. /**
  30921. * Clones the current fresnel and its valuues
  30922. * @returns a clone fresnel configuration
  30923. */
  30924. clone(): FresnelParameters;
  30925. /**
  30926. * Serializes the current fresnel parameters to a JSON representation.
  30927. * @return the JSON serialization
  30928. */
  30929. serialize(): any;
  30930. /**
  30931. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30932. * @param parsedFresnelParameters Define the JSON representation
  30933. * @returns the parsed parameters
  30934. */
  30935. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30936. }
  30937. }
  30938. declare module "babylonjs/Misc/decorators" {
  30939. import { Nullable } from "babylonjs/types";
  30940. import { Scene } from "babylonjs/scene";
  30941. import { IAnimatable } from "babylonjs/Misc/tools";
  30942. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30943. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30944. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30945. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30946. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30947. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30948. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30949. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30950. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30951. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30952. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30953. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30954. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30955. /**
  30956. * Decorator used to define property that can be serialized as reference to a camera
  30957. * @param sourceName defines the name of the property to decorate
  30958. */
  30959. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30960. /**
  30961. * Class used to help serialization objects
  30962. */
  30963. export class SerializationHelper {
  30964. /** hidden */
  30965. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30966. /** hidden */
  30967. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30968. /** hidden */
  30969. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30970. /** hidden */
  30971. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30972. /**
  30973. * Appends the serialized animations from the source animations
  30974. * @param source Source containing the animations
  30975. * @param destination Target to store the animations
  30976. */
  30977. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30978. /**
  30979. * Static function used to serialized a specific entity
  30980. * @param entity defines the entity to serialize
  30981. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30982. * @returns a JSON compatible object representing the serialization of the entity
  30983. */
  30984. static Serialize<T>(entity: T, serializationObject?: any): any;
  30985. /**
  30986. * Creates a new entity from a serialization data object
  30987. * @param creationFunction defines a function used to instanciated the new entity
  30988. * @param source defines the source serialization data
  30989. * @param scene defines the hosting scene
  30990. * @param rootUrl defines the root url for resources
  30991. * @returns a new entity
  30992. */
  30993. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30994. /**
  30995. * Clones an object
  30996. * @param creationFunction defines the function used to instanciate the new object
  30997. * @param source defines the source object
  30998. * @returns the cloned object
  30999. */
  31000. static Clone<T>(creationFunction: () => T, source: T): T;
  31001. /**
  31002. * Instanciates a new object based on a source one (some data will be shared between both object)
  31003. * @param creationFunction defines the function used to instanciate the new object
  31004. * @param source defines the source object
  31005. * @returns the new object
  31006. */
  31007. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31008. }
  31009. }
  31010. declare module "babylonjs/Cameras/camera" {
  31011. import { SmartArray } from "babylonjs/Misc/smartArray";
  31012. import { Observable } from "babylonjs/Misc/observable";
  31013. import { Nullable } from "babylonjs/types";
  31014. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31015. import { Scene } from "babylonjs/scene";
  31016. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31017. import { Node } from "babylonjs/node";
  31018. import { Mesh } from "babylonjs/Meshes/mesh";
  31019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31020. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31021. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31022. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31023. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31024. import { Ray } from "babylonjs/Culling/ray";
  31025. /**
  31026. * This is the base class of all the camera used in the application.
  31027. * @see http://doc.babylonjs.com/features/cameras
  31028. */
  31029. export class Camera extends Node {
  31030. /** @hidden */
  31031. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31032. /**
  31033. * This is the default projection mode used by the cameras.
  31034. * It helps recreating a feeling of perspective and better appreciate depth.
  31035. * This is the best way to simulate real life cameras.
  31036. */
  31037. static readonly PERSPECTIVE_CAMERA: number;
  31038. /**
  31039. * This helps creating camera with an orthographic mode.
  31040. * 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.
  31041. */
  31042. static readonly ORTHOGRAPHIC_CAMERA: number;
  31043. /**
  31044. * This is the default FOV mode for perspective cameras.
  31045. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31046. */
  31047. static readonly FOVMODE_VERTICAL_FIXED: number;
  31048. /**
  31049. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31050. */
  31051. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31052. /**
  31053. * This specifies ther is no need for a camera rig.
  31054. * Basically only one eye is rendered corresponding to the camera.
  31055. */
  31056. static readonly RIG_MODE_NONE: number;
  31057. /**
  31058. * Simulates a camera Rig with one blue eye and one red eye.
  31059. * This can be use with 3d blue and red glasses.
  31060. */
  31061. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31062. /**
  31063. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31064. */
  31065. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31066. /**
  31067. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31068. */
  31069. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31070. /**
  31071. * Defines that both eyes of the camera will be rendered over under each other.
  31072. */
  31073. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31074. /**
  31075. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31076. */
  31077. static readonly RIG_MODE_VR: number;
  31078. /**
  31079. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31080. */
  31081. static readonly RIG_MODE_WEBVR: number;
  31082. /**
  31083. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31084. */
  31085. static readonly RIG_MODE_CUSTOM: number;
  31086. /**
  31087. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31088. */
  31089. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31090. /**
  31091. * Define the input manager associated with the camera.
  31092. */
  31093. inputs: CameraInputsManager<Camera>;
  31094. /** @hidden */
  31095. _position: Vector3;
  31096. /**
  31097. * Define the current local position of the camera in the scene
  31098. */
  31099. position: Vector3;
  31100. /**
  31101. * The vector the camera should consider as up.
  31102. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31103. */
  31104. upVector: Vector3;
  31105. /**
  31106. * Define the current limit on the left side for an orthographic camera
  31107. * In scene unit
  31108. */
  31109. orthoLeft: Nullable<number>;
  31110. /**
  31111. * Define the current limit on the right side for an orthographic camera
  31112. * In scene unit
  31113. */
  31114. orthoRight: Nullable<number>;
  31115. /**
  31116. * Define the current limit on the bottom side for an orthographic camera
  31117. * In scene unit
  31118. */
  31119. orthoBottom: Nullable<number>;
  31120. /**
  31121. * Define the current limit on the top side for an orthographic camera
  31122. * In scene unit
  31123. */
  31124. orthoTop: Nullable<number>;
  31125. /**
  31126. * Field Of View is set in Radians. (default is 0.8)
  31127. */
  31128. fov: number;
  31129. /**
  31130. * Define the minimum distance the camera can see from.
  31131. * This is important to note that the depth buffer are not infinite and the closer it starts
  31132. * the more your scene might encounter depth fighting issue.
  31133. */
  31134. minZ: number;
  31135. /**
  31136. * Define the maximum distance the camera can see to.
  31137. * This is important to note that the depth buffer are not infinite and the further it end
  31138. * the more your scene might encounter depth fighting issue.
  31139. */
  31140. maxZ: number;
  31141. /**
  31142. * Define the default inertia of the camera.
  31143. * This helps giving a smooth feeling to the camera movement.
  31144. */
  31145. inertia: number;
  31146. /**
  31147. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31148. */
  31149. mode: number;
  31150. /**
  31151. * Define wether the camera is intermediate.
  31152. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31153. */
  31154. isIntermediate: boolean;
  31155. /**
  31156. * Define the viewport of the camera.
  31157. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31158. */
  31159. viewport: Viewport;
  31160. /**
  31161. * Restricts the camera to viewing objects with the same layerMask.
  31162. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31163. */
  31164. layerMask: number;
  31165. /**
  31166. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31167. */
  31168. fovMode: number;
  31169. /**
  31170. * Rig mode of the camera.
  31171. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31172. * This is normally controlled byt the camera themselves as internal use.
  31173. */
  31174. cameraRigMode: number;
  31175. /**
  31176. * Defines the distance between both "eyes" in case of a RIG
  31177. */
  31178. interaxialDistance: number;
  31179. /**
  31180. * Defines if stereoscopic rendering is done side by side or over under.
  31181. */
  31182. isStereoscopicSideBySide: boolean;
  31183. /**
  31184. * 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
  31185. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31186. * else in the scene.
  31187. */
  31188. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31189. /**
  31190. * When set, the camera will render to this render target instead of the default canvas
  31191. */
  31192. outputRenderTarget: Nullable<RenderTargetTexture>;
  31193. /**
  31194. * Observable triggered when the camera view matrix has changed.
  31195. */
  31196. onViewMatrixChangedObservable: Observable<Camera>;
  31197. /**
  31198. * Observable triggered when the camera Projection matrix has changed.
  31199. */
  31200. onProjectionMatrixChangedObservable: Observable<Camera>;
  31201. /**
  31202. * Observable triggered when the inputs have been processed.
  31203. */
  31204. onAfterCheckInputsObservable: Observable<Camera>;
  31205. /**
  31206. * Observable triggered when reset has been called and applied to the camera.
  31207. */
  31208. onRestoreStateObservable: Observable<Camera>;
  31209. /** @hidden */
  31210. _cameraRigParams: any;
  31211. /** @hidden */
  31212. _rigCameras: Camera[];
  31213. /** @hidden */
  31214. _rigPostProcess: Nullable<PostProcess>;
  31215. protected _webvrViewMatrix: Matrix;
  31216. /** @hidden */
  31217. _skipRendering: boolean;
  31218. /** @hidden */
  31219. _projectionMatrix: Matrix;
  31220. /** @hidden */
  31221. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31222. /** @hidden */
  31223. _activeMeshes: SmartArray<AbstractMesh>;
  31224. protected _globalPosition: Vector3;
  31225. /** hidden */
  31226. _computedViewMatrix: Matrix;
  31227. private _doNotComputeProjectionMatrix;
  31228. private _transformMatrix;
  31229. private _frustumPlanes;
  31230. private _refreshFrustumPlanes;
  31231. private _storedFov;
  31232. private _stateStored;
  31233. /**
  31234. * Instantiates a new camera object.
  31235. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31236. * @see http://doc.babylonjs.com/features/cameras
  31237. * @param name Defines the name of the camera in the scene
  31238. * @param position Defines the position of the camera
  31239. * @param scene Defines the scene the camera belongs too
  31240. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31241. */
  31242. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31243. /**
  31244. * Store current camera state (fov, position, etc..)
  31245. * @returns the camera
  31246. */
  31247. storeState(): Camera;
  31248. /**
  31249. * Restores the camera state values if it has been stored. You must call storeState() first
  31250. */
  31251. protected _restoreStateValues(): boolean;
  31252. /**
  31253. * Restored camera state. You must call storeState() first.
  31254. * @returns true if restored and false otherwise
  31255. */
  31256. restoreState(): boolean;
  31257. /**
  31258. * Gets the class name of the camera.
  31259. * @returns the class name
  31260. */
  31261. getClassName(): string;
  31262. /** @hidden */
  31263. readonly _isCamera: boolean;
  31264. /**
  31265. * Gets a string representation of the camera useful for debug purpose.
  31266. * @param fullDetails Defines that a more verboe level of logging is required
  31267. * @returns the string representation
  31268. */
  31269. toString(fullDetails?: boolean): string;
  31270. /**
  31271. * Gets the current world space position of the camera.
  31272. */
  31273. readonly globalPosition: Vector3;
  31274. /**
  31275. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31276. * @returns the active meshe list
  31277. */
  31278. getActiveMeshes(): SmartArray<AbstractMesh>;
  31279. /**
  31280. * Check wether a mesh is part of the current active mesh list of the camera
  31281. * @param mesh Defines the mesh to check
  31282. * @returns true if active, false otherwise
  31283. */
  31284. isActiveMesh(mesh: Mesh): boolean;
  31285. /**
  31286. * Is this camera ready to be used/rendered
  31287. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31288. * @return true if the camera is ready
  31289. */
  31290. isReady(completeCheck?: boolean): boolean;
  31291. /** @hidden */
  31292. _initCache(): void;
  31293. /** @hidden */
  31294. _updateCache(ignoreParentClass?: boolean): void;
  31295. /** @hidden */
  31296. _isSynchronized(): boolean;
  31297. /** @hidden */
  31298. _isSynchronizedViewMatrix(): boolean;
  31299. /** @hidden */
  31300. _isSynchronizedProjectionMatrix(): boolean;
  31301. /**
  31302. * Attach the input controls to a specific dom element to get the input from.
  31303. * @param element Defines the element the controls should be listened from
  31304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31305. */
  31306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31307. /**
  31308. * Detach the current controls from the specified dom element.
  31309. * @param element Defines the element to stop listening the inputs from
  31310. */
  31311. detachControl(element: HTMLElement): void;
  31312. /**
  31313. * Update the camera state according to the different inputs gathered during the frame.
  31314. */
  31315. update(): void;
  31316. /** @hidden */
  31317. _checkInputs(): void;
  31318. /** @hidden */
  31319. readonly rigCameras: Camera[];
  31320. /**
  31321. * Gets the post process used by the rig cameras
  31322. */
  31323. readonly rigPostProcess: Nullable<PostProcess>;
  31324. /**
  31325. * Internal, gets the first post proces.
  31326. * @returns the first post process to be run on this camera.
  31327. */
  31328. _getFirstPostProcess(): Nullable<PostProcess>;
  31329. private _cascadePostProcessesToRigCams;
  31330. /**
  31331. * Attach a post process to the camera.
  31332. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31333. * @param postProcess The post process to attach to the camera
  31334. * @param insertAt The position of the post process in case several of them are in use in the scene
  31335. * @returns the position the post process has been inserted at
  31336. */
  31337. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31338. /**
  31339. * Detach a post process to the camera.
  31340. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31341. * @param postProcess The post process to detach from the camera
  31342. */
  31343. detachPostProcess(postProcess: PostProcess): void;
  31344. /**
  31345. * Gets the current world matrix of the camera
  31346. */
  31347. getWorldMatrix(): Matrix;
  31348. /** @hidden */
  31349. _getViewMatrix(): Matrix;
  31350. /**
  31351. * Gets the current view matrix of the camera.
  31352. * @param force forces the camera to recompute the matrix without looking at the cached state
  31353. * @returns the view matrix
  31354. */
  31355. getViewMatrix(force?: boolean): Matrix;
  31356. /**
  31357. * Freeze the projection matrix.
  31358. * It will prevent the cache check of the camera projection compute and can speed up perf
  31359. * if no parameter of the camera are meant to change
  31360. * @param projection Defines manually a projection if necessary
  31361. */
  31362. freezeProjectionMatrix(projection?: Matrix): void;
  31363. /**
  31364. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31365. */
  31366. unfreezeProjectionMatrix(): void;
  31367. /**
  31368. * Gets the current projection matrix of the camera.
  31369. * @param force forces the camera to recompute the matrix without looking at the cached state
  31370. * @returns the projection matrix
  31371. */
  31372. getProjectionMatrix(force?: boolean): Matrix;
  31373. /**
  31374. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31375. * @returns a Matrix
  31376. */
  31377. getTransformationMatrix(): Matrix;
  31378. private _updateFrustumPlanes;
  31379. /**
  31380. * Checks if a cullable object (mesh...) is in the camera frustum
  31381. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31382. * @param target The object to check
  31383. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31384. * @returns true if the object is in frustum otherwise false
  31385. */
  31386. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31387. /**
  31388. * Checks if a cullable object (mesh...) is in the camera frustum
  31389. * Unlike isInFrustum this cheks the full bounding box
  31390. * @param target The object to check
  31391. * @returns true if the object is in frustum otherwise false
  31392. */
  31393. isCompletelyInFrustum(target: ICullable): boolean;
  31394. /**
  31395. * Gets a ray in the forward direction from the camera.
  31396. * @param length Defines the length of the ray to create
  31397. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31398. * @param origin Defines the start point of the ray which defaults to the camera position
  31399. * @returns the forward ray
  31400. */
  31401. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31402. /**
  31403. * Releases resources associated with this node.
  31404. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31405. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31406. */
  31407. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31408. /** @hidden */
  31409. _isLeftCamera: boolean;
  31410. /**
  31411. * Gets the left camera of a rig setup in case of Rigged Camera
  31412. */
  31413. readonly isLeftCamera: boolean;
  31414. /** @hidden */
  31415. _isRightCamera: boolean;
  31416. /**
  31417. * Gets the right camera of a rig setup in case of Rigged Camera
  31418. */
  31419. readonly isRightCamera: boolean;
  31420. /**
  31421. * Gets the left camera of a rig setup in case of Rigged Camera
  31422. */
  31423. readonly leftCamera: Nullable<FreeCamera>;
  31424. /**
  31425. * Gets the right camera of a rig setup in case of Rigged Camera
  31426. */
  31427. readonly rightCamera: Nullable<FreeCamera>;
  31428. /**
  31429. * Gets the left camera target of a rig setup in case of Rigged Camera
  31430. * @returns the target position
  31431. */
  31432. getLeftTarget(): Nullable<Vector3>;
  31433. /**
  31434. * Gets the right camera target of a rig setup in case of Rigged Camera
  31435. * @returns the target position
  31436. */
  31437. getRightTarget(): Nullable<Vector3>;
  31438. /**
  31439. * @hidden
  31440. */
  31441. setCameraRigMode(mode: number, rigParams: any): void;
  31442. /** @hidden */
  31443. static _setStereoscopicRigMode(camera: Camera): void;
  31444. /** @hidden */
  31445. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31446. /** @hidden */
  31447. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31448. /** @hidden */
  31449. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31450. /** @hidden */
  31451. _getVRProjectionMatrix(): Matrix;
  31452. protected _updateCameraRotationMatrix(): void;
  31453. protected _updateWebVRCameraRotationMatrix(): void;
  31454. /**
  31455. * This function MUST be overwritten by the different WebVR cameras available.
  31456. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31457. * @hidden
  31458. */
  31459. _getWebVRProjectionMatrix(): Matrix;
  31460. /**
  31461. * This function MUST be overwritten by the different WebVR cameras available.
  31462. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31463. * @hidden
  31464. */
  31465. _getWebVRViewMatrix(): Matrix;
  31466. /** @hidden */
  31467. setCameraRigParameter(name: string, value: any): void;
  31468. /**
  31469. * needs to be overridden by children so sub has required properties to be copied
  31470. * @hidden
  31471. */
  31472. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31473. /**
  31474. * May need to be overridden by children
  31475. * @hidden
  31476. */
  31477. _updateRigCameras(): void;
  31478. /** @hidden */
  31479. _setupInputs(): void;
  31480. /**
  31481. * Serialiaze the camera setup to a json represention
  31482. * @returns the JSON representation
  31483. */
  31484. serialize(): any;
  31485. /**
  31486. * Clones the current camera.
  31487. * @param name The cloned camera name
  31488. * @returns the cloned camera
  31489. */
  31490. clone(name: string): Camera;
  31491. /**
  31492. * Gets the direction of the camera relative to a given local axis.
  31493. * @param localAxis Defines the reference axis to provide a relative direction.
  31494. * @return the direction
  31495. */
  31496. getDirection(localAxis: Vector3): Vector3;
  31497. /**
  31498. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31499. * @param localAxis Defines the reference axis to provide a relative direction.
  31500. * @param result Defines the vector to store the result in
  31501. */
  31502. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31503. /**
  31504. * Gets a camera constructor for a given camera type
  31505. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31506. * @param name The name of the camera the result will be able to instantiate
  31507. * @param scene The scene the result will construct the camera in
  31508. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31509. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31510. * @returns a factory method to construc the camera
  31511. */
  31512. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31513. /**
  31514. * Compute the world matrix of the camera.
  31515. * @returns the camera workd matrix
  31516. */
  31517. computeWorldMatrix(): Matrix;
  31518. /**
  31519. * Parse a JSON and creates the camera from the parsed information
  31520. * @param parsedCamera The JSON to parse
  31521. * @param scene The scene to instantiate the camera in
  31522. * @returns the newly constructed camera
  31523. */
  31524. static Parse(parsedCamera: any, scene: Scene): Camera;
  31525. }
  31526. }
  31527. declare module "babylonjs/Misc/tools" {
  31528. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31529. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31530. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31531. import { Observable } from "babylonjs/Misc/observable";
  31532. import { DomManagement } from "babylonjs/Misc/domManagement";
  31533. import { WebRequest } from "babylonjs/Misc/webRequest";
  31534. import { Camera } from "babylonjs/Cameras/camera";
  31535. import { Engine } from "babylonjs/Engines/engine";
  31536. import { Animation } from "babylonjs/Animations/animation";
  31537. /**
  31538. * Interface for any object that can request an animation frame
  31539. */
  31540. export interface ICustomAnimationFrameRequester {
  31541. /**
  31542. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31543. */
  31544. renderFunction?: Function;
  31545. /**
  31546. * Called to request the next frame to render to
  31547. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31548. */
  31549. requestAnimationFrame: Function;
  31550. /**
  31551. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31552. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31553. */
  31554. requestID?: number;
  31555. }
  31556. /**
  31557. * Interface containing an array of animations
  31558. */
  31559. export interface IAnimatable {
  31560. /**
  31561. * Array of animations
  31562. */
  31563. animations: Nullable<Array<Animation>>;
  31564. }
  31565. /** Interface used by value gradients (color, factor, ...) */
  31566. export interface IValueGradient {
  31567. /**
  31568. * Gets or sets the gradient value (between 0 and 1)
  31569. */
  31570. gradient: number;
  31571. }
  31572. /** Class used to store color4 gradient */
  31573. export class ColorGradient implements IValueGradient {
  31574. /**
  31575. * Gets or sets the gradient value (between 0 and 1)
  31576. */
  31577. gradient: number;
  31578. /**
  31579. * Gets or sets first associated color
  31580. */
  31581. color1: Color4;
  31582. /**
  31583. * Gets or sets second associated color
  31584. */
  31585. color2?: Color4;
  31586. /**
  31587. * Will get a color picked randomly between color1 and color2.
  31588. * If color2 is undefined then color1 will be used
  31589. * @param result defines the target Color4 to store the result in
  31590. */
  31591. getColorToRef(result: Color4): void;
  31592. }
  31593. /** Class used to store color 3 gradient */
  31594. export class Color3Gradient implements IValueGradient {
  31595. /**
  31596. * Gets or sets the gradient value (between 0 and 1)
  31597. */
  31598. gradient: number;
  31599. /**
  31600. * Gets or sets the associated color
  31601. */
  31602. color: Color3;
  31603. }
  31604. /** Class used to store factor gradient */
  31605. export class FactorGradient implements IValueGradient {
  31606. /**
  31607. * Gets or sets the gradient value (between 0 and 1)
  31608. */
  31609. gradient: number;
  31610. /**
  31611. * Gets or sets first associated factor
  31612. */
  31613. factor1: number;
  31614. /**
  31615. * Gets or sets second associated factor
  31616. */
  31617. factor2?: number;
  31618. /**
  31619. * Will get a number picked randomly between factor1 and factor2.
  31620. * If factor2 is undefined then factor1 will be used
  31621. * @returns the picked number
  31622. */
  31623. getFactor(): number;
  31624. }
  31625. /**
  31626. * @ignore
  31627. * Application error to support additional information when loading a file
  31628. */
  31629. export class LoadFileError extends Error {
  31630. /** defines the optional web request */
  31631. request?: WebRequest | undefined;
  31632. private static _setPrototypeOf;
  31633. /**
  31634. * Creates a new LoadFileError
  31635. * @param message defines the message of the error
  31636. * @param request defines the optional web request
  31637. */
  31638. constructor(message: string,
  31639. /** defines the optional web request */
  31640. request?: WebRequest | undefined);
  31641. }
  31642. /**
  31643. * Class used to define a retry strategy when error happens while loading assets
  31644. */
  31645. export class RetryStrategy {
  31646. /**
  31647. * Function used to defines an exponential back off strategy
  31648. * @param maxRetries defines the maximum number of retries (3 by default)
  31649. * @param baseInterval defines the interval between retries
  31650. * @returns the strategy function to use
  31651. */
  31652. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31653. }
  31654. /**
  31655. * File request interface
  31656. */
  31657. export interface IFileRequest {
  31658. /**
  31659. * Raised when the request is complete (success or error).
  31660. */
  31661. onCompleteObservable: Observable<IFileRequest>;
  31662. /**
  31663. * Aborts the request for a file.
  31664. */
  31665. abort: () => void;
  31666. }
  31667. /**
  31668. * Class containing a set of static utilities functions
  31669. */
  31670. export class Tools {
  31671. /**
  31672. * Gets or sets the base URL to use to load assets
  31673. */
  31674. static BaseUrl: string;
  31675. /**
  31676. * Enable/Disable Custom HTTP Request Headers globally.
  31677. * default = false
  31678. * @see CustomRequestHeaders
  31679. */
  31680. static UseCustomRequestHeaders: boolean;
  31681. /**
  31682. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31683. * i.e. when loading files, where the server/service expects an Authorization header
  31684. */
  31685. static CustomRequestHeaders: {
  31686. [key: string]: string;
  31687. };
  31688. /**
  31689. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31690. */
  31691. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31692. /**
  31693. * Default behaviour for cors in the application.
  31694. * It can be a string if the expected behavior is identical in the entire app.
  31695. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31696. */
  31697. static CorsBehavior: string | ((url: string | string[]) => string);
  31698. /**
  31699. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31700. * @ignorenaming
  31701. */
  31702. static UseFallbackTexture: boolean;
  31703. /**
  31704. * Use this object to register external classes like custom textures or material
  31705. * to allow the laoders to instantiate them
  31706. */
  31707. static RegisteredExternalClasses: {
  31708. [key: string]: Object;
  31709. };
  31710. /**
  31711. * Texture content used if a texture cannot loaded
  31712. * @ignorenaming
  31713. */
  31714. static fallbackTexture: string;
  31715. /**
  31716. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31717. * @param u defines the coordinate on X axis
  31718. * @param v defines the coordinate on Y axis
  31719. * @param width defines the width of the source data
  31720. * @param height defines the height of the source data
  31721. * @param pixels defines the source byte array
  31722. * @param color defines the output color
  31723. */
  31724. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31725. /**
  31726. * Interpolates between a and b via alpha
  31727. * @param a The lower value (returned when alpha = 0)
  31728. * @param b The upper value (returned when alpha = 1)
  31729. * @param alpha The interpolation-factor
  31730. * @return The mixed value
  31731. */
  31732. static Mix(a: number, b: number, alpha: number): number;
  31733. /**
  31734. * Tries to instantiate a new object from a given class name
  31735. * @param className defines the class name to instantiate
  31736. * @returns the new object or null if the system was not able to do the instantiation
  31737. */
  31738. static Instantiate(className: string): any;
  31739. /**
  31740. * Provides a slice function that will work even on IE
  31741. * @param data defines the array to slice
  31742. * @param start defines the start of the data (optional)
  31743. * @param end defines the end of the data (optional)
  31744. * @returns the new sliced array
  31745. */
  31746. static Slice<T>(data: T, start?: number, end?: number): T;
  31747. /**
  31748. * Polyfill for setImmediate
  31749. * @param action defines the action to execute after the current execution block
  31750. */
  31751. static SetImmediate(action: () => void): void;
  31752. /**
  31753. * Function indicating if a number is an exponent of 2
  31754. * @param value defines the value to test
  31755. * @returns true if the value is an exponent of 2
  31756. */
  31757. static IsExponentOfTwo(value: number): boolean;
  31758. private static _tmpFloatArray;
  31759. /**
  31760. * Returns the nearest 32-bit single precision float representation of a Number
  31761. * @param value A Number. If the parameter is of a different type, it will get converted
  31762. * to a number or to NaN if it cannot be converted
  31763. * @returns number
  31764. */
  31765. static FloatRound(value: number): number;
  31766. /**
  31767. * Find the next highest power of two.
  31768. * @param x Number to start search from.
  31769. * @return Next highest power of two.
  31770. */
  31771. static CeilingPOT(x: number): number;
  31772. /**
  31773. * Find the next lowest power of two.
  31774. * @param x Number to start search from.
  31775. * @return Next lowest power of two.
  31776. */
  31777. static FloorPOT(x: number): number;
  31778. /**
  31779. * Find the nearest power of two.
  31780. * @param x Number to start search from.
  31781. * @return Next nearest power of two.
  31782. */
  31783. static NearestPOT(x: number): number;
  31784. /**
  31785. * Get the closest exponent of two
  31786. * @param value defines the value to approximate
  31787. * @param max defines the maximum value to return
  31788. * @param mode defines how to define the closest value
  31789. * @returns closest exponent of two of the given value
  31790. */
  31791. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31792. /**
  31793. * Extracts the filename from a path
  31794. * @param path defines the path to use
  31795. * @returns the filename
  31796. */
  31797. static GetFilename(path: string): string;
  31798. /**
  31799. * Extracts the "folder" part of a path (everything before the filename).
  31800. * @param uri The URI to extract the info from
  31801. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31802. * @returns The "folder" part of the path
  31803. */
  31804. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31805. /**
  31806. * Extracts text content from a DOM element hierarchy
  31807. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31808. */
  31809. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31810. /**
  31811. * Convert an angle in radians to degrees
  31812. * @param angle defines the angle to convert
  31813. * @returns the angle in degrees
  31814. */
  31815. static ToDegrees(angle: number): number;
  31816. /**
  31817. * Convert an angle in degrees to radians
  31818. * @param angle defines the angle to convert
  31819. * @returns the angle in radians
  31820. */
  31821. static ToRadians(angle: number): number;
  31822. /**
  31823. * Encode a buffer to a base64 string
  31824. * @param buffer defines the buffer to encode
  31825. * @returns the encoded string
  31826. */
  31827. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31828. /**
  31829. * Extracts minimum and maximum values from a list of indexed positions
  31830. * @param positions defines the positions to use
  31831. * @param indices defines the indices to the positions
  31832. * @param indexStart defines the start index
  31833. * @param indexCount defines the end index
  31834. * @param bias defines bias value to add to the result
  31835. * @return minimum and maximum values
  31836. */
  31837. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31838. minimum: Vector3;
  31839. maximum: Vector3;
  31840. };
  31841. /**
  31842. * Extracts minimum and maximum values from a list of positions
  31843. * @param positions defines the positions to use
  31844. * @param start defines the start index in the positions array
  31845. * @param count defines the number of positions to handle
  31846. * @param bias defines bias value to add to the result
  31847. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31848. * @return minimum and maximum values
  31849. */
  31850. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31851. minimum: Vector3;
  31852. maximum: Vector3;
  31853. };
  31854. /**
  31855. * Returns an array if obj is not an array
  31856. * @param obj defines the object to evaluate as an array
  31857. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31858. * @returns either obj directly if obj is an array or a new array containing obj
  31859. */
  31860. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31861. /**
  31862. * Gets the pointer prefix to use
  31863. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31864. */
  31865. static GetPointerPrefix(): string;
  31866. /**
  31867. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31868. * @param func - the function to be called
  31869. * @param requester - the object that will request the next frame. Falls back to window.
  31870. * @returns frame number
  31871. */
  31872. static QueueNewFrame(func: () => void, requester?: any): number;
  31873. /**
  31874. * Ask the browser to promote the current element to fullscreen rendering mode
  31875. * @param element defines the DOM element to promote
  31876. */
  31877. static RequestFullscreen(element: HTMLElement): void;
  31878. /**
  31879. * Asks the browser to exit fullscreen mode
  31880. */
  31881. static ExitFullscreen(): void;
  31882. /**
  31883. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31884. * @param url define the url we are trying
  31885. * @param element define the dom element where to configure the cors policy
  31886. */
  31887. static SetCorsBehavior(url: string | string[], element: {
  31888. crossOrigin: string | null;
  31889. }): void;
  31890. /**
  31891. * Removes unwanted characters from an url
  31892. * @param url defines the url to clean
  31893. * @returns the cleaned url
  31894. */
  31895. static CleanUrl(url: string): string;
  31896. /**
  31897. * Gets or sets a function used to pre-process url before using them to load assets
  31898. */
  31899. static PreprocessUrl: (url: string) => string;
  31900. /**
  31901. * Loads an image as an HTMLImageElement.
  31902. * @param input url string, ArrayBuffer, or Blob to load
  31903. * @param onLoad callback called when the image successfully loads
  31904. * @param onError callback called when the image fails to load
  31905. * @param offlineProvider offline provider for caching
  31906. * @returns the HTMLImageElement of the loaded image
  31907. */
  31908. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31909. /**
  31910. * Loads a file
  31911. * @param url url string, ArrayBuffer, or Blob to load
  31912. * @param onSuccess callback called when the file successfully loads
  31913. * @param onProgress callback called while file is loading (if the server supports this mode)
  31914. * @param offlineProvider defines the offline provider for caching
  31915. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31916. * @param onError callback called when the file fails to load
  31917. * @returns a file request object
  31918. */
  31919. 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;
  31920. /**
  31921. * Load a script (identified by an url). When the url returns, the
  31922. * content of this file is added into a new script element, attached to the DOM (body element)
  31923. * @param scriptUrl defines the url of the script to laod
  31924. * @param onSuccess defines the callback called when the script is loaded
  31925. * @param onError defines the callback to call if an error occurs
  31926. * @param scriptId defines the id of the script element
  31927. */
  31928. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31929. /**
  31930. * Load an asynchronous script (identified by an url). When the url returns, the
  31931. * content of this file is added into a new script element, attached to the DOM (body element)
  31932. * @param scriptUrl defines the url of the script to laod
  31933. * @param scriptId defines the id of the script element
  31934. * @returns a promise request object
  31935. */
  31936. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31937. /**
  31938. * Loads a file from a blob
  31939. * @param fileToLoad defines the blob to use
  31940. * @param callback defines the callback to call when data is loaded
  31941. * @param progressCallback defines the callback to call during loading process
  31942. * @returns a file request object
  31943. */
  31944. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31945. /**
  31946. * Loads a file
  31947. * @param fileToLoad defines the file to load
  31948. * @param callback defines the callback to call when data is loaded
  31949. * @param progressCallBack defines the callback to call during loading process
  31950. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31951. * @returns a file request object
  31952. */
  31953. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31954. /**
  31955. * Creates a data url from a given string content
  31956. * @param content defines the content to convert
  31957. * @returns the new data url link
  31958. */
  31959. static FileAsURL(content: string): string;
  31960. /**
  31961. * Format the given number to a specific decimal format
  31962. * @param value defines the number to format
  31963. * @param decimals defines the number of decimals to use
  31964. * @returns the formatted string
  31965. */
  31966. static Format(value: number, decimals?: number): string;
  31967. /**
  31968. * Checks if a given vector is inside a specific range
  31969. * @param v defines the vector to test
  31970. * @param min defines the minimum range
  31971. * @param max defines the maximum range
  31972. */
  31973. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31974. /**
  31975. * Tries to copy an object by duplicating every property
  31976. * @param source defines the source object
  31977. * @param destination defines the target object
  31978. * @param doNotCopyList defines a list of properties to avoid
  31979. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31980. */
  31981. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31982. /**
  31983. * Gets a boolean indicating if the given object has no own property
  31984. * @param obj defines the object to test
  31985. * @returns true if object has no own property
  31986. */
  31987. static IsEmpty(obj: any): boolean;
  31988. /**
  31989. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31990. * @param str Source string
  31991. * @param suffix Suffix to search for in the source string
  31992. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31993. */
  31994. static EndsWith(str: string, suffix: string): boolean;
  31995. /**
  31996. * Function used to register events at window level
  31997. * @param events defines the events to register
  31998. */
  31999. static RegisterTopRootEvents(events: {
  32000. name: string;
  32001. handler: Nullable<(e: FocusEvent) => any>;
  32002. }[]): void;
  32003. /**
  32004. * Function used to unregister events from window level
  32005. * @param events defines the events to unregister
  32006. */
  32007. static UnregisterTopRootEvents(events: {
  32008. name: string;
  32009. handler: Nullable<(e: FocusEvent) => any>;
  32010. }[]): void;
  32011. /**
  32012. * @ignore
  32013. */
  32014. static _ScreenshotCanvas: HTMLCanvasElement;
  32015. /**
  32016. * Dumps the current bound framebuffer
  32017. * @param width defines the rendering width
  32018. * @param height defines the rendering height
  32019. * @param engine defines the hosting engine
  32020. * @param successCallback defines the callback triggered once the data are available
  32021. * @param mimeType defines the mime type of the result
  32022. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32023. */
  32024. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32025. /**
  32026. * Converts the canvas data to blob.
  32027. * This acts as a polyfill for browsers not supporting the to blob function.
  32028. * @param canvas Defines the canvas to extract the data from
  32029. * @param successCallback Defines the callback triggered once the data are available
  32030. * @param mimeType Defines the mime type of the result
  32031. */
  32032. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32033. /**
  32034. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32035. * @param successCallback defines the callback triggered once the data are available
  32036. * @param mimeType defines the mime type of the result
  32037. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32038. */
  32039. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32040. /**
  32041. * Downloads a blob in the browser
  32042. * @param blob defines the blob to download
  32043. * @param fileName defines the name of the downloaded file
  32044. */
  32045. static Download(blob: Blob, fileName: string): void;
  32046. /**
  32047. * Captures a screenshot of the current rendering
  32048. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32049. * @param engine defines the rendering engine
  32050. * @param camera defines the source camera
  32051. * @param size This parameter can be set to a single number or to an object with the
  32052. * following (optional) properties: precision, width, height. If a single number is passed,
  32053. * it will be used for both width and height. If an object is passed, the screenshot size
  32054. * will be derived from the parameters. The precision property is a multiplier allowing
  32055. * rendering at a higher or lower resolution
  32056. * @param successCallback defines the callback receives a single parameter which contains the
  32057. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32058. * src parameter of an <img> to display it
  32059. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32060. * Check your browser for supported MIME types
  32061. */
  32062. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32063. /**
  32064. * Generates an image screenshot from the specified camera.
  32065. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32066. * @param engine The engine to use for rendering
  32067. * @param camera The camera to use for rendering
  32068. * @param size This parameter can be set to a single number or to an object with the
  32069. * following (optional) properties: precision, width, height. If a single number is passed,
  32070. * it will be used for both width and height. If an object is passed, the screenshot size
  32071. * will be derived from the parameters. The precision property is a multiplier allowing
  32072. * rendering at a higher or lower resolution
  32073. * @param successCallback The callback receives a single parameter which contains the
  32074. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32075. * src parameter of an <img> to display it
  32076. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32077. * Check your browser for supported MIME types
  32078. * @param samples Texture samples (default: 1)
  32079. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32080. * @param fileName A name for for the downloaded file.
  32081. */
  32082. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32083. /**
  32084. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32085. * Be aware Math.random() could cause collisions, but:
  32086. * "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"
  32087. * @returns a pseudo random id
  32088. */
  32089. static RandomId(): string;
  32090. /**
  32091. * Test if the given uri is a base64 string
  32092. * @param uri The uri to test
  32093. * @return True if the uri is a base64 string or false otherwise
  32094. */
  32095. static IsBase64(uri: string): boolean;
  32096. /**
  32097. * Decode the given base64 uri.
  32098. * @param uri The uri to decode
  32099. * @return The decoded base64 data.
  32100. */
  32101. static DecodeBase64(uri: string): ArrayBuffer;
  32102. /**
  32103. * Gets the absolute url.
  32104. * @param url the input url
  32105. * @return the absolute url
  32106. */
  32107. static GetAbsoluteUrl(url: string): string;
  32108. /**
  32109. * No log
  32110. */
  32111. static readonly NoneLogLevel: number;
  32112. /**
  32113. * Only message logs
  32114. */
  32115. static readonly MessageLogLevel: number;
  32116. /**
  32117. * Only warning logs
  32118. */
  32119. static readonly WarningLogLevel: number;
  32120. /**
  32121. * Only error logs
  32122. */
  32123. static readonly ErrorLogLevel: number;
  32124. /**
  32125. * All logs
  32126. */
  32127. static readonly AllLogLevel: number;
  32128. /**
  32129. * Gets a value indicating the number of loading errors
  32130. * @ignorenaming
  32131. */
  32132. static readonly errorsCount: number;
  32133. /**
  32134. * Callback called when a new log is added
  32135. */
  32136. static OnNewCacheEntry: (entry: string) => void;
  32137. /**
  32138. * Log a message to the console
  32139. * @param message defines the message to log
  32140. */
  32141. static Log(message: string): void;
  32142. /**
  32143. * Write a warning message to the console
  32144. * @param message defines the message to log
  32145. */
  32146. static Warn(message: string): void;
  32147. /**
  32148. * Write an error message to the console
  32149. * @param message defines the message to log
  32150. */
  32151. static Error(message: string): void;
  32152. /**
  32153. * Gets current log cache (list of logs)
  32154. */
  32155. static readonly LogCache: string;
  32156. /**
  32157. * Clears the log cache
  32158. */
  32159. static ClearLogCache(): void;
  32160. /**
  32161. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32162. */
  32163. static LogLevels: number;
  32164. /**
  32165. * Checks if the loaded document was accessed via `file:`-Protocol.
  32166. * @returns boolean
  32167. */
  32168. static IsFileURL(): boolean;
  32169. /**
  32170. * Checks if the window object exists
  32171. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32172. */
  32173. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32174. /**
  32175. * No performance log
  32176. */
  32177. static readonly PerformanceNoneLogLevel: number;
  32178. /**
  32179. * Use user marks to log performance
  32180. */
  32181. static readonly PerformanceUserMarkLogLevel: number;
  32182. /**
  32183. * Log performance to the console
  32184. */
  32185. static readonly PerformanceConsoleLogLevel: number;
  32186. private static _performance;
  32187. /**
  32188. * Sets the current performance log level
  32189. */
  32190. static PerformanceLogLevel: number;
  32191. private static _StartPerformanceCounterDisabled;
  32192. private static _EndPerformanceCounterDisabled;
  32193. private static _StartUserMark;
  32194. private static _EndUserMark;
  32195. private static _StartPerformanceConsole;
  32196. private static _EndPerformanceConsole;
  32197. /**
  32198. * Starts a performance counter
  32199. */
  32200. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32201. /**
  32202. * Ends a specific performance coutner
  32203. */
  32204. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32205. /**
  32206. * Gets either window.performance.now() if supported or Date.now() else
  32207. */
  32208. static readonly Now: number;
  32209. /**
  32210. * This method will return the name of the class used to create the instance of the given object.
  32211. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32212. * @param object the object to get the class name from
  32213. * @param isType defines if the object is actually a type
  32214. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32215. */
  32216. static GetClassName(object: any, isType?: boolean): string;
  32217. /**
  32218. * Gets the first element of an array satisfying a given predicate
  32219. * @param array defines the array to browse
  32220. * @param predicate defines the predicate to use
  32221. * @returns null if not found or the element
  32222. */
  32223. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32224. /**
  32225. * This method will return the name of the full name of the class, including its owning module (if any).
  32226. * 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).
  32227. * @param object the object to get the class name from
  32228. * @param isType defines if the object is actually a type
  32229. * @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.
  32230. * @ignorenaming
  32231. */
  32232. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32233. /**
  32234. * Returns a promise that resolves after the given amount of time.
  32235. * @param delay Number of milliseconds to delay
  32236. * @returns Promise that resolves after the given amount of time
  32237. */
  32238. static DelayAsync(delay: number): Promise<void>;
  32239. /**
  32240. * Gets the current gradient from an array of IValueGradient
  32241. * @param ratio defines the current ratio to get
  32242. * @param gradients defines the array of IValueGradient
  32243. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32244. */
  32245. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32246. }
  32247. /**
  32248. * This class is used to track a performance counter which is number based.
  32249. * The user has access to many properties which give statistics of different nature.
  32250. *
  32251. * The implementer can track two kinds of Performance Counter: time and count.
  32252. * 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.
  32253. * 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.
  32254. */
  32255. export class PerfCounter {
  32256. /**
  32257. * Gets or sets a global boolean to turn on and off all the counters
  32258. */
  32259. static Enabled: boolean;
  32260. /**
  32261. * Returns the smallest value ever
  32262. */
  32263. readonly min: number;
  32264. /**
  32265. * Returns the biggest value ever
  32266. */
  32267. readonly max: number;
  32268. /**
  32269. * Returns the average value since the performance counter is running
  32270. */
  32271. readonly average: number;
  32272. /**
  32273. * Returns the average value of the last second the counter was monitored
  32274. */
  32275. readonly lastSecAverage: number;
  32276. /**
  32277. * Returns the current value
  32278. */
  32279. readonly current: number;
  32280. /**
  32281. * Gets the accumulated total
  32282. */
  32283. readonly total: number;
  32284. /**
  32285. * Gets the total value count
  32286. */
  32287. readonly count: number;
  32288. /**
  32289. * Creates a new counter
  32290. */
  32291. constructor();
  32292. /**
  32293. * Call this method to start monitoring a new frame.
  32294. * 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.
  32295. */
  32296. fetchNewFrame(): void;
  32297. /**
  32298. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32299. * @param newCount the count value to add to the monitored count
  32300. * @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.
  32301. */
  32302. addCount(newCount: number, fetchResult: boolean): void;
  32303. /**
  32304. * Start monitoring this performance counter
  32305. */
  32306. beginMonitoring(): void;
  32307. /**
  32308. * Compute the time lapsed since the previous beginMonitoring() call.
  32309. * @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
  32310. */
  32311. endMonitoring(newFrame?: boolean): void;
  32312. private _fetchResult;
  32313. private _startMonitoringTime;
  32314. private _min;
  32315. private _max;
  32316. private _average;
  32317. private _current;
  32318. private _totalValueCount;
  32319. private _totalAccumulated;
  32320. private _lastSecAverage;
  32321. private _lastSecAccumulated;
  32322. private _lastSecTime;
  32323. private _lastSecValueCount;
  32324. }
  32325. /**
  32326. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32327. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32328. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32329. * @param name The name of the class, case should be preserved
  32330. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32331. */
  32332. export function className(name: string, module?: string): (target: Object) => void;
  32333. /**
  32334. * An implementation of a loop for asynchronous functions.
  32335. */
  32336. export class AsyncLoop {
  32337. /**
  32338. * Defines the number of iterations for the loop
  32339. */
  32340. iterations: number;
  32341. /**
  32342. * Defines the current index of the loop.
  32343. */
  32344. index: number;
  32345. private _done;
  32346. private _fn;
  32347. private _successCallback;
  32348. /**
  32349. * Constructor.
  32350. * @param iterations the number of iterations.
  32351. * @param func the function to run each iteration
  32352. * @param successCallback the callback that will be called upon succesful execution
  32353. * @param offset starting offset.
  32354. */
  32355. constructor(
  32356. /**
  32357. * Defines the number of iterations for the loop
  32358. */
  32359. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32360. /**
  32361. * Execute the next iteration. Must be called after the last iteration was finished.
  32362. */
  32363. executeNext(): void;
  32364. /**
  32365. * Break the loop and run the success callback.
  32366. */
  32367. breakLoop(): void;
  32368. /**
  32369. * Create and run an async loop.
  32370. * @param iterations the number of iterations.
  32371. * @param fn the function to run each iteration
  32372. * @param successCallback the callback that will be called upon succesful execution
  32373. * @param offset starting offset.
  32374. * @returns the created async loop object
  32375. */
  32376. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32377. /**
  32378. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32379. * @param iterations total number of iterations
  32380. * @param syncedIterations number of synchronous iterations in each async iteration.
  32381. * @param fn the function to call each iteration.
  32382. * @param callback a success call back that will be called when iterating stops.
  32383. * @param breakFunction a break condition (optional)
  32384. * @param timeout timeout settings for the setTimeout function. default - 0.
  32385. * @returns the created async loop object
  32386. */
  32387. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32388. }
  32389. }
  32390. declare module "babylonjs/Collisions/collisionCoordinator" {
  32391. import { Nullable } from "babylonjs/types";
  32392. import { Scene } from "babylonjs/scene";
  32393. import { Vector3 } from "babylonjs/Maths/math";
  32394. import { Collider } from "babylonjs/Collisions/collider";
  32395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32396. /** @hidden */
  32397. export interface ICollisionCoordinator {
  32398. createCollider(): Collider;
  32399. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32400. init(scene: Scene): void;
  32401. }
  32402. /** @hidden */
  32403. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32404. private _scene;
  32405. private _scaledPosition;
  32406. private _scaledVelocity;
  32407. private _finalPosition;
  32408. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32409. createCollider(): Collider;
  32410. init(scene: Scene): void;
  32411. private _collideWithWorld;
  32412. }
  32413. }
  32414. declare module "babylonjs/Inputs/scene.inputManager" {
  32415. import { Nullable } from "babylonjs/types";
  32416. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32417. import { Vector2 } from "babylonjs/Maths/math";
  32418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32419. import { Scene } from "babylonjs/scene";
  32420. /**
  32421. * Class used to manage all inputs for the scene.
  32422. */
  32423. export class InputManager {
  32424. /** The distance in pixel that you have to move to prevent some events */
  32425. static DragMovementThreshold: number;
  32426. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32427. static LongPressDelay: number;
  32428. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32429. static DoubleClickDelay: number;
  32430. /** If you need to check double click without raising a single click at first click, enable this flag */
  32431. static ExclusiveDoubleClickMode: boolean;
  32432. private _wheelEventName;
  32433. private _onPointerMove;
  32434. private _onPointerDown;
  32435. private _onPointerUp;
  32436. private _initClickEvent;
  32437. private _initActionManager;
  32438. private _delayedSimpleClick;
  32439. private _delayedSimpleClickTimeout;
  32440. private _previousDelayedSimpleClickTimeout;
  32441. private _meshPickProceed;
  32442. private _previousButtonPressed;
  32443. private _currentPickResult;
  32444. private _previousPickResult;
  32445. private _totalPointersPressed;
  32446. private _doubleClickOccured;
  32447. private _pointerOverMesh;
  32448. private _pickedDownMesh;
  32449. private _pickedUpMesh;
  32450. private _pointerX;
  32451. private _pointerY;
  32452. private _unTranslatedPointerX;
  32453. private _unTranslatedPointerY;
  32454. private _startingPointerPosition;
  32455. private _previousStartingPointerPosition;
  32456. private _startingPointerTime;
  32457. private _previousStartingPointerTime;
  32458. private _pointerCaptures;
  32459. private _onKeyDown;
  32460. private _onKeyUp;
  32461. private _onCanvasFocusObserver;
  32462. private _onCanvasBlurObserver;
  32463. private _scene;
  32464. /**
  32465. * Creates a new InputManager
  32466. * @param scene defines the hosting scene
  32467. */
  32468. constructor(scene: Scene);
  32469. /**
  32470. * Gets the mesh that is currently under the pointer
  32471. */
  32472. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32473. /**
  32474. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32475. */
  32476. readonly unTranslatedPointer: Vector2;
  32477. /**
  32478. * Gets or sets the current on-screen X position of the pointer
  32479. */
  32480. pointerX: number;
  32481. /**
  32482. * Gets or sets the current on-screen Y position of the pointer
  32483. */
  32484. pointerY: number;
  32485. private _updatePointerPosition;
  32486. private _processPointerMove;
  32487. private _setRayOnPointerInfo;
  32488. private _checkPrePointerObservable;
  32489. /**
  32490. * Use this method to simulate a pointer move on a mesh
  32491. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32492. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32493. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32494. */
  32495. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32496. /**
  32497. * Use this method to simulate a pointer down on a mesh
  32498. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32499. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32500. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32501. */
  32502. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32503. private _processPointerDown;
  32504. /** @hidden */
  32505. _isPointerSwiping(): boolean;
  32506. /**
  32507. * Use this method to simulate a pointer up on a mesh
  32508. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32509. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32510. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32511. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32512. */
  32513. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32514. private _processPointerUp;
  32515. /**
  32516. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32517. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32518. * @returns true if the pointer was captured
  32519. */
  32520. isPointerCaptured(pointerId?: number): boolean;
  32521. /**
  32522. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32523. * @param attachUp defines if you want to attach events to pointerup
  32524. * @param attachDown defines if you want to attach events to pointerdown
  32525. * @param attachMove defines if you want to attach events to pointermove
  32526. */
  32527. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32528. /**
  32529. * Detaches all event handlers
  32530. */
  32531. detachControl(): void;
  32532. /**
  32533. * Force the value of meshUnderPointer
  32534. * @param mesh defines the mesh to use
  32535. */
  32536. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32537. /**
  32538. * Gets the mesh under the pointer
  32539. * @returns a Mesh or null if no mesh is under the pointer
  32540. */
  32541. getPointerOverMesh(): Nullable<AbstractMesh>;
  32542. }
  32543. }
  32544. declare module "babylonjs/Animations/animationGroup" {
  32545. import { Animatable } from "babylonjs/Animations/animatable";
  32546. import { Animation } from "babylonjs/Animations/animation";
  32547. import { Scene, IDisposable } from "babylonjs/scene";
  32548. import { Observable } from "babylonjs/Misc/observable";
  32549. import { Nullable } from "babylonjs/types";
  32550. import "babylonjs/Animations/animatable";
  32551. /**
  32552. * This class defines the direct association between an animation and a target
  32553. */
  32554. export class TargetedAnimation {
  32555. /**
  32556. * Animation to perform
  32557. */
  32558. animation: Animation;
  32559. /**
  32560. * Target to animate
  32561. */
  32562. target: any;
  32563. }
  32564. /**
  32565. * Use this class to create coordinated animations on multiple targets
  32566. */
  32567. export class AnimationGroup implements IDisposable {
  32568. /** The name of the animation group */
  32569. name: string;
  32570. private _scene;
  32571. private _targetedAnimations;
  32572. private _animatables;
  32573. private _from;
  32574. private _to;
  32575. private _isStarted;
  32576. private _isPaused;
  32577. private _speedRatio;
  32578. private _loopAnimation;
  32579. /**
  32580. * Gets or sets the unique id of the node
  32581. */
  32582. uniqueId: number;
  32583. /**
  32584. * This observable will notify when one animation have ended
  32585. */
  32586. onAnimationEndObservable: Observable<TargetedAnimation>;
  32587. /**
  32588. * Observer raised when one animation loops
  32589. */
  32590. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32591. /**
  32592. * This observable will notify when all animations have ended.
  32593. */
  32594. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32595. /**
  32596. * This observable will notify when all animations have paused.
  32597. */
  32598. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32599. /**
  32600. * This observable will notify when all animations are playing.
  32601. */
  32602. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32603. /**
  32604. * Gets the first frame
  32605. */
  32606. readonly from: number;
  32607. /**
  32608. * Gets the last frame
  32609. */
  32610. readonly to: number;
  32611. /**
  32612. * Define if the animations are started
  32613. */
  32614. readonly isStarted: boolean;
  32615. /**
  32616. * Gets a value indicating that the current group is playing
  32617. */
  32618. readonly isPlaying: boolean;
  32619. /**
  32620. * Gets or sets the speed ratio to use for all animations
  32621. */
  32622. /**
  32623. * Gets or sets the speed ratio to use for all animations
  32624. */
  32625. speedRatio: number;
  32626. /**
  32627. * Gets or sets if all animations should loop or not
  32628. */
  32629. loopAnimation: boolean;
  32630. /**
  32631. * Gets the targeted animations for this animation group
  32632. */
  32633. readonly targetedAnimations: Array<TargetedAnimation>;
  32634. /**
  32635. * returning the list of animatables controlled by this animation group.
  32636. */
  32637. readonly animatables: Array<Animatable>;
  32638. /**
  32639. * Instantiates a new Animation Group.
  32640. * This helps managing several animations at once.
  32641. * @see http://doc.babylonjs.com/how_to/group
  32642. * @param name Defines the name of the group
  32643. * @param scene Defines the scene the group belongs to
  32644. */
  32645. constructor(
  32646. /** The name of the animation group */
  32647. name: string, scene?: Nullable<Scene>);
  32648. /**
  32649. * Add an animation (with its target) in the group
  32650. * @param animation defines the animation we want to add
  32651. * @param target defines the target of the animation
  32652. * @returns the TargetedAnimation object
  32653. */
  32654. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32655. /**
  32656. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32657. * It can add constant keys at begin or end
  32658. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32659. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32660. * @returns the animation group
  32661. */
  32662. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32663. /**
  32664. * Start all animations on given targets
  32665. * @param loop defines if animations must loop
  32666. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32667. * @param from defines the from key (optional)
  32668. * @param to defines the to key (optional)
  32669. * @returns the current animation group
  32670. */
  32671. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32672. /**
  32673. * Pause all animations
  32674. * @returns the animation group
  32675. */
  32676. pause(): AnimationGroup;
  32677. /**
  32678. * Play all animations to initial state
  32679. * This function will start() the animations if they were not started or will restart() them if they were paused
  32680. * @param loop defines if animations must loop
  32681. * @returns the animation group
  32682. */
  32683. play(loop?: boolean): AnimationGroup;
  32684. /**
  32685. * Reset all animations to initial state
  32686. * @returns the animation group
  32687. */
  32688. reset(): AnimationGroup;
  32689. /**
  32690. * Restart animations from key 0
  32691. * @returns the animation group
  32692. */
  32693. restart(): AnimationGroup;
  32694. /**
  32695. * Stop all animations
  32696. * @returns the animation group
  32697. */
  32698. stop(): AnimationGroup;
  32699. /**
  32700. * Set animation weight for all animatables
  32701. * @param weight defines the weight to use
  32702. * @return the animationGroup
  32703. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32704. */
  32705. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32706. /**
  32707. * Synchronize and normalize all animatables with a source animatable
  32708. * @param root defines the root animatable to synchronize with
  32709. * @return the animationGroup
  32710. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32711. */
  32712. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32713. /**
  32714. * Goes to a specific frame in this animation group
  32715. * @param frame the frame number to go to
  32716. * @return the animationGroup
  32717. */
  32718. goToFrame(frame: number): AnimationGroup;
  32719. /**
  32720. * Dispose all associated resources
  32721. */
  32722. dispose(): void;
  32723. private _checkAnimationGroupEnded;
  32724. /**
  32725. * Clone the current animation group and returns a copy
  32726. * @param newName defines the name of the new group
  32727. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32728. * @returns the new aniamtion group
  32729. */
  32730. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32731. /**
  32732. * Returns a new AnimationGroup object parsed from the source provided.
  32733. * @param parsedAnimationGroup defines the source
  32734. * @param scene defines the scene that will receive the animationGroup
  32735. * @returns a new AnimationGroup
  32736. */
  32737. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32738. /**
  32739. * Returns the string "AnimationGroup"
  32740. * @returns "AnimationGroup"
  32741. */
  32742. getClassName(): string;
  32743. /**
  32744. * Creates a detailled string about the object
  32745. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32746. * @returns a string representing the object
  32747. */
  32748. toString(fullDetails?: boolean): string;
  32749. }
  32750. }
  32751. declare module "babylonjs/scene" {
  32752. import { Nullable } from "babylonjs/types";
  32753. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32754. import { Observable } from "babylonjs/Misc/observable";
  32755. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32756. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32757. import { Geometry } from "babylonjs/Meshes/geometry";
  32758. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32759. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32761. import { Mesh } from "babylonjs/Meshes/mesh";
  32762. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32763. import { Bone } from "babylonjs/Bones/bone";
  32764. import { Skeleton } from "babylonjs/Bones/skeleton";
  32765. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32766. import { Camera } from "babylonjs/Cameras/camera";
  32767. import { AbstractScene } from "babylonjs/abstractScene";
  32768. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32769. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32770. import { Material } from "babylonjs/Materials/material";
  32771. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32772. import { Effect } from "babylonjs/Materials/effect";
  32773. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32774. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32775. import { Light } from "babylonjs/Lights/light";
  32776. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32777. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32778. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32779. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32780. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32781. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32782. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32783. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32784. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32785. import { Engine } from "babylonjs/Engines/engine";
  32786. import { Node } from "babylonjs/node";
  32787. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32788. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32789. import { WebRequest } from "babylonjs/Misc/webRequest";
  32790. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  32791. import { Ray } from "babylonjs/Culling/ray";
  32792. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32793. import { Animation } from "babylonjs/Animations/animation";
  32794. import { Animatable } from "babylonjs/Animations/animatable";
  32795. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32796. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32797. import { Collider } from "babylonjs/Collisions/collider";
  32798. /**
  32799. * Define an interface for all classes that will hold resources
  32800. */
  32801. export interface IDisposable {
  32802. /**
  32803. * Releases all held resources
  32804. */
  32805. dispose(): void;
  32806. }
  32807. /** Interface defining initialization parameters for Scene class */
  32808. export interface SceneOptions {
  32809. /**
  32810. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32811. * It will improve performance when the number of geometries becomes important.
  32812. */
  32813. useGeometryUniqueIdsMap?: boolean;
  32814. /**
  32815. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32816. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32817. */
  32818. useMaterialMeshMap?: boolean;
  32819. /**
  32820. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32821. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32822. */
  32823. useClonedMeshhMap?: boolean;
  32824. }
  32825. /**
  32826. * Represents a scene to be rendered by the engine.
  32827. * @see http://doc.babylonjs.com/features/scene
  32828. */
  32829. export class Scene extends AbstractScene implements IAnimatable {
  32830. private static _uniqueIdCounter;
  32831. /** The fog is deactivated */
  32832. static readonly FOGMODE_NONE: number;
  32833. /** The fog density is following an exponential function */
  32834. static readonly FOGMODE_EXP: number;
  32835. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32836. static readonly FOGMODE_EXP2: number;
  32837. /** The fog density is following a linear function. */
  32838. static readonly FOGMODE_LINEAR: number;
  32839. /**
  32840. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32841. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32842. */
  32843. static MinDeltaTime: number;
  32844. /**
  32845. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32846. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32847. */
  32848. static MaxDeltaTime: number;
  32849. /**
  32850. * Factory used to create the default material.
  32851. * @param name The name of the material to create
  32852. * @param scene The scene to create the material for
  32853. * @returns The default material
  32854. */
  32855. static DefaultMaterialFactory(scene: Scene): Material;
  32856. /**
  32857. * Factory used to create the a collision coordinator.
  32858. * @returns The collision coordinator
  32859. */
  32860. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32861. /** @hidden */
  32862. _inputManager: InputManager;
  32863. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32864. cameraToUseForPointers: Nullable<Camera>;
  32865. /** @hidden */
  32866. readonly _isScene: boolean;
  32867. /**
  32868. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32869. */
  32870. autoClear: boolean;
  32871. /**
  32872. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32873. */
  32874. autoClearDepthAndStencil: boolean;
  32875. /**
  32876. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32877. */
  32878. clearColor: Color4;
  32879. /**
  32880. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32881. */
  32882. ambientColor: Color3;
  32883. /**
  32884. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32885. * It should only be one of the following (if not the default embedded one):
  32886. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32887. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32888. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32889. * The material properties need to be setup according to the type of texture in use.
  32890. */
  32891. environmentBRDFTexture: BaseTexture;
  32892. /** @hidden */
  32893. protected _environmentTexture: Nullable<BaseTexture>;
  32894. /**
  32895. * Texture used in all pbr material as the reflection texture.
  32896. * As in the majority of the scene they are the same (exception for multi room and so on),
  32897. * this is easier to reference from here than from all the materials.
  32898. */
  32899. /**
  32900. * Texture used in all pbr material as the reflection texture.
  32901. * As in the majority of the scene they are the same (exception for multi room and so on),
  32902. * this is easier to set here than in all the materials.
  32903. */
  32904. environmentTexture: Nullable<BaseTexture>;
  32905. /** @hidden */
  32906. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32907. /**
  32908. * Default image processing configuration used either in the rendering
  32909. * Forward main pass or through the imageProcessingPostProcess if present.
  32910. * As in the majority of the scene they are the same (exception for multi camera),
  32911. * this is easier to reference from here than from all the materials and post process.
  32912. *
  32913. * No setter as we it is a shared configuration, you can set the values instead.
  32914. */
  32915. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32916. private _forceWireframe;
  32917. /**
  32918. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32919. */
  32920. forceWireframe: boolean;
  32921. private _forcePointsCloud;
  32922. /**
  32923. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32924. */
  32925. forcePointsCloud: boolean;
  32926. /**
  32927. * Gets or sets the active clipplane 1
  32928. */
  32929. clipPlane: Nullable<Plane>;
  32930. /**
  32931. * Gets or sets the active clipplane 2
  32932. */
  32933. clipPlane2: Nullable<Plane>;
  32934. /**
  32935. * Gets or sets the active clipplane 3
  32936. */
  32937. clipPlane3: Nullable<Plane>;
  32938. /**
  32939. * Gets or sets the active clipplane 4
  32940. */
  32941. clipPlane4: Nullable<Plane>;
  32942. /**
  32943. * Gets or sets a boolean indicating if animations are enabled
  32944. */
  32945. animationsEnabled: boolean;
  32946. private _animationPropertiesOverride;
  32947. /**
  32948. * Gets or sets the animation properties override
  32949. */
  32950. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32951. /**
  32952. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32953. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32954. */
  32955. useConstantAnimationDeltaTime: boolean;
  32956. /**
  32957. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32958. * Please note that it requires to run a ray cast through the scene on every frame
  32959. */
  32960. constantlyUpdateMeshUnderPointer: boolean;
  32961. /**
  32962. * Defines the HTML cursor to use when hovering over interactive elements
  32963. */
  32964. hoverCursor: string;
  32965. /**
  32966. * Defines the HTML default cursor to use (empty by default)
  32967. */
  32968. defaultCursor: string;
  32969. /**
  32970. * This is used to call preventDefault() on pointer down
  32971. * in order to block unwanted artifacts like system double clicks
  32972. */
  32973. preventDefaultOnPointerDown: boolean;
  32974. /**
  32975. * This is used to call preventDefault() on pointer up
  32976. * in order to block unwanted artifacts like system double clicks
  32977. */
  32978. preventDefaultOnPointerUp: boolean;
  32979. /**
  32980. * Gets or sets user defined metadata
  32981. */
  32982. metadata: any;
  32983. /**
  32984. * For internal use only. Please do not use.
  32985. */
  32986. reservedDataStore: any;
  32987. /**
  32988. * Gets the name of the plugin used to load this scene (null by default)
  32989. */
  32990. loadingPluginName: string;
  32991. /**
  32992. * Use this array to add regular expressions used to disable offline support for specific urls
  32993. */
  32994. disableOfflineSupportExceptionRules: RegExp[];
  32995. /**
  32996. * An event triggered when the scene is disposed.
  32997. */
  32998. onDisposeObservable: Observable<Scene>;
  32999. private _onDisposeObserver;
  33000. /** Sets a function to be executed when this scene is disposed. */
  33001. onDispose: () => void;
  33002. /**
  33003. * An event triggered before rendering the scene (right after animations and physics)
  33004. */
  33005. onBeforeRenderObservable: Observable<Scene>;
  33006. private _onBeforeRenderObserver;
  33007. /** Sets a function to be executed before rendering this scene */
  33008. beforeRender: Nullable<() => void>;
  33009. /**
  33010. * An event triggered after rendering the scene
  33011. */
  33012. onAfterRenderObservable: Observable<Scene>;
  33013. private _onAfterRenderObserver;
  33014. /** Sets a function to be executed after rendering this scene */
  33015. afterRender: Nullable<() => void>;
  33016. /**
  33017. * An event triggered before animating the scene
  33018. */
  33019. onBeforeAnimationsObservable: Observable<Scene>;
  33020. /**
  33021. * An event triggered after animations processing
  33022. */
  33023. onAfterAnimationsObservable: Observable<Scene>;
  33024. /**
  33025. * An event triggered before draw calls are ready to be sent
  33026. */
  33027. onBeforeDrawPhaseObservable: Observable<Scene>;
  33028. /**
  33029. * An event triggered after draw calls have been sent
  33030. */
  33031. onAfterDrawPhaseObservable: Observable<Scene>;
  33032. /**
  33033. * An event triggered when the scene is ready
  33034. */
  33035. onReadyObservable: Observable<Scene>;
  33036. /**
  33037. * An event triggered before rendering a camera
  33038. */
  33039. onBeforeCameraRenderObservable: Observable<Camera>;
  33040. private _onBeforeCameraRenderObserver;
  33041. /** Sets a function to be executed before rendering a camera*/
  33042. beforeCameraRender: () => void;
  33043. /**
  33044. * An event triggered after rendering a camera
  33045. */
  33046. onAfterCameraRenderObservable: Observable<Camera>;
  33047. private _onAfterCameraRenderObserver;
  33048. /** Sets a function to be executed after rendering a camera*/
  33049. afterCameraRender: () => void;
  33050. /**
  33051. * An event triggered when active meshes evaluation is about to start
  33052. */
  33053. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33054. /**
  33055. * An event triggered when active meshes evaluation is done
  33056. */
  33057. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33058. /**
  33059. * An event triggered when particles rendering is about to start
  33060. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33061. */
  33062. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33063. /**
  33064. * An event triggered when particles rendering is done
  33065. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33066. */
  33067. onAfterParticlesRenderingObservable: Observable<Scene>;
  33068. /**
  33069. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33070. */
  33071. onDataLoadedObservable: Observable<Scene>;
  33072. /**
  33073. * An event triggered when a camera is created
  33074. */
  33075. onNewCameraAddedObservable: Observable<Camera>;
  33076. /**
  33077. * An event triggered when a camera is removed
  33078. */
  33079. onCameraRemovedObservable: Observable<Camera>;
  33080. /**
  33081. * An event triggered when a light is created
  33082. */
  33083. onNewLightAddedObservable: Observable<Light>;
  33084. /**
  33085. * An event triggered when a light is removed
  33086. */
  33087. onLightRemovedObservable: Observable<Light>;
  33088. /**
  33089. * An event triggered when a geometry is created
  33090. */
  33091. onNewGeometryAddedObservable: Observable<Geometry>;
  33092. /**
  33093. * An event triggered when a geometry is removed
  33094. */
  33095. onGeometryRemovedObservable: Observable<Geometry>;
  33096. /**
  33097. * An event triggered when a transform node is created
  33098. */
  33099. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33100. /**
  33101. * An event triggered when a transform node is removed
  33102. */
  33103. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33104. /**
  33105. * An event triggered when a mesh is created
  33106. */
  33107. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33108. /**
  33109. * An event triggered when a mesh is removed
  33110. */
  33111. onMeshRemovedObservable: Observable<AbstractMesh>;
  33112. /**
  33113. * An event triggered when a skeleton is created
  33114. */
  33115. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33116. /**
  33117. * An event triggered when a skeleton is removed
  33118. */
  33119. onSkeletonRemovedObservable: Observable<Skeleton>;
  33120. /**
  33121. * An event triggered when a material is created
  33122. */
  33123. onNewMaterialAddedObservable: Observable<Material>;
  33124. /**
  33125. * An event triggered when a material is removed
  33126. */
  33127. onMaterialRemovedObservable: Observable<Material>;
  33128. /**
  33129. * An event triggered when a texture is created
  33130. */
  33131. onNewTextureAddedObservable: Observable<BaseTexture>;
  33132. /**
  33133. * An event triggered when a texture is removed
  33134. */
  33135. onTextureRemovedObservable: Observable<BaseTexture>;
  33136. /**
  33137. * An event triggered when render targets are about to be rendered
  33138. * Can happen multiple times per frame.
  33139. */
  33140. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33141. /**
  33142. * An event triggered when render targets were rendered.
  33143. * Can happen multiple times per frame.
  33144. */
  33145. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33146. /**
  33147. * An event triggered before calculating deterministic simulation step
  33148. */
  33149. onBeforeStepObservable: Observable<Scene>;
  33150. /**
  33151. * An event triggered after calculating deterministic simulation step
  33152. */
  33153. onAfterStepObservable: Observable<Scene>;
  33154. /**
  33155. * An event triggered when the activeCamera property is updated
  33156. */
  33157. onActiveCameraChanged: Observable<Scene>;
  33158. /**
  33159. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33160. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33161. * 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)
  33162. */
  33163. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33164. /**
  33165. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33166. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33167. * 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)
  33168. */
  33169. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33170. /**
  33171. * This Observable will when a mesh has been imported into the scene.
  33172. */
  33173. onMeshImportedObservable: Observable<AbstractMesh>;
  33174. /**
  33175. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33176. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33177. */
  33178. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33179. /** @hidden */
  33180. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33181. /**
  33182. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33183. */
  33184. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33185. /**
  33186. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33187. */
  33188. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33189. /**
  33190. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33191. */
  33192. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33193. /** Callback called when a pointer move is detected */
  33194. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33195. /** Callback called when a pointer down is detected */
  33196. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33197. /** Callback called when a pointer up is detected */
  33198. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33199. /** Callback called when a pointer pick is detected */
  33200. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33201. /**
  33202. * 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).
  33203. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33204. */
  33205. onPrePointerObservable: Observable<PointerInfoPre>;
  33206. /**
  33207. * Observable event triggered each time an input event is received from the rendering canvas
  33208. */
  33209. onPointerObservable: Observable<PointerInfo>;
  33210. /**
  33211. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33212. */
  33213. readonly unTranslatedPointer: Vector2;
  33214. /**
  33215. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33216. */
  33217. static DragMovementThreshold: number;
  33218. /**
  33219. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33220. */
  33221. static LongPressDelay: number;
  33222. /**
  33223. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33224. */
  33225. static DoubleClickDelay: number;
  33226. /** If you need to check double click without raising a single click at first click, enable this flag */
  33227. static ExclusiveDoubleClickMode: boolean;
  33228. /** @hidden */
  33229. _mirroredCameraPosition: Nullable<Vector3>;
  33230. /**
  33231. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33232. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33233. */
  33234. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33235. /**
  33236. * Observable event triggered each time an keyboard event is received from the hosting window
  33237. */
  33238. onKeyboardObservable: Observable<KeyboardInfo>;
  33239. private _useRightHandedSystem;
  33240. /**
  33241. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33242. */
  33243. useRightHandedSystem: boolean;
  33244. private _timeAccumulator;
  33245. private _currentStepId;
  33246. private _currentInternalStep;
  33247. /**
  33248. * Sets the step Id used by deterministic lock step
  33249. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33250. * @param newStepId defines the step Id
  33251. */
  33252. setStepId(newStepId: number): void;
  33253. /**
  33254. * Gets the step Id used by deterministic lock step
  33255. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33256. * @returns the step Id
  33257. */
  33258. getStepId(): number;
  33259. /**
  33260. * Gets the internal step used by deterministic lock step
  33261. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33262. * @returns the internal step
  33263. */
  33264. getInternalStep(): number;
  33265. private _fogEnabled;
  33266. /**
  33267. * Gets or sets a boolean indicating if fog is enabled on this scene
  33268. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33269. * (Default is true)
  33270. */
  33271. fogEnabled: boolean;
  33272. private _fogMode;
  33273. /**
  33274. * Gets or sets the fog mode to use
  33275. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33276. * | mode | value |
  33277. * | --- | --- |
  33278. * | FOGMODE_NONE | 0 |
  33279. * | FOGMODE_EXP | 1 |
  33280. * | FOGMODE_EXP2 | 2 |
  33281. * | FOGMODE_LINEAR | 3 |
  33282. */
  33283. fogMode: number;
  33284. /**
  33285. * Gets or sets the fog color to use
  33286. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33287. * (Default is Color3(0.2, 0.2, 0.3))
  33288. */
  33289. fogColor: Color3;
  33290. /**
  33291. * Gets or sets the fog density to use
  33292. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33293. * (Default is 0.1)
  33294. */
  33295. fogDensity: number;
  33296. /**
  33297. * Gets or sets the fog start distance to use
  33298. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33299. * (Default is 0)
  33300. */
  33301. fogStart: number;
  33302. /**
  33303. * Gets or sets the fog end distance to use
  33304. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33305. * (Default is 1000)
  33306. */
  33307. fogEnd: number;
  33308. private _shadowsEnabled;
  33309. /**
  33310. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33311. */
  33312. shadowsEnabled: boolean;
  33313. private _lightsEnabled;
  33314. /**
  33315. * Gets or sets a boolean indicating if lights are enabled on this scene
  33316. */
  33317. lightsEnabled: boolean;
  33318. /** All of the active cameras added to this scene. */
  33319. activeCameras: Camera[];
  33320. /** @hidden */
  33321. _activeCamera: Nullable<Camera>;
  33322. /** Gets or sets the current active camera */
  33323. activeCamera: Nullable<Camera>;
  33324. private _defaultMaterial;
  33325. /** The default material used on meshes when no material is affected */
  33326. /** The default material used on meshes when no material is affected */
  33327. defaultMaterial: Material;
  33328. private _texturesEnabled;
  33329. /**
  33330. * Gets or sets a boolean indicating if textures are enabled on this scene
  33331. */
  33332. texturesEnabled: boolean;
  33333. /**
  33334. * Gets or sets a boolean indicating if particles are enabled on this scene
  33335. */
  33336. particlesEnabled: boolean;
  33337. /**
  33338. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33339. */
  33340. spritesEnabled: boolean;
  33341. private _skeletonsEnabled;
  33342. /**
  33343. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33344. */
  33345. skeletonsEnabled: boolean;
  33346. /**
  33347. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33348. */
  33349. lensFlaresEnabled: boolean;
  33350. /**
  33351. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33352. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33353. */
  33354. collisionsEnabled: boolean;
  33355. private _collisionCoordinator;
  33356. /** @hidden */
  33357. readonly collisionCoordinator: ICollisionCoordinator;
  33358. /**
  33359. * Defines the gravity applied to this scene (used only for collisions)
  33360. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33361. */
  33362. gravity: Vector3;
  33363. /**
  33364. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33365. */
  33366. postProcessesEnabled: boolean;
  33367. /**
  33368. * The list of postprocesses added to the scene
  33369. */
  33370. postProcesses: PostProcess[];
  33371. /**
  33372. * Gets the current postprocess manager
  33373. */
  33374. postProcessManager: PostProcessManager;
  33375. /**
  33376. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33377. */
  33378. renderTargetsEnabled: boolean;
  33379. /**
  33380. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33381. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33382. */
  33383. dumpNextRenderTargets: boolean;
  33384. /**
  33385. * The list of user defined render targets added to the scene
  33386. */
  33387. customRenderTargets: RenderTargetTexture[];
  33388. /**
  33389. * Defines if texture loading must be delayed
  33390. * If true, textures will only be loaded when they need to be rendered
  33391. */
  33392. useDelayedTextureLoading: boolean;
  33393. /**
  33394. * Gets the list of meshes imported to the scene through SceneLoader
  33395. */
  33396. importedMeshesFiles: String[];
  33397. /**
  33398. * Gets or sets a boolean indicating if probes are enabled on this scene
  33399. */
  33400. probesEnabled: boolean;
  33401. /**
  33402. * Gets or sets the current offline provider to use to store scene data
  33403. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33404. */
  33405. offlineProvider: IOfflineProvider;
  33406. /**
  33407. * Gets or sets the action manager associated with the scene
  33408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33409. */
  33410. actionManager: AbstractActionManager;
  33411. private _meshesForIntersections;
  33412. /**
  33413. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33414. */
  33415. proceduralTexturesEnabled: boolean;
  33416. private _engine;
  33417. private _totalVertices;
  33418. /** @hidden */
  33419. _activeIndices: PerfCounter;
  33420. /** @hidden */
  33421. _activeParticles: PerfCounter;
  33422. /** @hidden */
  33423. _activeBones: PerfCounter;
  33424. private _animationRatio;
  33425. /** @hidden */
  33426. _animationTimeLast: number;
  33427. /** @hidden */
  33428. _animationTime: number;
  33429. /**
  33430. * Gets or sets a general scale for animation speed
  33431. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33432. */
  33433. animationTimeScale: number;
  33434. /** @hidden */
  33435. _cachedMaterial: Nullable<Material>;
  33436. /** @hidden */
  33437. _cachedEffect: Nullable<Effect>;
  33438. /** @hidden */
  33439. _cachedVisibility: Nullable<number>;
  33440. private _renderId;
  33441. private _frameId;
  33442. private _executeWhenReadyTimeoutId;
  33443. private _intermediateRendering;
  33444. private _viewUpdateFlag;
  33445. private _projectionUpdateFlag;
  33446. /** @hidden */
  33447. _toBeDisposed: Nullable<IDisposable>[];
  33448. private _activeRequests;
  33449. /** @hidden */
  33450. _pendingData: any[];
  33451. private _isDisposed;
  33452. /**
  33453. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33454. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33455. */
  33456. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33457. private _activeMeshes;
  33458. private _processedMaterials;
  33459. private _renderTargets;
  33460. /** @hidden */
  33461. _activeParticleSystems: SmartArray<IParticleSystem>;
  33462. private _activeSkeletons;
  33463. private _softwareSkinnedMeshes;
  33464. private _renderingManager;
  33465. /** @hidden */
  33466. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33467. private _transformMatrix;
  33468. private _sceneUbo;
  33469. /** @hidden */
  33470. _viewMatrix: Matrix;
  33471. private _projectionMatrix;
  33472. /** @hidden */
  33473. _forcedViewPosition: Nullable<Vector3>;
  33474. /** @hidden */
  33475. _frustumPlanes: Plane[];
  33476. /**
  33477. * Gets the list of frustum planes (built from the active camera)
  33478. */
  33479. readonly frustumPlanes: Plane[];
  33480. /**
  33481. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33482. * This is useful if there are more lights that the maximum simulteanous authorized
  33483. */
  33484. requireLightSorting: boolean;
  33485. /** @hidden */
  33486. readonly useMaterialMeshMap: boolean;
  33487. /** @hidden */
  33488. readonly useClonedMeshhMap: boolean;
  33489. private _externalData;
  33490. private _uid;
  33491. /**
  33492. * @hidden
  33493. * Backing store of defined scene components.
  33494. */
  33495. _components: ISceneComponent[];
  33496. /**
  33497. * @hidden
  33498. * Backing store of defined scene components.
  33499. */
  33500. _serializableComponents: ISceneSerializableComponent[];
  33501. /**
  33502. * List of components to register on the next registration step.
  33503. */
  33504. private _transientComponents;
  33505. /**
  33506. * Registers the transient components if needed.
  33507. */
  33508. private _registerTransientComponents;
  33509. /**
  33510. * @hidden
  33511. * Add a component to the scene.
  33512. * Note that the ccomponent could be registered on th next frame if this is called after
  33513. * the register component stage.
  33514. * @param component Defines the component to add to the scene
  33515. */
  33516. _addComponent(component: ISceneComponent): void;
  33517. /**
  33518. * @hidden
  33519. * Gets a component from the scene.
  33520. * @param name defines the name of the component to retrieve
  33521. * @returns the component or null if not present
  33522. */
  33523. _getComponent(name: string): Nullable<ISceneComponent>;
  33524. /**
  33525. * @hidden
  33526. * Defines the actions happening before camera updates.
  33527. */
  33528. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33529. /**
  33530. * @hidden
  33531. * Defines the actions happening before clear the canvas.
  33532. */
  33533. _beforeClearStage: Stage<SimpleStageAction>;
  33534. /**
  33535. * @hidden
  33536. * Defines the actions when collecting render targets for the frame.
  33537. */
  33538. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33539. /**
  33540. * @hidden
  33541. * Defines the actions happening for one camera in the frame.
  33542. */
  33543. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33544. /**
  33545. * @hidden
  33546. * Defines the actions happening during the per mesh ready checks.
  33547. */
  33548. _isReadyForMeshStage: Stage<MeshStageAction>;
  33549. /**
  33550. * @hidden
  33551. * Defines the actions happening before evaluate active mesh checks.
  33552. */
  33553. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33554. /**
  33555. * @hidden
  33556. * Defines the actions happening during the evaluate sub mesh checks.
  33557. */
  33558. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33559. /**
  33560. * @hidden
  33561. * Defines the actions happening during the active mesh stage.
  33562. */
  33563. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33564. /**
  33565. * @hidden
  33566. * Defines the actions happening during the per camera render target step.
  33567. */
  33568. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33569. /**
  33570. * @hidden
  33571. * Defines the actions happening just before the active camera is drawing.
  33572. */
  33573. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33574. /**
  33575. * @hidden
  33576. * Defines the actions happening just before a render target is drawing.
  33577. */
  33578. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33579. /**
  33580. * @hidden
  33581. * Defines the actions happening just before a rendering group is drawing.
  33582. */
  33583. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33584. /**
  33585. * @hidden
  33586. * Defines the actions happening just before a mesh is drawing.
  33587. */
  33588. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33589. /**
  33590. * @hidden
  33591. * Defines the actions happening just after a mesh has been drawn.
  33592. */
  33593. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33594. /**
  33595. * @hidden
  33596. * Defines the actions happening just after a rendering group has been drawn.
  33597. */
  33598. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33599. /**
  33600. * @hidden
  33601. * Defines the actions happening just after the active camera has been drawn.
  33602. */
  33603. _afterCameraDrawStage: Stage<CameraStageAction>;
  33604. /**
  33605. * @hidden
  33606. * Defines the actions happening just after a render target has been drawn.
  33607. */
  33608. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33609. /**
  33610. * @hidden
  33611. * Defines the actions happening just after rendering all cameras and computing intersections.
  33612. */
  33613. _afterRenderStage: Stage<SimpleStageAction>;
  33614. /**
  33615. * @hidden
  33616. * Defines the actions happening when a pointer move event happens.
  33617. */
  33618. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33619. /**
  33620. * @hidden
  33621. * Defines the actions happening when a pointer down event happens.
  33622. */
  33623. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33624. /**
  33625. * @hidden
  33626. * Defines the actions happening when a pointer up event happens.
  33627. */
  33628. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33629. /**
  33630. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33631. */
  33632. private geometriesByUniqueId;
  33633. /**
  33634. * Creates a new Scene
  33635. * @param engine defines the engine to use to render this scene
  33636. * @param options defines the scene options
  33637. */
  33638. constructor(engine: Engine, options?: SceneOptions);
  33639. /**
  33640. * Gets a string idenfifying the name of the class
  33641. * @returns "Scene" string
  33642. */
  33643. getClassName(): string;
  33644. private _defaultMeshCandidates;
  33645. /**
  33646. * @hidden
  33647. */
  33648. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33649. private _defaultSubMeshCandidates;
  33650. /**
  33651. * @hidden
  33652. */
  33653. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33654. /**
  33655. * Sets the default candidate providers for the scene.
  33656. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33657. * and getCollidingSubMeshCandidates to their default function
  33658. */
  33659. setDefaultCandidateProviders(): void;
  33660. /**
  33661. * Gets the mesh that is currently under the pointer
  33662. */
  33663. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33664. /**
  33665. * Gets or sets the current on-screen X position of the pointer
  33666. */
  33667. pointerX: number;
  33668. /**
  33669. * Gets or sets the current on-screen Y position of the pointer
  33670. */
  33671. pointerY: number;
  33672. /**
  33673. * Gets the cached material (ie. the latest rendered one)
  33674. * @returns the cached material
  33675. */
  33676. getCachedMaterial(): Nullable<Material>;
  33677. /**
  33678. * Gets the cached effect (ie. the latest rendered one)
  33679. * @returns the cached effect
  33680. */
  33681. getCachedEffect(): Nullable<Effect>;
  33682. /**
  33683. * Gets the cached visibility state (ie. the latest rendered one)
  33684. * @returns the cached visibility state
  33685. */
  33686. getCachedVisibility(): Nullable<number>;
  33687. /**
  33688. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33689. * @param material defines the current material
  33690. * @param effect defines the current effect
  33691. * @param visibility defines the current visibility state
  33692. * @returns true if one parameter is not cached
  33693. */
  33694. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33695. /**
  33696. * Gets the engine associated with the scene
  33697. * @returns an Engine
  33698. */
  33699. getEngine(): Engine;
  33700. /**
  33701. * Gets the total number of vertices rendered per frame
  33702. * @returns the total number of vertices rendered per frame
  33703. */
  33704. getTotalVertices(): number;
  33705. /**
  33706. * Gets the performance counter for total vertices
  33707. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33708. */
  33709. readonly totalVerticesPerfCounter: PerfCounter;
  33710. /**
  33711. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33712. * @returns the total number of active indices rendered per frame
  33713. */
  33714. getActiveIndices(): number;
  33715. /**
  33716. * Gets the performance counter for active indices
  33717. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33718. */
  33719. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33720. /**
  33721. * Gets the total number of active particles rendered per frame
  33722. * @returns the total number of active particles rendered per frame
  33723. */
  33724. getActiveParticles(): number;
  33725. /**
  33726. * Gets the performance counter for active particles
  33727. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33728. */
  33729. readonly activeParticlesPerfCounter: PerfCounter;
  33730. /**
  33731. * Gets the total number of active bones rendered per frame
  33732. * @returns the total number of active bones rendered per frame
  33733. */
  33734. getActiveBones(): number;
  33735. /**
  33736. * Gets the performance counter for active bones
  33737. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33738. */
  33739. readonly activeBonesPerfCounter: PerfCounter;
  33740. /**
  33741. * Gets the array of active meshes
  33742. * @returns an array of AbstractMesh
  33743. */
  33744. getActiveMeshes(): SmartArray<AbstractMesh>;
  33745. /**
  33746. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33747. * @returns a number
  33748. */
  33749. getAnimationRatio(): number;
  33750. /**
  33751. * Gets an unique Id for the current render phase
  33752. * @returns a number
  33753. */
  33754. getRenderId(): number;
  33755. /**
  33756. * Gets an unique Id for the current frame
  33757. * @returns a number
  33758. */
  33759. getFrameId(): number;
  33760. /** Call this function if you want to manually increment the render Id*/
  33761. incrementRenderId(): void;
  33762. private _createUbo;
  33763. /**
  33764. * Use this method to simulate a pointer move on a mesh
  33765. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33766. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33767. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33768. * @returns the current scene
  33769. */
  33770. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33771. /**
  33772. * Use this method to simulate a pointer down on a mesh
  33773. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33774. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33775. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33776. * @returns the current scene
  33777. */
  33778. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33779. /**
  33780. * Use this method to simulate a pointer up on a mesh
  33781. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33782. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33783. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33784. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33785. * @returns the current scene
  33786. */
  33787. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33788. /**
  33789. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33790. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33791. * @returns true if the pointer was captured
  33792. */
  33793. isPointerCaptured(pointerId?: number): boolean;
  33794. /**
  33795. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33796. * @param attachUp defines if you want to attach events to pointerup
  33797. * @param attachDown defines if you want to attach events to pointerdown
  33798. * @param attachMove defines if you want to attach events to pointermove
  33799. */
  33800. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33801. /** Detaches all event handlers*/
  33802. detachControl(): void;
  33803. /**
  33804. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33805. * Delay loaded resources are not taking in account
  33806. * @return true if all required resources are ready
  33807. */
  33808. isReady(): boolean;
  33809. /** Resets all cached information relative to material (including effect and visibility) */
  33810. resetCachedMaterial(): void;
  33811. /**
  33812. * Registers a function to be called before every frame render
  33813. * @param func defines the function to register
  33814. */
  33815. registerBeforeRender(func: () => void): void;
  33816. /**
  33817. * Unregisters a function called before every frame render
  33818. * @param func defines the function to unregister
  33819. */
  33820. unregisterBeforeRender(func: () => void): void;
  33821. /**
  33822. * Registers a function to be called after every frame render
  33823. * @param func defines the function to register
  33824. */
  33825. registerAfterRender(func: () => void): void;
  33826. /**
  33827. * Unregisters a function called after every frame render
  33828. * @param func defines the function to unregister
  33829. */
  33830. unregisterAfterRender(func: () => void): void;
  33831. private _executeOnceBeforeRender;
  33832. /**
  33833. * The provided function will run before render once and will be disposed afterwards.
  33834. * A timeout delay can be provided so that the function will be executed in N ms.
  33835. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33836. * @param func The function to be executed.
  33837. * @param timeout optional delay in ms
  33838. */
  33839. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33840. /** @hidden */
  33841. _addPendingData(data: any): void;
  33842. /** @hidden */
  33843. _removePendingData(data: any): void;
  33844. /**
  33845. * Returns the number of items waiting to be loaded
  33846. * @returns the number of items waiting to be loaded
  33847. */
  33848. getWaitingItemsCount(): number;
  33849. /**
  33850. * Returns a boolean indicating if the scene is still loading data
  33851. */
  33852. readonly isLoading: boolean;
  33853. /**
  33854. * Registers a function to be executed when the scene is ready
  33855. * @param {Function} func - the function to be executed
  33856. */
  33857. executeWhenReady(func: () => void): void;
  33858. /**
  33859. * Returns a promise that resolves when the scene is ready
  33860. * @returns A promise that resolves when the scene is ready
  33861. */
  33862. whenReadyAsync(): Promise<void>;
  33863. /** @hidden */
  33864. _checkIsReady(): void;
  33865. /**
  33866. * Gets all animatable attached to the scene
  33867. */
  33868. readonly animatables: Animatable[];
  33869. /**
  33870. * Resets the last animation time frame.
  33871. * Useful to override when animations start running when loading a scene for the first time.
  33872. */
  33873. resetLastAnimationTimeFrame(): void;
  33874. /**
  33875. * Gets the current view matrix
  33876. * @returns a Matrix
  33877. */
  33878. getViewMatrix(): Matrix;
  33879. /**
  33880. * Gets the current projection matrix
  33881. * @returns a Matrix
  33882. */
  33883. getProjectionMatrix(): Matrix;
  33884. /**
  33885. * Gets the current transform matrix
  33886. * @returns a Matrix made of View * Projection
  33887. */
  33888. getTransformMatrix(): Matrix;
  33889. /**
  33890. * Sets the current transform matrix
  33891. * @param viewL defines the View matrix to use
  33892. * @param projectionL defines the Projection matrix to use
  33893. * @param viewR defines the right View matrix to use (if provided)
  33894. * @param projectionR defines the right Projection matrix to use (if provided)
  33895. */
  33896. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33897. /**
  33898. * Gets the uniform buffer used to store scene data
  33899. * @returns a UniformBuffer
  33900. */
  33901. getSceneUniformBuffer(): UniformBuffer;
  33902. /**
  33903. * Gets an unique (relatively to the current scene) Id
  33904. * @returns an unique number for the scene
  33905. */
  33906. getUniqueId(): number;
  33907. /**
  33908. * Add a mesh to the list of scene's meshes
  33909. * @param newMesh defines the mesh to add
  33910. * @param recursive if all child meshes should also be added to the scene
  33911. */
  33912. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33913. /**
  33914. * Remove a mesh for the list of scene's meshes
  33915. * @param toRemove defines the mesh to remove
  33916. * @param recursive if all child meshes should also be removed from the scene
  33917. * @returns the index where the mesh was in the mesh list
  33918. */
  33919. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33920. /**
  33921. * Add a transform node to the list of scene's transform nodes
  33922. * @param newTransformNode defines the transform node to add
  33923. */
  33924. addTransformNode(newTransformNode: TransformNode): void;
  33925. /**
  33926. * Remove a transform node for the list of scene's transform nodes
  33927. * @param toRemove defines the transform node to remove
  33928. * @returns the index where the transform node was in the transform node list
  33929. */
  33930. removeTransformNode(toRemove: TransformNode): number;
  33931. /**
  33932. * Remove a skeleton for the list of scene's skeletons
  33933. * @param toRemove defines the skeleton to remove
  33934. * @returns the index where the skeleton was in the skeleton list
  33935. */
  33936. removeSkeleton(toRemove: Skeleton): number;
  33937. /**
  33938. * Remove a morph target for the list of scene's morph targets
  33939. * @param toRemove defines the morph target to remove
  33940. * @returns the index where the morph target was in the morph target list
  33941. */
  33942. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33943. /**
  33944. * Remove a light for the list of scene's lights
  33945. * @param toRemove defines the light to remove
  33946. * @returns the index where the light was in the light list
  33947. */
  33948. removeLight(toRemove: Light): number;
  33949. /**
  33950. * Remove a camera for the list of scene's cameras
  33951. * @param toRemove defines the camera to remove
  33952. * @returns the index where the camera was in the camera list
  33953. */
  33954. removeCamera(toRemove: Camera): number;
  33955. /**
  33956. * Remove a particle system for the list of scene's particle systems
  33957. * @param toRemove defines the particle system to remove
  33958. * @returns the index where the particle system was in the particle system list
  33959. */
  33960. removeParticleSystem(toRemove: IParticleSystem): number;
  33961. /**
  33962. * Remove a animation for the list of scene's animations
  33963. * @param toRemove defines the animation to remove
  33964. * @returns the index where the animation was in the animation list
  33965. */
  33966. removeAnimation(toRemove: Animation): number;
  33967. /**
  33968. * Will stop the animation of the given target
  33969. * @param target - the target
  33970. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33971. * @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)
  33972. */
  33973. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33974. /**
  33975. * Removes the given animation group from this scene.
  33976. * @param toRemove The animation group to remove
  33977. * @returns The index of the removed animation group
  33978. */
  33979. removeAnimationGroup(toRemove: AnimationGroup): number;
  33980. /**
  33981. * Removes the given multi-material from this scene.
  33982. * @param toRemove The multi-material to remove
  33983. * @returns The index of the removed multi-material
  33984. */
  33985. removeMultiMaterial(toRemove: MultiMaterial): number;
  33986. /**
  33987. * Removes the given material from this scene.
  33988. * @param toRemove The material to remove
  33989. * @returns The index of the removed material
  33990. */
  33991. removeMaterial(toRemove: Material): number;
  33992. /**
  33993. * Removes the given action manager from this scene.
  33994. * @param toRemove The action manager to remove
  33995. * @returns The index of the removed action manager
  33996. */
  33997. removeActionManager(toRemove: AbstractActionManager): number;
  33998. /**
  33999. * Removes the given texture from this scene.
  34000. * @param toRemove The texture to remove
  34001. * @returns The index of the removed texture
  34002. */
  34003. removeTexture(toRemove: BaseTexture): number;
  34004. /**
  34005. * Adds the given light to this scene
  34006. * @param newLight The light to add
  34007. */
  34008. addLight(newLight: Light): void;
  34009. /**
  34010. * Sorts the list list based on light priorities
  34011. */
  34012. sortLightsByPriority(): void;
  34013. /**
  34014. * Adds the given camera to this scene
  34015. * @param newCamera The camera to add
  34016. */
  34017. addCamera(newCamera: Camera): void;
  34018. /**
  34019. * Adds the given skeleton to this scene
  34020. * @param newSkeleton The skeleton to add
  34021. */
  34022. addSkeleton(newSkeleton: Skeleton): void;
  34023. /**
  34024. * Adds the given particle system to this scene
  34025. * @param newParticleSystem The particle system to add
  34026. */
  34027. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34028. /**
  34029. * Adds the given animation to this scene
  34030. * @param newAnimation The animation to add
  34031. */
  34032. addAnimation(newAnimation: Animation): void;
  34033. /**
  34034. * Adds the given animation group to this scene.
  34035. * @param newAnimationGroup The animation group to add
  34036. */
  34037. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34038. /**
  34039. * Adds the given multi-material to this scene
  34040. * @param newMultiMaterial The multi-material to add
  34041. */
  34042. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34043. /**
  34044. * Adds the given material to this scene
  34045. * @param newMaterial The material to add
  34046. */
  34047. addMaterial(newMaterial: Material): void;
  34048. /**
  34049. * Adds the given morph target to this scene
  34050. * @param newMorphTargetManager The morph target to add
  34051. */
  34052. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34053. /**
  34054. * Adds the given geometry to this scene
  34055. * @param newGeometry The geometry to add
  34056. */
  34057. addGeometry(newGeometry: Geometry): void;
  34058. /**
  34059. * Adds the given action manager to this scene
  34060. * @param newActionManager The action manager to add
  34061. */
  34062. addActionManager(newActionManager: AbstractActionManager): void;
  34063. /**
  34064. * Adds the given texture to this scene.
  34065. * @param newTexture The texture to add
  34066. */
  34067. addTexture(newTexture: BaseTexture): void;
  34068. /**
  34069. * Switch active camera
  34070. * @param newCamera defines the new active camera
  34071. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34072. */
  34073. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34074. /**
  34075. * sets the active camera of the scene using its ID
  34076. * @param id defines the camera's ID
  34077. * @return the new active camera or null if none found.
  34078. */
  34079. setActiveCameraByID(id: string): Nullable<Camera>;
  34080. /**
  34081. * sets the active camera of the scene using its name
  34082. * @param name defines the camera's name
  34083. * @returns the new active camera or null if none found.
  34084. */
  34085. setActiveCameraByName(name: string): Nullable<Camera>;
  34086. /**
  34087. * get an animation group using its name
  34088. * @param name defines the material's name
  34089. * @return the animation group or null if none found.
  34090. */
  34091. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34092. /**
  34093. * Get a material using its unique id
  34094. * @param uniqueId defines the material's unique id
  34095. * @return the material or null if none found.
  34096. */
  34097. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34098. /**
  34099. * get a material using its id
  34100. * @param id defines the material's ID
  34101. * @return the material or null if none found.
  34102. */
  34103. getMaterialByID(id: string): Nullable<Material>;
  34104. /**
  34105. * Gets a material using its name
  34106. * @param name defines the material's name
  34107. * @return the material or null if none found.
  34108. */
  34109. getMaterialByName(name: string): Nullable<Material>;
  34110. /**
  34111. * Gets a camera using its id
  34112. * @param id defines the id to look for
  34113. * @returns the camera or null if not found
  34114. */
  34115. getCameraByID(id: string): Nullable<Camera>;
  34116. /**
  34117. * Gets a camera using its unique id
  34118. * @param uniqueId defines the unique id to look for
  34119. * @returns the camera or null if not found
  34120. */
  34121. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34122. /**
  34123. * Gets a camera using its name
  34124. * @param name defines the camera's name
  34125. * @return the camera or null if none found.
  34126. */
  34127. getCameraByName(name: string): Nullable<Camera>;
  34128. /**
  34129. * Gets a bone using its id
  34130. * @param id defines the bone's id
  34131. * @return the bone or null if not found
  34132. */
  34133. getBoneByID(id: string): Nullable<Bone>;
  34134. /**
  34135. * Gets a bone using its id
  34136. * @param name defines the bone's name
  34137. * @return the bone or null if not found
  34138. */
  34139. getBoneByName(name: string): Nullable<Bone>;
  34140. /**
  34141. * Gets a light node using its name
  34142. * @param name defines the the light's name
  34143. * @return the light or null if none found.
  34144. */
  34145. getLightByName(name: string): Nullable<Light>;
  34146. /**
  34147. * Gets a light node using its id
  34148. * @param id defines the light's id
  34149. * @return the light or null if none found.
  34150. */
  34151. getLightByID(id: string): Nullable<Light>;
  34152. /**
  34153. * Gets a light node using its scene-generated unique ID
  34154. * @param uniqueId defines the light's unique id
  34155. * @return the light or null if none found.
  34156. */
  34157. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34158. /**
  34159. * Gets a particle system by id
  34160. * @param id defines the particle system id
  34161. * @return the corresponding system or null if none found
  34162. */
  34163. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34164. /**
  34165. * Gets a geometry using its ID
  34166. * @param id defines the geometry's id
  34167. * @return the geometry or null if none found.
  34168. */
  34169. getGeometryByID(id: string): Nullable<Geometry>;
  34170. private _getGeometryByUniqueID;
  34171. /**
  34172. * Add a new geometry to this scene
  34173. * @param geometry defines the geometry to be added to the scene.
  34174. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34175. * @return a boolean defining if the geometry was added or not
  34176. */
  34177. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34178. /**
  34179. * Removes an existing geometry
  34180. * @param geometry defines the geometry to be removed from the scene
  34181. * @return a boolean defining if the geometry was removed or not
  34182. */
  34183. removeGeometry(geometry: Geometry): boolean;
  34184. /**
  34185. * Gets the list of geometries attached to the scene
  34186. * @returns an array of Geometry
  34187. */
  34188. getGeometries(): Geometry[];
  34189. /**
  34190. * Gets the first added mesh found of a given ID
  34191. * @param id defines the id to search for
  34192. * @return the mesh found or null if not found at all
  34193. */
  34194. getMeshByID(id: string): Nullable<AbstractMesh>;
  34195. /**
  34196. * Gets a list of meshes using their id
  34197. * @param id defines the id to search for
  34198. * @returns a list of meshes
  34199. */
  34200. getMeshesByID(id: string): Array<AbstractMesh>;
  34201. /**
  34202. * Gets the first added transform node found of a given ID
  34203. * @param id defines the id to search for
  34204. * @return the found transform node or null if not found at all.
  34205. */
  34206. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34207. /**
  34208. * Gets a transform node with its auto-generated unique id
  34209. * @param uniqueId efines the unique id to search for
  34210. * @return the found transform node or null if not found at all.
  34211. */
  34212. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34213. /**
  34214. * Gets a list of transform nodes using their id
  34215. * @param id defines the id to search for
  34216. * @returns a list of transform nodes
  34217. */
  34218. getTransformNodesByID(id: string): Array<TransformNode>;
  34219. /**
  34220. * Gets a mesh with its auto-generated unique id
  34221. * @param uniqueId defines the unique id to search for
  34222. * @return the found mesh or null if not found at all.
  34223. */
  34224. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34225. /**
  34226. * Gets a the last added mesh using a given id
  34227. * @param id defines the id to search for
  34228. * @return the found mesh or null if not found at all.
  34229. */
  34230. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34231. /**
  34232. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34233. * @param id defines the id to search for
  34234. * @return the found node or null if not found at all
  34235. */
  34236. getLastEntryByID(id: string): Nullable<Node>;
  34237. /**
  34238. * Gets a node (Mesh, Camera, Light) using a given id
  34239. * @param id defines the id to search for
  34240. * @return the found node or null if not found at all
  34241. */
  34242. getNodeByID(id: string): Nullable<Node>;
  34243. /**
  34244. * Gets a node (Mesh, Camera, Light) using a given name
  34245. * @param name defines the name to search for
  34246. * @return the found node or null if not found at all.
  34247. */
  34248. getNodeByName(name: string): Nullable<Node>;
  34249. /**
  34250. * Gets a mesh using a given name
  34251. * @param name defines the name to search for
  34252. * @return the found mesh or null if not found at all.
  34253. */
  34254. getMeshByName(name: string): Nullable<AbstractMesh>;
  34255. /**
  34256. * Gets a transform node using a given name
  34257. * @param name defines the name to search for
  34258. * @return the found transform node or null if not found at all.
  34259. */
  34260. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34261. /**
  34262. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34263. * @param id defines the id to search for
  34264. * @return the found skeleton or null if not found at all.
  34265. */
  34266. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34267. /**
  34268. * Gets a skeleton using a given auto generated unique id
  34269. * @param uniqueId defines the unique id to search for
  34270. * @return the found skeleton or null if not found at all.
  34271. */
  34272. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34273. /**
  34274. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34275. * @param id defines the id to search for
  34276. * @return the found skeleton or null if not found at all.
  34277. */
  34278. getSkeletonById(id: string): Nullable<Skeleton>;
  34279. /**
  34280. * Gets a skeleton using a given name
  34281. * @param name defines the name to search for
  34282. * @return the found skeleton or null if not found at all.
  34283. */
  34284. getSkeletonByName(name: string): Nullable<Skeleton>;
  34285. /**
  34286. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34287. * @param id defines the id to search for
  34288. * @return the found morph target manager or null if not found at all.
  34289. */
  34290. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34291. /**
  34292. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34293. * @param id defines the id to search for
  34294. * @return the found morph target or null if not found at all.
  34295. */
  34296. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34297. /**
  34298. * Gets a boolean indicating if the given mesh is active
  34299. * @param mesh defines the mesh to look for
  34300. * @returns true if the mesh is in the active list
  34301. */
  34302. isActiveMesh(mesh: AbstractMesh): boolean;
  34303. /**
  34304. * Return a unique id as a string which can serve as an identifier for the scene
  34305. */
  34306. readonly uid: string;
  34307. /**
  34308. * Add an externaly attached data from its key.
  34309. * This method call will fail and return false, if such key already exists.
  34310. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34311. * @param key the unique key that identifies the data
  34312. * @param data the data object to associate to the key for this Engine instance
  34313. * @return true if no such key were already present and the data was added successfully, false otherwise
  34314. */
  34315. addExternalData<T>(key: string, data: T): boolean;
  34316. /**
  34317. * Get an externaly attached data from its key
  34318. * @param key the unique key that identifies the data
  34319. * @return the associated data, if present (can be null), or undefined if not present
  34320. */
  34321. getExternalData<T>(key: string): Nullable<T>;
  34322. /**
  34323. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34324. * @param key the unique key that identifies the data
  34325. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34326. * @return the associated data, can be null if the factory returned null.
  34327. */
  34328. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34329. /**
  34330. * Remove an externaly attached data from the Engine instance
  34331. * @param key the unique key that identifies the data
  34332. * @return true if the data was successfully removed, false if it doesn't exist
  34333. */
  34334. removeExternalData(key: string): boolean;
  34335. private _evaluateSubMesh;
  34336. /**
  34337. * Clear the processed materials smart array preventing retention point in material dispose.
  34338. */
  34339. freeProcessedMaterials(): void;
  34340. private _preventFreeActiveMeshesAndRenderingGroups;
  34341. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34342. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34343. * when disposing several meshes in a row or a hierarchy of meshes.
  34344. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34345. */
  34346. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34347. /**
  34348. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34349. */
  34350. freeActiveMeshes(): void;
  34351. /**
  34352. * Clear the info related to rendering groups preventing retention points during dispose.
  34353. */
  34354. freeRenderingGroups(): void;
  34355. /** @hidden */
  34356. _isInIntermediateRendering(): boolean;
  34357. /**
  34358. * Lambda returning the list of potentially active meshes.
  34359. */
  34360. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34361. /**
  34362. * Lambda returning the list of potentially active sub meshes.
  34363. */
  34364. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34365. /**
  34366. * Lambda returning the list of potentially intersecting sub meshes.
  34367. */
  34368. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34369. /**
  34370. * Lambda returning the list of potentially colliding sub meshes.
  34371. */
  34372. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34373. private _activeMeshesFrozen;
  34374. /**
  34375. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34376. * @returns the current scene
  34377. */
  34378. freezeActiveMeshes(): Scene;
  34379. /**
  34380. * Use this function to restart evaluating active meshes on every frame
  34381. * @returns the current scene
  34382. */
  34383. unfreezeActiveMeshes(): Scene;
  34384. private _evaluateActiveMeshes;
  34385. private _activeMesh;
  34386. /**
  34387. * Update the transform matrix to update from the current active camera
  34388. * @param force defines a boolean used to force the update even if cache is up to date
  34389. */
  34390. updateTransformMatrix(force?: boolean): void;
  34391. private _bindFrameBuffer;
  34392. /** @hidden */
  34393. _allowPostProcessClearColor: boolean;
  34394. /** @hidden */
  34395. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34396. private _processSubCameras;
  34397. private _checkIntersections;
  34398. /** @hidden */
  34399. _advancePhysicsEngineStep(step: number): void;
  34400. /**
  34401. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34402. */
  34403. getDeterministicFrameTime: () => number;
  34404. /** @hidden */
  34405. _animate(): void;
  34406. /** Execute all animations (for a frame) */
  34407. animate(): void;
  34408. /**
  34409. * Render the scene
  34410. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34411. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34412. */
  34413. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34414. /**
  34415. * Freeze all materials
  34416. * A frozen material will not be updatable but should be faster to render
  34417. */
  34418. freezeMaterials(): void;
  34419. /**
  34420. * Unfreeze all materials
  34421. * A frozen material will not be updatable but should be faster to render
  34422. */
  34423. unfreezeMaterials(): void;
  34424. /**
  34425. * Releases all held ressources
  34426. */
  34427. dispose(): void;
  34428. /**
  34429. * Gets if the scene is already disposed
  34430. */
  34431. readonly isDisposed: boolean;
  34432. /**
  34433. * Call this function to reduce memory footprint of the scene.
  34434. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34435. */
  34436. clearCachedVertexData(): void;
  34437. /**
  34438. * This function will remove the local cached buffer data from texture.
  34439. * It will save memory but will prevent the texture from being rebuilt
  34440. */
  34441. cleanCachedTextureBuffer(): void;
  34442. /**
  34443. * Get the world extend vectors with an optional filter
  34444. *
  34445. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34446. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34447. */
  34448. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34449. min: Vector3;
  34450. max: Vector3;
  34451. };
  34452. /**
  34453. * Creates a ray that can be used to pick in the scene
  34454. * @param x defines the x coordinate of the origin (on-screen)
  34455. * @param y defines the y coordinate of the origin (on-screen)
  34456. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34457. * @param camera defines the camera to use for the picking
  34458. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34459. * @returns a Ray
  34460. */
  34461. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34462. /**
  34463. * Creates a ray that can be used to pick in the scene
  34464. * @param x defines the x coordinate of the origin (on-screen)
  34465. * @param y defines the y coordinate of the origin (on-screen)
  34466. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34467. * @param result defines the ray where to store the picking ray
  34468. * @param camera defines the camera to use for the picking
  34469. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34470. * @returns the current scene
  34471. */
  34472. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34473. /**
  34474. * Creates a ray that can be used to pick in the scene
  34475. * @param x defines the x coordinate of the origin (on-screen)
  34476. * @param y defines the y coordinate of the origin (on-screen)
  34477. * @param camera defines the camera to use for the picking
  34478. * @returns a Ray
  34479. */
  34480. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34481. /**
  34482. * Creates a ray that can be used to pick in the scene
  34483. * @param x defines the x coordinate of the origin (on-screen)
  34484. * @param y defines the y coordinate of the origin (on-screen)
  34485. * @param result defines the ray where to store the picking ray
  34486. * @param camera defines the camera to use for the picking
  34487. * @returns the current scene
  34488. */
  34489. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34490. /** Launch a ray to try to pick a mesh in the scene
  34491. * @param x position on screen
  34492. * @param y position on screen
  34493. * @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
  34494. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34495. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34496. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34497. * @returns a PickingInfo
  34498. */
  34499. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34500. /** Use the given ray to pick a mesh in the scene
  34501. * @param ray The ray to use to pick meshes
  34502. * @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
  34503. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34504. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34505. * @returns a PickingInfo
  34506. */
  34507. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34508. /**
  34509. * Launch a ray to try to pick a mesh in the scene
  34510. * @param x X position on screen
  34511. * @param y Y position on screen
  34512. * @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
  34513. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34514. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34515. * @returns an array of PickingInfo
  34516. */
  34517. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34518. /**
  34519. * Launch a ray to try to pick a mesh in the scene
  34520. * @param ray Ray to use
  34521. * @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
  34522. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34523. * @returns an array of PickingInfo
  34524. */
  34525. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34526. /**
  34527. * Force the value of meshUnderPointer
  34528. * @param mesh defines the mesh to use
  34529. */
  34530. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34531. /**
  34532. * Gets the mesh under the pointer
  34533. * @returns a Mesh or null if no mesh is under the pointer
  34534. */
  34535. getPointerOverMesh(): Nullable<AbstractMesh>;
  34536. /** @hidden */
  34537. _rebuildGeometries(): void;
  34538. /** @hidden */
  34539. _rebuildTextures(): void;
  34540. private _getByTags;
  34541. /**
  34542. * Get a list of meshes by tags
  34543. * @param tagsQuery defines the tags query to use
  34544. * @param forEach defines a predicate used to filter results
  34545. * @returns an array of Mesh
  34546. */
  34547. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34548. /**
  34549. * Get a list of cameras by tags
  34550. * @param tagsQuery defines the tags query to use
  34551. * @param forEach defines a predicate used to filter results
  34552. * @returns an array of Camera
  34553. */
  34554. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34555. /**
  34556. * Get a list of lights by tags
  34557. * @param tagsQuery defines the tags query to use
  34558. * @param forEach defines a predicate used to filter results
  34559. * @returns an array of Light
  34560. */
  34561. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34562. /**
  34563. * Get a list of materials by tags
  34564. * @param tagsQuery defines the tags query to use
  34565. * @param forEach defines a predicate used to filter results
  34566. * @returns an array of Material
  34567. */
  34568. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34569. /**
  34570. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34571. * This allowed control for front to back rendering or reversly depending of the special needs.
  34572. *
  34573. * @param renderingGroupId The rendering group id corresponding to its index
  34574. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34575. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34576. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34577. */
  34578. 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;
  34579. /**
  34580. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34581. *
  34582. * @param renderingGroupId The rendering group id corresponding to its index
  34583. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34584. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34585. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34586. */
  34587. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34588. /**
  34589. * Gets the current auto clear configuration for one rendering group of the rendering
  34590. * manager.
  34591. * @param index the rendering group index to get the information for
  34592. * @returns The auto clear setup for the requested rendering group
  34593. */
  34594. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34595. private _blockMaterialDirtyMechanism;
  34596. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34597. blockMaterialDirtyMechanism: boolean;
  34598. /**
  34599. * Will flag all materials as dirty to trigger new shader compilation
  34600. * @param flag defines the flag used to specify which material part must be marked as dirty
  34601. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34602. */
  34603. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34604. /** @hidden */
  34605. _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;
  34606. /** @hidden */
  34607. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34608. }
  34609. }
  34610. declare module "babylonjs/assetContainer" {
  34611. import { AbstractScene } from "babylonjs/abstractScene";
  34612. import { Scene } from "babylonjs/scene";
  34613. import { Mesh } from "babylonjs/Meshes/mesh";
  34614. /**
  34615. * Set of assets to keep when moving a scene into an asset container.
  34616. */
  34617. export class KeepAssets extends AbstractScene {
  34618. }
  34619. /**
  34620. * Container with a set of assets that can be added or removed from a scene.
  34621. */
  34622. export class AssetContainer extends AbstractScene {
  34623. /**
  34624. * The scene the AssetContainer belongs to.
  34625. */
  34626. scene: Scene;
  34627. /**
  34628. * Instantiates an AssetContainer.
  34629. * @param scene The scene the AssetContainer belongs to.
  34630. */
  34631. constructor(scene: Scene);
  34632. /**
  34633. * Adds all the assets from the container to the scene.
  34634. */
  34635. addAllToScene(): void;
  34636. /**
  34637. * Removes all the assets in the container from the scene
  34638. */
  34639. removeAllFromScene(): void;
  34640. /**
  34641. * Disposes all the assets in the container
  34642. */
  34643. dispose(): void;
  34644. private _moveAssets;
  34645. /**
  34646. * Removes all the assets contained in the scene and adds them to the container.
  34647. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34648. */
  34649. moveAllFromScene(keepAssets?: KeepAssets): void;
  34650. /**
  34651. * 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.
  34652. * @returns the root mesh
  34653. */
  34654. createRootMesh(): Mesh;
  34655. }
  34656. }
  34657. declare module "babylonjs/abstractScene" {
  34658. import { Scene } from "babylonjs/scene";
  34659. import { Nullable } from "babylonjs/types";
  34660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34661. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34662. import { Geometry } from "babylonjs/Meshes/geometry";
  34663. import { Skeleton } from "babylonjs/Bones/skeleton";
  34664. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34665. import { AssetContainer } from "babylonjs/assetContainer";
  34666. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34667. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34668. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34669. import { Material } from "babylonjs/Materials/material";
  34670. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34671. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34672. import { Camera } from "babylonjs/Cameras/camera";
  34673. import { Light } from "babylonjs/Lights/light";
  34674. import { Node } from "babylonjs/node";
  34675. import { Animation } from "babylonjs/Animations/animation";
  34676. /**
  34677. * Defines how the parser contract is defined.
  34678. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34679. */
  34680. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34681. /**
  34682. * Defines how the individual parser contract is defined.
  34683. * These parser can parse an individual asset
  34684. */
  34685. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34686. /**
  34687. * Base class of the scene acting as a container for the different elements composing a scene.
  34688. * This class is dynamically extended by the different components of the scene increasing
  34689. * flexibility and reducing coupling
  34690. */
  34691. export abstract class AbstractScene {
  34692. /**
  34693. * Stores the list of available parsers in the application.
  34694. */
  34695. private static _BabylonFileParsers;
  34696. /**
  34697. * Stores the list of available individual parsers in the application.
  34698. */
  34699. private static _IndividualBabylonFileParsers;
  34700. /**
  34701. * Adds a parser in the list of available ones
  34702. * @param name Defines the name of the parser
  34703. * @param parser Defines the parser to add
  34704. */
  34705. static AddParser(name: string, parser: BabylonFileParser): void;
  34706. /**
  34707. * Gets a general parser from the list of avaialble ones
  34708. * @param name Defines the name of the parser
  34709. * @returns the requested parser or null
  34710. */
  34711. static GetParser(name: string): Nullable<BabylonFileParser>;
  34712. /**
  34713. * Adds n individual parser in the list of available ones
  34714. * @param name Defines the name of the parser
  34715. * @param parser Defines the parser to add
  34716. */
  34717. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34718. /**
  34719. * Gets an individual parser from the list of avaialble ones
  34720. * @param name Defines the name of the parser
  34721. * @returns the requested parser or null
  34722. */
  34723. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34724. /**
  34725. * Parser json data and populate both a scene and its associated container object
  34726. * @param jsonData Defines the data to parse
  34727. * @param scene Defines the scene to parse the data for
  34728. * @param container Defines the container attached to the parsing sequence
  34729. * @param rootUrl Defines the root url of the data
  34730. */
  34731. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34732. /**
  34733. * Gets the list of root nodes (ie. nodes with no parent)
  34734. */
  34735. rootNodes: Node[];
  34736. /** All of the cameras added to this scene
  34737. * @see http://doc.babylonjs.com/babylon101/cameras
  34738. */
  34739. cameras: Camera[];
  34740. /**
  34741. * All of the lights added to this scene
  34742. * @see http://doc.babylonjs.com/babylon101/lights
  34743. */
  34744. lights: Light[];
  34745. /**
  34746. * All of the (abstract) meshes added to this scene
  34747. */
  34748. meshes: AbstractMesh[];
  34749. /**
  34750. * The list of skeletons added to the scene
  34751. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34752. */
  34753. skeletons: Skeleton[];
  34754. /**
  34755. * All of the particle systems added to this scene
  34756. * @see http://doc.babylonjs.com/babylon101/particles
  34757. */
  34758. particleSystems: IParticleSystem[];
  34759. /**
  34760. * Gets a list of Animations associated with the scene
  34761. */
  34762. animations: Animation[];
  34763. /**
  34764. * All of the animation groups added to this scene
  34765. * @see http://doc.babylonjs.com/how_to/group
  34766. */
  34767. animationGroups: AnimationGroup[];
  34768. /**
  34769. * All of the multi-materials added to this scene
  34770. * @see http://doc.babylonjs.com/how_to/multi_materials
  34771. */
  34772. multiMaterials: MultiMaterial[];
  34773. /**
  34774. * All of the materials added to this scene
  34775. * In the context of a Scene, it is not supposed to be modified manually.
  34776. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34777. * Note also that the order of the Material wihin the array is not significant and might change.
  34778. * @see http://doc.babylonjs.com/babylon101/materials
  34779. */
  34780. materials: Material[];
  34781. /**
  34782. * The list of morph target managers added to the scene
  34783. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34784. */
  34785. morphTargetManagers: MorphTargetManager[];
  34786. /**
  34787. * The list of geometries used in the scene.
  34788. */
  34789. geometries: Geometry[];
  34790. /**
  34791. * All of the tranform nodes added to this scene
  34792. * In the context of a Scene, it is not supposed to be modified manually.
  34793. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34794. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34795. * @see http://doc.babylonjs.com/how_to/transformnode
  34796. */
  34797. transformNodes: TransformNode[];
  34798. /**
  34799. * ActionManagers available on the scene.
  34800. */
  34801. actionManagers: AbstractActionManager[];
  34802. /**
  34803. * Textures to keep.
  34804. */
  34805. textures: BaseTexture[];
  34806. /**
  34807. * Environment texture for the scene
  34808. */
  34809. environmentTexture: Nullable<BaseTexture>;
  34810. }
  34811. }
  34812. declare module "babylonjs/Audio/sound" {
  34813. import { Observable } from "babylonjs/Misc/observable";
  34814. import { Vector3 } from "babylonjs/Maths/math";
  34815. import { Nullable } from "babylonjs/types";
  34816. import { Scene } from "babylonjs/scene";
  34817. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34818. /**
  34819. * Defines a sound that can be played in the application.
  34820. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34822. */
  34823. export class Sound {
  34824. /**
  34825. * The name of the sound in the scene.
  34826. */
  34827. name: string;
  34828. /**
  34829. * Does the sound autoplay once loaded.
  34830. */
  34831. autoplay: boolean;
  34832. /**
  34833. * Does the sound loop after it finishes playing once.
  34834. */
  34835. loop: boolean;
  34836. /**
  34837. * Does the sound use a custom attenuation curve to simulate the falloff
  34838. * happening when the source gets further away from the camera.
  34839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34840. */
  34841. useCustomAttenuation: boolean;
  34842. /**
  34843. * The sound track id this sound belongs to.
  34844. */
  34845. soundTrackId: number;
  34846. /**
  34847. * Is this sound currently played.
  34848. */
  34849. isPlaying: boolean;
  34850. /**
  34851. * Is this sound currently paused.
  34852. */
  34853. isPaused: boolean;
  34854. /**
  34855. * Does this sound enables spatial sound.
  34856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34857. */
  34858. spatialSound: boolean;
  34859. /**
  34860. * Define the reference distance the sound should be heard perfectly.
  34861. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34862. */
  34863. refDistance: number;
  34864. /**
  34865. * Define the roll off factor of spatial sounds.
  34866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34867. */
  34868. rolloffFactor: number;
  34869. /**
  34870. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34871. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34872. */
  34873. maxDistance: number;
  34874. /**
  34875. * Define the distance attenuation model the sound will follow.
  34876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34877. */
  34878. distanceModel: string;
  34879. /**
  34880. * @hidden
  34881. * Back Compat
  34882. **/
  34883. onended: () => any;
  34884. /**
  34885. * Observable event when the current playing sound finishes.
  34886. */
  34887. onEndedObservable: Observable<Sound>;
  34888. private _panningModel;
  34889. private _playbackRate;
  34890. private _streaming;
  34891. private _startTime;
  34892. private _startOffset;
  34893. private _position;
  34894. /** @hidden */
  34895. _positionInEmitterSpace: boolean;
  34896. private _localDirection;
  34897. private _volume;
  34898. private _isReadyToPlay;
  34899. private _isDirectional;
  34900. private _readyToPlayCallback;
  34901. private _audioBuffer;
  34902. private _soundSource;
  34903. private _streamingSource;
  34904. private _soundPanner;
  34905. private _soundGain;
  34906. private _inputAudioNode;
  34907. private _outputAudioNode;
  34908. private _coneInnerAngle;
  34909. private _coneOuterAngle;
  34910. private _coneOuterGain;
  34911. private _scene;
  34912. private _connectedTransformNode;
  34913. private _customAttenuationFunction;
  34914. private _registerFunc;
  34915. private _isOutputConnected;
  34916. private _htmlAudioElement;
  34917. private _urlType;
  34918. /** @hidden */
  34919. static _SceneComponentInitialization: (scene: Scene) => void;
  34920. /**
  34921. * Create a sound and attach it to a scene
  34922. * @param name Name of your sound
  34923. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34924. * @param scene defines the scene the sound belongs to
  34925. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34926. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34927. */
  34928. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34929. /**
  34930. * Release the sound and its associated resources
  34931. */
  34932. dispose(): void;
  34933. /**
  34934. * Gets if the sounds is ready to be played or not.
  34935. * @returns true if ready, otherwise false
  34936. */
  34937. isReady(): boolean;
  34938. private _soundLoaded;
  34939. /**
  34940. * Sets the data of the sound from an audiobuffer
  34941. * @param audioBuffer The audioBuffer containing the data
  34942. */
  34943. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34944. /**
  34945. * Updates the current sounds options such as maxdistance, loop...
  34946. * @param options A JSON object containing values named as the object properties
  34947. */
  34948. updateOptions(options: any): void;
  34949. private _createSpatialParameters;
  34950. private _updateSpatialParameters;
  34951. /**
  34952. * Switch the panning model to HRTF:
  34953. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34955. */
  34956. switchPanningModelToHRTF(): void;
  34957. /**
  34958. * Switch the panning model to Equal Power:
  34959. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34960. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34961. */
  34962. switchPanningModelToEqualPower(): void;
  34963. private _switchPanningModel;
  34964. /**
  34965. * Connect this sound to a sound track audio node like gain...
  34966. * @param soundTrackAudioNode the sound track audio node to connect to
  34967. */
  34968. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34969. /**
  34970. * Transform this sound into a directional source
  34971. * @param coneInnerAngle Size of the inner cone in degree
  34972. * @param coneOuterAngle Size of the outer cone in degree
  34973. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34974. */
  34975. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34976. /**
  34977. * Gets or sets the inner angle for the directional cone.
  34978. */
  34979. /**
  34980. * Gets or sets the inner angle for the directional cone.
  34981. */
  34982. directionalConeInnerAngle: number;
  34983. /**
  34984. * Gets or sets the outer angle for the directional cone.
  34985. */
  34986. /**
  34987. * Gets or sets the outer angle for the directional cone.
  34988. */
  34989. directionalConeOuterAngle: number;
  34990. /**
  34991. * Sets the position of the emitter if spatial sound is enabled
  34992. * @param newPosition Defines the new posisiton
  34993. */
  34994. setPosition(newPosition: Vector3): void;
  34995. /**
  34996. * Sets the local direction of the emitter if spatial sound is enabled
  34997. * @param newLocalDirection Defines the new local direction
  34998. */
  34999. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35000. private _updateDirection;
  35001. /** @hidden */
  35002. updateDistanceFromListener(): void;
  35003. /**
  35004. * Sets a new custom attenuation function for the sound.
  35005. * @param callback Defines the function used for the attenuation
  35006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35007. */
  35008. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35009. /**
  35010. * Play the sound
  35011. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35012. * @param offset (optional) Start the sound setting it at a specific time
  35013. */
  35014. play(time?: number, offset?: number): void;
  35015. private _onended;
  35016. /**
  35017. * Stop the sound
  35018. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35019. */
  35020. stop(time?: number): void;
  35021. /**
  35022. * Put the sound in pause
  35023. */
  35024. pause(): void;
  35025. /**
  35026. * Sets a dedicated volume for this sounds
  35027. * @param newVolume Define the new volume of the sound
  35028. * @param time Define in how long the sound should be at this value
  35029. */
  35030. setVolume(newVolume: number, time?: number): void;
  35031. /**
  35032. * Set the sound play back rate
  35033. * @param newPlaybackRate Define the playback rate the sound should be played at
  35034. */
  35035. setPlaybackRate(newPlaybackRate: number): void;
  35036. /**
  35037. * Gets the volume of the sound.
  35038. * @returns the volume of the sound
  35039. */
  35040. getVolume(): number;
  35041. /**
  35042. * Attach the sound to a dedicated mesh
  35043. * @param transformNode The transform node to connect the sound with
  35044. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35045. */
  35046. attachToMesh(transformNode: TransformNode): void;
  35047. /**
  35048. * Detach the sound from the previously attached mesh
  35049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35050. */
  35051. detachFromMesh(): void;
  35052. private _onRegisterAfterWorldMatrixUpdate;
  35053. /**
  35054. * Clone the current sound in the scene.
  35055. * @returns the new sound clone
  35056. */
  35057. clone(): Nullable<Sound>;
  35058. /**
  35059. * Gets the current underlying audio buffer containing the data
  35060. * @returns the audio buffer
  35061. */
  35062. getAudioBuffer(): Nullable<AudioBuffer>;
  35063. /**
  35064. * Serializes the Sound in a JSON representation
  35065. * @returns the JSON representation of the sound
  35066. */
  35067. serialize(): any;
  35068. /**
  35069. * Parse a JSON representation of a sound to innstantiate in a given scene
  35070. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35071. * @param scene Define the scene the new parsed sound should be created in
  35072. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35073. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35074. * @returns the newly parsed sound
  35075. */
  35076. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35077. }
  35078. }
  35079. declare module "babylonjs/Actions/directAudioActions" {
  35080. import { Action } from "babylonjs/Actions/action";
  35081. import { Condition } from "babylonjs/Actions/condition";
  35082. import { Sound } from "babylonjs/Audio/sound";
  35083. /**
  35084. * This defines an action helpful to play a defined sound on a triggered action.
  35085. */
  35086. export class PlaySoundAction extends Action {
  35087. private _sound;
  35088. /**
  35089. * Instantiate the action
  35090. * @param triggerOptions defines the trigger options
  35091. * @param sound defines the sound to play
  35092. * @param condition defines the trigger related conditions
  35093. */
  35094. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35095. /** @hidden */
  35096. _prepare(): void;
  35097. /**
  35098. * Execute the action and play the sound.
  35099. */
  35100. execute(): void;
  35101. /**
  35102. * Serializes the actions and its related information.
  35103. * @param parent defines the object to serialize in
  35104. * @returns the serialized object
  35105. */
  35106. serialize(parent: any): any;
  35107. }
  35108. /**
  35109. * This defines an action helpful to stop a defined sound on a triggered action.
  35110. */
  35111. export class StopSoundAction extends Action {
  35112. private _sound;
  35113. /**
  35114. * Instantiate the action
  35115. * @param triggerOptions defines the trigger options
  35116. * @param sound defines the sound to stop
  35117. * @param condition defines the trigger related conditions
  35118. */
  35119. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35120. /** @hidden */
  35121. _prepare(): void;
  35122. /**
  35123. * Execute the action and stop the sound.
  35124. */
  35125. execute(): void;
  35126. /**
  35127. * Serializes the actions and its related information.
  35128. * @param parent defines the object to serialize in
  35129. * @returns the serialized object
  35130. */
  35131. serialize(parent: any): any;
  35132. }
  35133. }
  35134. declare module "babylonjs/Actions/interpolateValueAction" {
  35135. import { Action } from "babylonjs/Actions/action";
  35136. import { Condition } from "babylonjs/Actions/condition";
  35137. import { Observable } from "babylonjs/Misc/observable";
  35138. /**
  35139. * This defines an action responsible to change the value of a property
  35140. * by interpolating between its current value and the newly set one once triggered.
  35141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35142. */
  35143. export class InterpolateValueAction extends Action {
  35144. /**
  35145. * Defines the path of the property where the value should be interpolated
  35146. */
  35147. propertyPath: string;
  35148. /**
  35149. * Defines the target value at the end of the interpolation.
  35150. */
  35151. value: any;
  35152. /**
  35153. * Defines the time it will take for the property to interpolate to the value.
  35154. */
  35155. duration: number;
  35156. /**
  35157. * Defines if the other scene animations should be stopped when the action has been triggered
  35158. */
  35159. stopOtherAnimations?: boolean;
  35160. /**
  35161. * Defines a callback raised once the interpolation animation has been done.
  35162. */
  35163. onInterpolationDone?: () => void;
  35164. /**
  35165. * Observable triggered once the interpolation animation has been done.
  35166. */
  35167. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35168. private _target;
  35169. private _effectiveTarget;
  35170. private _property;
  35171. /**
  35172. * Instantiate the action
  35173. * @param triggerOptions defines the trigger options
  35174. * @param target defines the object containing the value to interpolate
  35175. * @param propertyPath defines the path to the property in the target object
  35176. * @param value defines the target value at the end of the interpolation
  35177. * @param duration deines the time it will take for the property to interpolate to the value.
  35178. * @param condition defines the trigger related conditions
  35179. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35180. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35181. */
  35182. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35183. /** @hidden */
  35184. _prepare(): void;
  35185. /**
  35186. * Execute the action starts the value interpolation.
  35187. */
  35188. execute(): void;
  35189. /**
  35190. * Serializes the actions and its related information.
  35191. * @param parent defines the object to serialize in
  35192. * @returns the serialized object
  35193. */
  35194. serialize(parent: any): any;
  35195. }
  35196. }
  35197. declare module "babylonjs/Actions/index" {
  35198. export * from "babylonjs/Actions/action";
  35199. export * from "babylonjs/Actions/actionEvent";
  35200. export * from "babylonjs/Actions/actionManager";
  35201. export * from "babylonjs/Actions/condition";
  35202. export * from "babylonjs/Actions/directActions";
  35203. export * from "babylonjs/Actions/directAudioActions";
  35204. export * from "babylonjs/Actions/interpolateValueAction";
  35205. }
  35206. declare module "babylonjs/Animations/index" {
  35207. export * from "babylonjs/Animations/animatable";
  35208. export * from "babylonjs/Animations/animation";
  35209. export * from "babylonjs/Animations/animationGroup";
  35210. export * from "babylonjs/Animations/animationPropertiesOverride";
  35211. export * from "babylonjs/Animations/easing";
  35212. export * from "babylonjs/Animations/runtimeAnimation";
  35213. export * from "babylonjs/Animations/animationEvent";
  35214. export * from "babylonjs/Animations/animationGroup";
  35215. export * from "babylonjs/Animations/animationKey";
  35216. export * from "babylonjs/Animations/animationRange";
  35217. }
  35218. declare module "babylonjs/Audio/soundTrack" {
  35219. import { Sound } from "babylonjs/Audio/sound";
  35220. import { Analyser } from "babylonjs/Audio/analyser";
  35221. import { Scene } from "babylonjs/scene";
  35222. /**
  35223. * Options allowed during the creation of a sound track.
  35224. */
  35225. export interface ISoundTrackOptions {
  35226. /**
  35227. * The volume the sound track should take during creation
  35228. */
  35229. volume?: number;
  35230. /**
  35231. * Define if the sound track is the main sound track of the scene
  35232. */
  35233. mainTrack?: boolean;
  35234. }
  35235. /**
  35236. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35237. * It will be also used in a future release to apply effects on a specific track.
  35238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35239. */
  35240. export class SoundTrack {
  35241. /**
  35242. * The unique identifier of the sound track in the scene.
  35243. */
  35244. id: number;
  35245. /**
  35246. * The list of sounds included in the sound track.
  35247. */
  35248. soundCollection: Array<Sound>;
  35249. private _outputAudioNode;
  35250. private _scene;
  35251. private _isMainTrack;
  35252. private _connectedAnalyser;
  35253. private _options;
  35254. private _isInitialized;
  35255. /**
  35256. * Creates a new sound track.
  35257. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35258. * @param scene Define the scene the sound track belongs to
  35259. * @param options
  35260. */
  35261. constructor(scene: Scene, options?: ISoundTrackOptions);
  35262. private _initializeSoundTrackAudioGraph;
  35263. /**
  35264. * Release the sound track and its associated resources
  35265. */
  35266. dispose(): void;
  35267. /**
  35268. * Adds a sound to this sound track
  35269. * @param sound define the cound to add
  35270. * @ignoreNaming
  35271. */
  35272. AddSound(sound: Sound): void;
  35273. /**
  35274. * Removes a sound to this sound track
  35275. * @param sound define the cound to remove
  35276. * @ignoreNaming
  35277. */
  35278. RemoveSound(sound: Sound): void;
  35279. /**
  35280. * Set a global volume for the full sound track.
  35281. * @param newVolume Define the new volume of the sound track
  35282. */
  35283. setVolume(newVolume: number): void;
  35284. /**
  35285. * Switch the panning model to HRTF:
  35286. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35287. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35288. */
  35289. switchPanningModelToHRTF(): void;
  35290. /**
  35291. * Switch the panning model to Equal Power:
  35292. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35294. */
  35295. switchPanningModelToEqualPower(): void;
  35296. /**
  35297. * Connect the sound track to an audio analyser allowing some amazing
  35298. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35300. * @param analyser The analyser to connect to the engine
  35301. */
  35302. connectToAnalyser(analyser: Analyser): void;
  35303. }
  35304. }
  35305. declare module "babylonjs/Audio/audioSceneComponent" {
  35306. import { Sound } from "babylonjs/Audio/sound";
  35307. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35308. import { Nullable } from "babylonjs/types";
  35309. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35310. import { Scene } from "babylonjs/scene";
  35311. import { AbstractScene } from "babylonjs/abstractScene";
  35312. module "babylonjs/abstractScene" {
  35313. interface AbstractScene {
  35314. /**
  35315. * The list of sounds used in the scene.
  35316. */
  35317. sounds: Nullable<Array<Sound>>;
  35318. }
  35319. }
  35320. module "babylonjs/scene" {
  35321. interface Scene {
  35322. /**
  35323. * @hidden
  35324. * Backing field
  35325. */
  35326. _mainSoundTrack: SoundTrack;
  35327. /**
  35328. * The main sound track played by the scene.
  35329. * It cotains your primary collection of sounds.
  35330. */
  35331. mainSoundTrack: SoundTrack;
  35332. /**
  35333. * The list of sound tracks added to the scene
  35334. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35335. */
  35336. soundTracks: Nullable<Array<SoundTrack>>;
  35337. /**
  35338. * Gets a sound using a given name
  35339. * @param name defines the name to search for
  35340. * @return the found sound or null if not found at all.
  35341. */
  35342. getSoundByName(name: string): Nullable<Sound>;
  35343. /**
  35344. * Gets or sets if audio support is enabled
  35345. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35346. */
  35347. audioEnabled: boolean;
  35348. /**
  35349. * Gets or sets if audio will be output to headphones
  35350. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35351. */
  35352. headphone: boolean;
  35353. }
  35354. }
  35355. /**
  35356. * Defines the sound scene component responsible to manage any sounds
  35357. * in a given scene.
  35358. */
  35359. export class AudioSceneComponent implements ISceneSerializableComponent {
  35360. /**
  35361. * The component name helpfull to identify the component in the list of scene components.
  35362. */
  35363. readonly name: string;
  35364. /**
  35365. * The scene the component belongs to.
  35366. */
  35367. scene: Scene;
  35368. private _audioEnabled;
  35369. /**
  35370. * Gets whether audio is enabled or not.
  35371. * Please use related enable/disable method to switch state.
  35372. */
  35373. readonly audioEnabled: boolean;
  35374. private _headphone;
  35375. /**
  35376. * Gets whether audio is outputing to headphone or not.
  35377. * Please use the according Switch methods to change output.
  35378. */
  35379. readonly headphone: boolean;
  35380. /**
  35381. * Creates a new instance of the component for the given scene
  35382. * @param scene Defines the scene to register the component in
  35383. */
  35384. constructor(scene: Scene);
  35385. /**
  35386. * Registers the component in a given scene
  35387. */
  35388. register(): void;
  35389. /**
  35390. * Rebuilds the elements related to this component in case of
  35391. * context lost for instance.
  35392. */
  35393. rebuild(): void;
  35394. /**
  35395. * Serializes the component data to the specified json object
  35396. * @param serializationObject The object to serialize to
  35397. */
  35398. serialize(serializationObject: any): void;
  35399. /**
  35400. * Adds all the element from the container to the scene
  35401. * @param container the container holding the elements
  35402. */
  35403. addFromContainer(container: AbstractScene): void;
  35404. /**
  35405. * Removes all the elements in the container from the scene
  35406. * @param container contains the elements to remove
  35407. * @param dispose if the removed element should be disposed (default: false)
  35408. */
  35409. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35410. /**
  35411. * Disposes the component and the associated ressources.
  35412. */
  35413. dispose(): void;
  35414. /**
  35415. * Disables audio in the associated scene.
  35416. */
  35417. disableAudio(): void;
  35418. /**
  35419. * Enables audio in the associated scene.
  35420. */
  35421. enableAudio(): void;
  35422. /**
  35423. * Switch audio to headphone output.
  35424. */
  35425. switchAudioModeForHeadphones(): void;
  35426. /**
  35427. * Switch audio to normal speakers.
  35428. */
  35429. switchAudioModeForNormalSpeakers(): void;
  35430. private _afterRender;
  35431. }
  35432. }
  35433. declare module "babylonjs/Audio/weightedsound" {
  35434. import { Sound } from "babylonjs/Audio/sound";
  35435. /**
  35436. * Wraps one or more Sound objects and selects one with random weight for playback.
  35437. */
  35438. export class WeightedSound {
  35439. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35440. loop: boolean;
  35441. private _coneInnerAngle;
  35442. private _coneOuterAngle;
  35443. private _volume;
  35444. /** A Sound is currently playing. */
  35445. isPlaying: boolean;
  35446. /** A Sound is currently paused. */
  35447. isPaused: boolean;
  35448. private _sounds;
  35449. private _weights;
  35450. private _currentIndex?;
  35451. /**
  35452. * Creates a new WeightedSound from the list of sounds given.
  35453. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35454. * @param sounds Array of Sounds that will be selected from.
  35455. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35456. */
  35457. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35458. /**
  35459. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35460. */
  35461. /**
  35462. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35463. */
  35464. directionalConeInnerAngle: number;
  35465. /**
  35466. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35467. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35468. */
  35469. /**
  35470. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35471. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35472. */
  35473. directionalConeOuterAngle: number;
  35474. /**
  35475. * Playback volume.
  35476. */
  35477. /**
  35478. * Playback volume.
  35479. */
  35480. volume: number;
  35481. private _onended;
  35482. /**
  35483. * Suspend playback
  35484. */
  35485. pause(): void;
  35486. /**
  35487. * Stop playback
  35488. */
  35489. stop(): void;
  35490. /**
  35491. * Start playback.
  35492. * @param startOffset Position the clip head at a specific time in seconds.
  35493. */
  35494. play(startOffset?: number): void;
  35495. }
  35496. }
  35497. declare module "babylonjs/Audio/index" {
  35498. export * from "babylonjs/Audio/analyser";
  35499. export * from "babylonjs/Audio/audioEngine";
  35500. export * from "babylonjs/Audio/audioSceneComponent";
  35501. export * from "babylonjs/Audio/sound";
  35502. export * from "babylonjs/Audio/soundTrack";
  35503. export * from "babylonjs/Audio/weightedsound";
  35504. }
  35505. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35506. import { Behavior } from "babylonjs/Behaviors/behavior";
  35507. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35508. import { BackEase } from "babylonjs/Animations/easing";
  35509. /**
  35510. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35511. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35512. */
  35513. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35514. /**
  35515. * Gets the name of the behavior.
  35516. */
  35517. readonly name: string;
  35518. /**
  35519. * The easing function used by animations
  35520. */
  35521. static EasingFunction: BackEase;
  35522. /**
  35523. * The easing mode used by animations
  35524. */
  35525. static EasingMode: number;
  35526. /**
  35527. * The duration of the animation, in milliseconds
  35528. */
  35529. transitionDuration: number;
  35530. /**
  35531. * Length of the distance animated by the transition when lower radius is reached
  35532. */
  35533. lowerRadiusTransitionRange: number;
  35534. /**
  35535. * Length of the distance animated by the transition when upper radius is reached
  35536. */
  35537. upperRadiusTransitionRange: number;
  35538. private _autoTransitionRange;
  35539. /**
  35540. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35541. */
  35542. /**
  35543. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35544. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35545. */
  35546. autoTransitionRange: boolean;
  35547. private _attachedCamera;
  35548. private _onAfterCheckInputsObserver;
  35549. private _onMeshTargetChangedObserver;
  35550. /**
  35551. * Initializes the behavior.
  35552. */
  35553. init(): void;
  35554. /**
  35555. * Attaches the behavior to its arc rotate camera.
  35556. * @param camera Defines the camera to attach the behavior to
  35557. */
  35558. attach(camera: ArcRotateCamera): void;
  35559. /**
  35560. * Detaches the behavior from its current arc rotate camera.
  35561. */
  35562. detach(): void;
  35563. private _radiusIsAnimating;
  35564. private _radiusBounceTransition;
  35565. private _animatables;
  35566. private _cachedWheelPrecision;
  35567. /**
  35568. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35569. * @param radiusLimit The limit to check against.
  35570. * @return Bool to indicate if at limit.
  35571. */
  35572. private _isRadiusAtLimit;
  35573. /**
  35574. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35575. * @param radiusDelta The delta by which to animate to. Can be negative.
  35576. */
  35577. private _applyBoundRadiusAnimation;
  35578. /**
  35579. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35580. */
  35581. protected _clearAnimationLocks(): void;
  35582. /**
  35583. * Stops and removes all animations that have been applied to the camera
  35584. */
  35585. stopAllAnimations(): void;
  35586. }
  35587. }
  35588. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35589. import { Behavior } from "babylonjs/Behaviors/behavior";
  35590. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35591. import { ExponentialEase } from "babylonjs/Animations/easing";
  35592. import { Nullable } from "babylonjs/types";
  35593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35594. import { Vector3 } from "babylonjs/Maths/math";
  35595. /**
  35596. * 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.
  35597. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35598. */
  35599. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35600. /**
  35601. * Gets the name of the behavior.
  35602. */
  35603. readonly name: string;
  35604. private _mode;
  35605. private _radiusScale;
  35606. private _positionScale;
  35607. private _defaultElevation;
  35608. private _elevationReturnTime;
  35609. private _elevationReturnWaitTime;
  35610. private _zoomStopsAnimation;
  35611. private _framingTime;
  35612. /**
  35613. * The easing function used by animations
  35614. */
  35615. static EasingFunction: ExponentialEase;
  35616. /**
  35617. * The easing mode used by animations
  35618. */
  35619. static EasingMode: number;
  35620. /**
  35621. * Sets the current mode used by the behavior
  35622. */
  35623. /**
  35624. * Gets current mode used by the behavior.
  35625. */
  35626. mode: number;
  35627. /**
  35628. * Sets the scale applied to the radius (1 by default)
  35629. */
  35630. /**
  35631. * Gets the scale applied to the radius
  35632. */
  35633. radiusScale: number;
  35634. /**
  35635. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35636. */
  35637. /**
  35638. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35639. */
  35640. positionScale: number;
  35641. /**
  35642. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35643. * behaviour is triggered, in radians.
  35644. */
  35645. /**
  35646. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35647. * behaviour is triggered, in radians.
  35648. */
  35649. defaultElevation: number;
  35650. /**
  35651. * Sets the time (in milliseconds) taken to return to the default beta position.
  35652. * Negative value indicates camera should not return to default.
  35653. */
  35654. /**
  35655. * Gets the time (in milliseconds) taken to return to the default beta position.
  35656. * Negative value indicates camera should not return to default.
  35657. */
  35658. elevationReturnTime: number;
  35659. /**
  35660. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35661. */
  35662. /**
  35663. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35664. */
  35665. elevationReturnWaitTime: number;
  35666. /**
  35667. * Sets the flag that indicates if user zooming should stop animation.
  35668. */
  35669. /**
  35670. * Gets the flag that indicates if user zooming should stop animation.
  35671. */
  35672. zoomStopsAnimation: boolean;
  35673. /**
  35674. * Sets the transition time when framing the mesh, in milliseconds
  35675. */
  35676. /**
  35677. * Gets the transition time when framing the mesh, in milliseconds
  35678. */
  35679. framingTime: number;
  35680. /**
  35681. * Define if the behavior should automatically change the configured
  35682. * camera limits and sensibilities.
  35683. */
  35684. autoCorrectCameraLimitsAndSensibility: boolean;
  35685. private _onPrePointerObservableObserver;
  35686. private _onAfterCheckInputsObserver;
  35687. private _onMeshTargetChangedObserver;
  35688. private _attachedCamera;
  35689. private _isPointerDown;
  35690. private _lastInteractionTime;
  35691. /**
  35692. * Initializes the behavior.
  35693. */
  35694. init(): void;
  35695. /**
  35696. * Attaches the behavior to its arc rotate camera.
  35697. * @param camera Defines the camera to attach the behavior to
  35698. */
  35699. attach(camera: ArcRotateCamera): void;
  35700. /**
  35701. * Detaches the behavior from its current arc rotate camera.
  35702. */
  35703. detach(): void;
  35704. private _animatables;
  35705. private _betaIsAnimating;
  35706. private _betaTransition;
  35707. private _radiusTransition;
  35708. private _vectorTransition;
  35709. /**
  35710. * Targets the given mesh and updates zoom level accordingly.
  35711. * @param mesh The mesh to target.
  35712. * @param radius Optional. If a cached radius position already exists, overrides default.
  35713. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35714. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35715. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35716. */
  35717. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35718. /**
  35719. * Targets the given mesh with its children and updates zoom level accordingly.
  35720. * @param mesh The mesh to target.
  35721. * @param radius Optional. If a cached radius position already exists, overrides default.
  35722. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35723. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35724. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35725. */
  35726. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35727. /**
  35728. * Targets the given meshes with their children and updates zoom level accordingly.
  35729. * @param meshes The mesh to target.
  35730. * @param radius Optional. If a cached radius position already exists, overrides default.
  35731. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35732. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35733. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35734. */
  35735. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35736. /**
  35737. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35738. * @param minimumWorld Determines the smaller position of the bounding box extend
  35739. * @param maximumWorld Determines the bigger position of the bounding box extend
  35740. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35741. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35742. */
  35743. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35744. /**
  35745. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35746. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35747. * frustum width.
  35748. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35749. * to fully enclose the mesh in the viewing frustum.
  35750. */
  35751. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35752. /**
  35753. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35754. * is automatically returned to its default position (expected to be above ground plane).
  35755. */
  35756. private _maintainCameraAboveGround;
  35757. /**
  35758. * Returns the frustum slope based on the canvas ratio and camera FOV
  35759. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35760. */
  35761. private _getFrustumSlope;
  35762. /**
  35763. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35764. */
  35765. private _clearAnimationLocks;
  35766. /**
  35767. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35768. */
  35769. private _applyUserInteraction;
  35770. /**
  35771. * Stops and removes all animations that have been applied to the camera
  35772. */
  35773. stopAllAnimations(): void;
  35774. /**
  35775. * Gets a value indicating if the user is moving the camera
  35776. */
  35777. readonly isUserIsMoving: boolean;
  35778. /**
  35779. * The camera can move all the way towards the mesh.
  35780. */
  35781. static IgnoreBoundsSizeMode: number;
  35782. /**
  35783. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35784. */
  35785. static FitFrustumSidesMode: number;
  35786. }
  35787. }
  35788. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35789. import { Nullable } from "babylonjs/types";
  35790. import { Camera } from "babylonjs/Cameras/camera";
  35791. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35792. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35793. /**
  35794. * Base class for Camera Pointer Inputs.
  35795. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35796. * for example usage.
  35797. */
  35798. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35799. /**
  35800. * Defines the camera the input is attached to.
  35801. */
  35802. abstract camera: Camera;
  35803. /**
  35804. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35805. */
  35806. protected _altKey: boolean;
  35807. protected _ctrlKey: boolean;
  35808. protected _metaKey: boolean;
  35809. protected _shiftKey: boolean;
  35810. /**
  35811. * Which mouse buttons were pressed at time of last mouse event.
  35812. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35813. */
  35814. protected _buttonsPressed: number;
  35815. /**
  35816. * Defines the buttons associated with the input to handle camera move.
  35817. */
  35818. buttons: number[];
  35819. /**
  35820. * Attach the input controls to a specific dom element to get the input from.
  35821. * @param element Defines the element the controls should be listened from
  35822. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35823. */
  35824. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35825. /**
  35826. * Detach the current controls from the specified dom element.
  35827. * @param element Defines the element to stop listening the inputs from
  35828. */
  35829. detachControl(element: Nullable<HTMLElement>): void;
  35830. /**
  35831. * Gets the class name of the current input.
  35832. * @returns the class name
  35833. */
  35834. getClassName(): string;
  35835. /**
  35836. * Get the friendly name associated with the input class.
  35837. * @returns the input friendly name
  35838. */
  35839. getSimpleName(): string;
  35840. /**
  35841. * Called on pointer POINTERDOUBLETAP event.
  35842. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35843. */
  35844. protected onDoubleTap(type: string): void;
  35845. /**
  35846. * Called on pointer POINTERMOVE event if only a single touch is active.
  35847. * Override this method to provide functionality.
  35848. */
  35849. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35850. /**
  35851. * Called on pointer POINTERMOVE event if multiple touches are active.
  35852. * Override this method to provide functionality.
  35853. */
  35854. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35855. /**
  35856. * Called on JS contextmenu event.
  35857. * Override this method to provide functionality.
  35858. */
  35859. protected onContextMenu(evt: PointerEvent): void;
  35860. /**
  35861. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35862. * press.
  35863. * Override this method to provide functionality.
  35864. */
  35865. protected onButtonDown(evt: PointerEvent): void;
  35866. /**
  35867. * Called each time a new POINTERUP event occurs. Ie, for each button
  35868. * release.
  35869. * Override this method to provide functionality.
  35870. */
  35871. protected onButtonUp(evt: PointerEvent): void;
  35872. /**
  35873. * Called when window becomes inactive.
  35874. * Override this method to provide functionality.
  35875. */
  35876. protected onLostFocus(): void;
  35877. private _pointerInput;
  35878. private _observer;
  35879. private _onLostFocus;
  35880. private pointA;
  35881. private pointB;
  35882. }
  35883. }
  35884. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35885. import { Nullable } from "babylonjs/types";
  35886. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35887. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35888. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35889. /**
  35890. * Manage the pointers inputs to control an arc rotate camera.
  35891. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35892. */
  35893. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35894. /**
  35895. * Defines the camera the input is attached to.
  35896. */
  35897. camera: ArcRotateCamera;
  35898. /**
  35899. * Gets the class name of the current input.
  35900. * @returns the class name
  35901. */
  35902. getClassName(): string;
  35903. /**
  35904. * Defines the buttons associated with the input to handle camera move.
  35905. */
  35906. buttons: number[];
  35907. /**
  35908. * Defines the pointer angular sensibility along the X axis or how fast is
  35909. * the camera rotating.
  35910. */
  35911. angularSensibilityX: number;
  35912. /**
  35913. * Defines the pointer angular sensibility along the Y axis or how fast is
  35914. * the camera rotating.
  35915. */
  35916. angularSensibilityY: number;
  35917. /**
  35918. * Defines the pointer pinch precision or how fast is the camera zooming.
  35919. */
  35920. pinchPrecision: number;
  35921. /**
  35922. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35923. * from 0.
  35924. * It defines the percentage of current camera.radius to use as delta when
  35925. * pinch zoom is used.
  35926. */
  35927. pinchDeltaPercentage: number;
  35928. /**
  35929. * Defines the pointer panning sensibility or how fast is the camera moving.
  35930. */
  35931. panningSensibility: number;
  35932. /**
  35933. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35934. */
  35935. multiTouchPanning: boolean;
  35936. /**
  35937. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35938. * zoom (pinch) through multitouch.
  35939. */
  35940. multiTouchPanAndZoom: boolean;
  35941. /**
  35942. * Revers pinch action direction.
  35943. */
  35944. pinchInwards: boolean;
  35945. private _isPanClick;
  35946. private _twoFingerActivityCount;
  35947. private _isPinching;
  35948. /**
  35949. * Called on pointer POINTERMOVE event if only a single touch is active.
  35950. */
  35951. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35952. /**
  35953. * Called on pointer POINTERDOUBLETAP event.
  35954. */
  35955. protected onDoubleTap(type: string): void;
  35956. /**
  35957. * Called on pointer POINTERMOVE event if multiple touches are active.
  35958. */
  35959. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35960. /**
  35961. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35962. * press.
  35963. */
  35964. protected onButtonDown(evt: PointerEvent): void;
  35965. /**
  35966. * Called each time a new POINTERUP event occurs. Ie, for each button
  35967. * release.
  35968. */
  35969. protected onButtonUp(evt: PointerEvent): void;
  35970. /**
  35971. * Called when window becomes inactive.
  35972. */
  35973. protected onLostFocus(): void;
  35974. }
  35975. }
  35976. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35977. import { Nullable } from "babylonjs/types";
  35978. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35979. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35980. /**
  35981. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35982. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35983. */
  35984. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35985. /**
  35986. * Defines the camera the input is attached to.
  35987. */
  35988. camera: ArcRotateCamera;
  35989. /**
  35990. * Defines the list of key codes associated with the up action (increase alpha)
  35991. */
  35992. keysUp: number[];
  35993. /**
  35994. * Defines the list of key codes associated with the down action (decrease alpha)
  35995. */
  35996. keysDown: number[];
  35997. /**
  35998. * Defines the list of key codes associated with the left action (increase beta)
  35999. */
  36000. keysLeft: number[];
  36001. /**
  36002. * Defines the list of key codes associated with the right action (decrease beta)
  36003. */
  36004. keysRight: number[];
  36005. /**
  36006. * Defines the list of key codes associated with the reset action.
  36007. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36008. */
  36009. keysReset: number[];
  36010. /**
  36011. * Defines the panning sensibility of the inputs.
  36012. * (How fast is the camera paning)
  36013. */
  36014. panningSensibility: number;
  36015. /**
  36016. * Defines the zooming sensibility of the inputs.
  36017. * (How fast is the camera zooming)
  36018. */
  36019. zoomingSensibility: number;
  36020. /**
  36021. * Defines wether maintaining the alt key down switch the movement mode from
  36022. * orientation to zoom.
  36023. */
  36024. useAltToZoom: boolean;
  36025. /**
  36026. * Rotation speed of the camera
  36027. */
  36028. angularSpeed: number;
  36029. private _keys;
  36030. private _ctrlPressed;
  36031. private _altPressed;
  36032. private _onCanvasBlurObserver;
  36033. private _onKeyboardObserver;
  36034. private _engine;
  36035. private _scene;
  36036. /**
  36037. * Attach the input controls to a specific dom element to get the input from.
  36038. * @param element Defines the element the controls should be listened from
  36039. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36040. */
  36041. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36042. /**
  36043. * Detach the current controls from the specified dom element.
  36044. * @param element Defines the element to stop listening the inputs from
  36045. */
  36046. detachControl(element: Nullable<HTMLElement>): void;
  36047. /**
  36048. * Update the current camera state depending on the inputs that have been used this frame.
  36049. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36050. */
  36051. checkInputs(): void;
  36052. /**
  36053. * Gets the class name of the current intput.
  36054. * @returns the class name
  36055. */
  36056. getClassName(): string;
  36057. /**
  36058. * Get the friendly name associated with the input class.
  36059. * @returns the input friendly name
  36060. */
  36061. getSimpleName(): string;
  36062. }
  36063. }
  36064. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36065. import { Nullable } from "babylonjs/types";
  36066. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36067. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36068. /**
  36069. * Manage the mouse wheel inputs to control an arc rotate camera.
  36070. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36071. */
  36072. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36073. /**
  36074. * Defines the camera the input is attached to.
  36075. */
  36076. camera: ArcRotateCamera;
  36077. /**
  36078. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36079. */
  36080. wheelPrecision: number;
  36081. /**
  36082. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36083. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36084. */
  36085. wheelDeltaPercentage: number;
  36086. private _wheel;
  36087. private _observer;
  36088. private computeDeltaFromMouseWheelLegacyEvent;
  36089. /**
  36090. * Attach the input controls to a specific dom element to get the input from.
  36091. * @param element Defines the element the controls should be listened from
  36092. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36093. */
  36094. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36095. /**
  36096. * Detach the current controls from the specified dom element.
  36097. * @param element Defines the element to stop listening the inputs from
  36098. */
  36099. detachControl(element: Nullable<HTMLElement>): void;
  36100. /**
  36101. * Gets the class name of the current intput.
  36102. * @returns the class name
  36103. */
  36104. getClassName(): string;
  36105. /**
  36106. * Get the friendly name associated with the input class.
  36107. * @returns the input friendly name
  36108. */
  36109. getSimpleName(): string;
  36110. }
  36111. }
  36112. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36113. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36114. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36115. /**
  36116. * Default Inputs manager for the ArcRotateCamera.
  36117. * It groups all the default supported inputs for ease of use.
  36118. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36119. */
  36120. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36121. /**
  36122. * Instantiates a new ArcRotateCameraInputsManager.
  36123. * @param camera Defines the camera the inputs belong to
  36124. */
  36125. constructor(camera: ArcRotateCamera);
  36126. /**
  36127. * Add mouse wheel input support to the input manager.
  36128. * @returns the current input manager
  36129. */
  36130. addMouseWheel(): ArcRotateCameraInputsManager;
  36131. /**
  36132. * Add pointers input support to the input manager.
  36133. * @returns the current input manager
  36134. */
  36135. addPointers(): ArcRotateCameraInputsManager;
  36136. /**
  36137. * Add keyboard input support to the input manager.
  36138. * @returns the current input manager
  36139. */
  36140. addKeyboard(): ArcRotateCameraInputsManager;
  36141. }
  36142. }
  36143. declare module "babylonjs/Cameras/arcRotateCamera" {
  36144. import { Observable } from "babylonjs/Misc/observable";
  36145. import { Nullable } from "babylonjs/types";
  36146. import { Scene } from "babylonjs/scene";
  36147. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36149. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36150. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36151. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36152. import { Camera } from "babylonjs/Cameras/camera";
  36153. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36154. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36155. import { Collider } from "babylonjs/Collisions/collider";
  36156. /**
  36157. * This represents an orbital type of camera.
  36158. *
  36159. * 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.
  36160. * 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.
  36161. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36162. */
  36163. export class ArcRotateCamera extends TargetCamera {
  36164. /**
  36165. * Defines the rotation angle of the camera along the longitudinal axis.
  36166. */
  36167. alpha: number;
  36168. /**
  36169. * Defines the rotation angle of the camera along the latitudinal axis.
  36170. */
  36171. beta: number;
  36172. /**
  36173. * Defines the radius of the camera from it s target point.
  36174. */
  36175. radius: number;
  36176. protected _target: Vector3;
  36177. protected _targetHost: Nullable<AbstractMesh>;
  36178. /**
  36179. * Defines the target point of the camera.
  36180. * The camera looks towards it form the radius distance.
  36181. */
  36182. target: Vector3;
  36183. /**
  36184. * Define the current local position of the camera in the scene
  36185. */
  36186. position: Vector3;
  36187. protected _upVector: Vector3;
  36188. protected _upToYMatrix: Matrix;
  36189. protected _YToUpMatrix: Matrix;
  36190. /**
  36191. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36192. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36193. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36194. */
  36195. upVector: Vector3;
  36196. /**
  36197. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36198. */
  36199. setMatUp(): void;
  36200. /**
  36201. * Current inertia value on the longitudinal axis.
  36202. * The bigger this number the longer it will take for the camera to stop.
  36203. */
  36204. inertialAlphaOffset: number;
  36205. /**
  36206. * Current inertia value on the latitudinal axis.
  36207. * The bigger this number the longer it will take for the camera to stop.
  36208. */
  36209. inertialBetaOffset: number;
  36210. /**
  36211. * Current inertia value on the radius axis.
  36212. * The bigger this number the longer it will take for the camera to stop.
  36213. */
  36214. inertialRadiusOffset: number;
  36215. /**
  36216. * Minimum allowed angle on the longitudinal axis.
  36217. * This can help limiting how the Camera is able to move in the scene.
  36218. */
  36219. lowerAlphaLimit: Nullable<number>;
  36220. /**
  36221. * Maximum allowed angle on the longitudinal axis.
  36222. * This can help limiting how the Camera is able to move in the scene.
  36223. */
  36224. upperAlphaLimit: Nullable<number>;
  36225. /**
  36226. * Minimum allowed angle on the latitudinal axis.
  36227. * This can help limiting how the Camera is able to move in the scene.
  36228. */
  36229. lowerBetaLimit: number;
  36230. /**
  36231. * Maximum allowed angle on the latitudinal axis.
  36232. * This can help limiting how the Camera is able to move in the scene.
  36233. */
  36234. upperBetaLimit: number;
  36235. /**
  36236. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36237. * This can help limiting how the Camera is able to move in the scene.
  36238. */
  36239. lowerRadiusLimit: Nullable<number>;
  36240. /**
  36241. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36242. * This can help limiting how the Camera is able to move in the scene.
  36243. */
  36244. upperRadiusLimit: Nullable<number>;
  36245. /**
  36246. * Defines the current inertia value used during panning of the camera along the X axis.
  36247. */
  36248. inertialPanningX: number;
  36249. /**
  36250. * Defines the current inertia value used during panning of the camera along the Y axis.
  36251. */
  36252. inertialPanningY: number;
  36253. /**
  36254. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36255. * Basically if your fingers moves away from more than this distance you will be considered
  36256. * in pinch mode.
  36257. */
  36258. pinchToPanMaxDistance: number;
  36259. /**
  36260. * Defines the maximum distance the camera can pan.
  36261. * This could help keeping the cammera always in your scene.
  36262. */
  36263. panningDistanceLimit: Nullable<number>;
  36264. /**
  36265. * Defines the target of the camera before paning.
  36266. */
  36267. panningOriginTarget: Vector3;
  36268. /**
  36269. * Defines the value of the inertia used during panning.
  36270. * 0 would mean stop inertia and one would mean no decelleration at all.
  36271. */
  36272. panningInertia: number;
  36273. /**
  36274. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36275. */
  36276. angularSensibilityX: number;
  36277. /**
  36278. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36279. */
  36280. angularSensibilityY: number;
  36281. /**
  36282. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36283. */
  36284. pinchPrecision: number;
  36285. /**
  36286. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36287. * It will be used instead of pinchDeltaPrecision if different from 0.
  36288. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36289. */
  36290. pinchDeltaPercentage: number;
  36291. /**
  36292. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36293. */
  36294. panningSensibility: number;
  36295. /**
  36296. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36297. */
  36298. keysUp: number[];
  36299. /**
  36300. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36301. */
  36302. keysDown: number[];
  36303. /**
  36304. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36305. */
  36306. keysLeft: number[];
  36307. /**
  36308. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36309. */
  36310. keysRight: number[];
  36311. /**
  36312. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36313. */
  36314. wheelPrecision: number;
  36315. /**
  36316. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36317. * It will be used instead of pinchDeltaPrecision if different from 0.
  36318. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36319. */
  36320. wheelDeltaPercentage: number;
  36321. /**
  36322. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36323. */
  36324. zoomOnFactor: number;
  36325. /**
  36326. * Defines a screen offset for the camera position.
  36327. */
  36328. targetScreenOffset: Vector2;
  36329. /**
  36330. * Allows the camera to be completely reversed.
  36331. * If false the camera can not arrive upside down.
  36332. */
  36333. allowUpsideDown: boolean;
  36334. /**
  36335. * Define if double tap/click is used to restore the previously saved state of the camera.
  36336. */
  36337. useInputToRestoreState: boolean;
  36338. /** @hidden */
  36339. _viewMatrix: Matrix;
  36340. /** @hidden */
  36341. _useCtrlForPanning: boolean;
  36342. /** @hidden */
  36343. _panningMouseButton: number;
  36344. /**
  36345. * Defines the input associated to the camera.
  36346. */
  36347. inputs: ArcRotateCameraInputsManager;
  36348. /** @hidden */
  36349. _reset: () => void;
  36350. /**
  36351. * Defines the allowed panning axis.
  36352. */
  36353. panningAxis: Vector3;
  36354. protected _localDirection: Vector3;
  36355. protected _transformedDirection: Vector3;
  36356. private _bouncingBehavior;
  36357. /**
  36358. * Gets the bouncing behavior of the camera if it has been enabled.
  36359. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36360. */
  36361. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36362. /**
  36363. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36364. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36365. */
  36366. useBouncingBehavior: boolean;
  36367. private _framingBehavior;
  36368. /**
  36369. * Gets the framing behavior of the camera if it has been enabled.
  36370. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36371. */
  36372. readonly framingBehavior: Nullable<FramingBehavior>;
  36373. /**
  36374. * Defines if the framing behavior of the camera is enabled on the camera.
  36375. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36376. */
  36377. useFramingBehavior: boolean;
  36378. private _autoRotationBehavior;
  36379. /**
  36380. * Gets the auto rotation behavior of the camera if it has been enabled.
  36381. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36382. */
  36383. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36384. /**
  36385. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36386. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36387. */
  36388. useAutoRotationBehavior: boolean;
  36389. /**
  36390. * Observable triggered when the mesh target has been changed on the camera.
  36391. */
  36392. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36393. /**
  36394. * Event raised when the camera is colliding with a mesh.
  36395. */
  36396. onCollide: (collidedMesh: AbstractMesh) => void;
  36397. /**
  36398. * Defines whether the camera should check collision with the objects oh the scene.
  36399. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36400. */
  36401. checkCollisions: boolean;
  36402. /**
  36403. * Defines the collision radius of the camera.
  36404. * This simulates a sphere around the camera.
  36405. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36406. */
  36407. collisionRadius: Vector3;
  36408. protected _collider: Collider;
  36409. protected _previousPosition: Vector3;
  36410. protected _collisionVelocity: Vector3;
  36411. protected _newPosition: Vector3;
  36412. protected _previousAlpha: number;
  36413. protected _previousBeta: number;
  36414. protected _previousRadius: number;
  36415. protected _collisionTriggered: boolean;
  36416. protected _targetBoundingCenter: Nullable<Vector3>;
  36417. private _computationVector;
  36418. /**
  36419. * Instantiates a new ArcRotateCamera in a given scene
  36420. * @param name Defines the name of the camera
  36421. * @param alpha Defines the camera rotation along the logitudinal axis
  36422. * @param beta Defines the camera rotation along the latitudinal axis
  36423. * @param radius Defines the camera distance from its target
  36424. * @param target Defines the camera target
  36425. * @param scene Defines the scene the camera belongs to
  36426. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36427. */
  36428. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36429. /** @hidden */
  36430. _initCache(): void;
  36431. /** @hidden */
  36432. _updateCache(ignoreParentClass?: boolean): void;
  36433. protected _getTargetPosition(): Vector3;
  36434. private _storedAlpha;
  36435. private _storedBeta;
  36436. private _storedRadius;
  36437. private _storedTarget;
  36438. /**
  36439. * Stores the current state of the camera (alpha, beta, radius and target)
  36440. * @returns the camera itself
  36441. */
  36442. storeState(): Camera;
  36443. /**
  36444. * @hidden
  36445. * Restored camera state. You must call storeState() first
  36446. */
  36447. _restoreStateValues(): boolean;
  36448. /** @hidden */
  36449. _isSynchronizedViewMatrix(): boolean;
  36450. /**
  36451. * Attached controls to the current camera.
  36452. * @param element Defines the element the controls should be listened from
  36453. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36454. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36455. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36456. */
  36457. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36458. /**
  36459. * Detach the current controls from the camera.
  36460. * The camera will stop reacting to inputs.
  36461. * @param element Defines the element to stop listening the inputs from
  36462. */
  36463. detachControl(element: HTMLElement): void;
  36464. /** @hidden */
  36465. _checkInputs(): void;
  36466. protected _checkLimits(): void;
  36467. /**
  36468. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36469. */
  36470. rebuildAnglesAndRadius(): void;
  36471. /**
  36472. * Use a position to define the current camera related information like aplha, beta and radius
  36473. * @param position Defines the position to set the camera at
  36474. */
  36475. setPosition(position: Vector3): void;
  36476. /**
  36477. * Defines the target the camera should look at.
  36478. * This will automatically adapt alpha beta and radius to fit within the new target.
  36479. * @param target Defines the new target as a Vector or a mesh
  36480. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36481. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36482. */
  36483. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36484. /** @hidden */
  36485. _getViewMatrix(): Matrix;
  36486. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36487. /**
  36488. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36489. * @param meshes Defines the mesh to zoom on
  36490. * @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)
  36491. */
  36492. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36493. /**
  36494. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36495. * The target will be changed but the radius
  36496. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36497. * @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)
  36498. */
  36499. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36500. min: Vector3;
  36501. max: Vector3;
  36502. distance: number;
  36503. }, doNotUpdateMaxZ?: boolean): void;
  36504. /**
  36505. * @override
  36506. * Override Camera.createRigCamera
  36507. */
  36508. createRigCamera(name: string, cameraIndex: number): Camera;
  36509. /**
  36510. * @hidden
  36511. * @override
  36512. * Override Camera._updateRigCameras
  36513. */
  36514. _updateRigCameras(): void;
  36515. /**
  36516. * Destroy the camera and release the current resources hold by it.
  36517. */
  36518. dispose(): void;
  36519. /**
  36520. * Gets the current object class name.
  36521. * @return the class name
  36522. */
  36523. getClassName(): string;
  36524. }
  36525. }
  36526. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36527. import { Behavior } from "babylonjs/Behaviors/behavior";
  36528. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36529. /**
  36530. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36531. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36532. */
  36533. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36534. /**
  36535. * Gets the name of the behavior.
  36536. */
  36537. readonly name: string;
  36538. private _zoomStopsAnimation;
  36539. private _idleRotationSpeed;
  36540. private _idleRotationWaitTime;
  36541. private _idleRotationSpinupTime;
  36542. /**
  36543. * Sets the flag that indicates if user zooming should stop animation.
  36544. */
  36545. /**
  36546. * Gets the flag that indicates if user zooming should stop animation.
  36547. */
  36548. zoomStopsAnimation: boolean;
  36549. /**
  36550. * Sets the default speed at which the camera rotates around the model.
  36551. */
  36552. /**
  36553. * Gets the default speed at which the camera rotates around the model.
  36554. */
  36555. idleRotationSpeed: number;
  36556. /**
  36557. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36558. */
  36559. /**
  36560. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36561. */
  36562. idleRotationWaitTime: number;
  36563. /**
  36564. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36565. */
  36566. /**
  36567. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36568. */
  36569. idleRotationSpinupTime: number;
  36570. /**
  36571. * Gets a value indicating if the camera is currently rotating because of this behavior
  36572. */
  36573. readonly rotationInProgress: boolean;
  36574. private _onPrePointerObservableObserver;
  36575. private _onAfterCheckInputsObserver;
  36576. private _attachedCamera;
  36577. private _isPointerDown;
  36578. private _lastFrameTime;
  36579. private _lastInteractionTime;
  36580. private _cameraRotationSpeed;
  36581. /**
  36582. * Initializes the behavior.
  36583. */
  36584. init(): void;
  36585. /**
  36586. * Attaches the behavior to its arc rotate camera.
  36587. * @param camera Defines the camera to attach the behavior to
  36588. */
  36589. attach(camera: ArcRotateCamera): void;
  36590. /**
  36591. * Detaches the behavior from its current arc rotate camera.
  36592. */
  36593. detach(): void;
  36594. /**
  36595. * Returns true if user is scrolling.
  36596. * @return true if user is scrolling.
  36597. */
  36598. private _userIsZooming;
  36599. private _lastFrameRadius;
  36600. private _shouldAnimationStopForInteraction;
  36601. /**
  36602. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36603. */
  36604. private _applyUserInteraction;
  36605. private _userIsMoving;
  36606. }
  36607. }
  36608. declare module "babylonjs/Behaviors/Cameras/index" {
  36609. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36610. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36611. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36612. }
  36613. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36614. import { Mesh } from "babylonjs/Meshes/mesh";
  36615. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36616. import { Behavior } from "babylonjs/Behaviors/behavior";
  36617. /**
  36618. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36619. */
  36620. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36621. private ui;
  36622. /**
  36623. * The name of the behavior
  36624. */
  36625. name: string;
  36626. /**
  36627. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36628. */
  36629. distanceAwayFromFace: number;
  36630. /**
  36631. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36632. */
  36633. distanceAwayFromBottomOfFace: number;
  36634. private _faceVectors;
  36635. private _target;
  36636. private _scene;
  36637. private _onRenderObserver;
  36638. private _tmpMatrix;
  36639. private _tmpVector;
  36640. /**
  36641. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36642. * @param ui The transform node that should be attched to the mesh
  36643. */
  36644. constructor(ui: TransformNode);
  36645. /**
  36646. * Initializes the behavior
  36647. */
  36648. init(): void;
  36649. private _closestFace;
  36650. private _zeroVector;
  36651. private _lookAtTmpMatrix;
  36652. private _lookAtToRef;
  36653. /**
  36654. * Attaches the AttachToBoxBehavior to the passed in mesh
  36655. * @param target The mesh that the specified node will be attached to
  36656. */
  36657. attach(target: Mesh): void;
  36658. /**
  36659. * Detaches the behavior from the mesh
  36660. */
  36661. detach(): void;
  36662. }
  36663. }
  36664. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36665. import { Behavior } from "babylonjs/Behaviors/behavior";
  36666. import { Mesh } from "babylonjs/Meshes/mesh";
  36667. /**
  36668. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36669. */
  36670. export class FadeInOutBehavior implements Behavior<Mesh> {
  36671. /**
  36672. * Time in milliseconds to delay before fading in (Default: 0)
  36673. */
  36674. delay: number;
  36675. /**
  36676. * Time in milliseconds for the mesh to fade in (Default: 300)
  36677. */
  36678. fadeInTime: number;
  36679. private _millisecondsPerFrame;
  36680. private _hovered;
  36681. private _hoverValue;
  36682. private _ownerNode;
  36683. /**
  36684. * Instatiates the FadeInOutBehavior
  36685. */
  36686. constructor();
  36687. /**
  36688. * The name of the behavior
  36689. */
  36690. readonly name: string;
  36691. /**
  36692. * Initializes the behavior
  36693. */
  36694. init(): void;
  36695. /**
  36696. * Attaches the fade behavior on the passed in mesh
  36697. * @param ownerNode The mesh that will be faded in/out once attached
  36698. */
  36699. attach(ownerNode: Mesh): void;
  36700. /**
  36701. * Detaches the behavior from the mesh
  36702. */
  36703. detach(): void;
  36704. /**
  36705. * Triggers the mesh to begin fading in or out
  36706. * @param value if the object should fade in or out (true to fade in)
  36707. */
  36708. fadeIn(value: boolean): void;
  36709. private _update;
  36710. private _setAllVisibility;
  36711. }
  36712. }
  36713. declare module "babylonjs/Misc/pivotTools" {
  36714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36715. /**
  36716. * Class containing a set of static utilities functions for managing Pivots
  36717. * @hidden
  36718. */
  36719. export class PivotTools {
  36720. private static _PivotCached;
  36721. private static _OldPivotPoint;
  36722. private static _PivotTranslation;
  36723. private static _PivotTmpVector;
  36724. /** @hidden */
  36725. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36726. /** @hidden */
  36727. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36728. }
  36729. }
  36730. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36731. import { Scene } from "babylonjs/scene";
  36732. import { Vector4, Plane } from "babylonjs/Maths/math";
  36733. import { Mesh } from "babylonjs/Meshes/mesh";
  36734. import { Nullable } from "babylonjs/types";
  36735. /**
  36736. * Class containing static functions to help procedurally build meshes
  36737. */
  36738. export class PlaneBuilder {
  36739. /**
  36740. * Creates a plane mesh
  36741. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36742. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36743. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36747. * @param name defines the name of the mesh
  36748. * @param options defines the options used to create the mesh
  36749. * @param scene defines the hosting scene
  36750. * @returns the plane mesh
  36751. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36752. */
  36753. static CreatePlane(name: string, options: {
  36754. size?: number;
  36755. width?: number;
  36756. height?: number;
  36757. sideOrientation?: number;
  36758. frontUVs?: Vector4;
  36759. backUVs?: Vector4;
  36760. updatable?: boolean;
  36761. sourcePlane?: Plane;
  36762. }, scene?: Nullable<Scene>): Mesh;
  36763. }
  36764. }
  36765. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36766. import { Behavior } from "babylonjs/Behaviors/behavior";
  36767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36768. import { Observable } from "babylonjs/Misc/observable";
  36769. import { Vector3 } from "babylonjs/Maths/math";
  36770. import { Ray } from "babylonjs/Culling/ray";
  36771. import "babylonjs/Meshes/Builders/planeBuilder";
  36772. /**
  36773. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36774. */
  36775. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36776. private static _AnyMouseID;
  36777. private _attachedNode;
  36778. private _dragPlane;
  36779. private _scene;
  36780. private _pointerObserver;
  36781. private _beforeRenderObserver;
  36782. private static _planeScene;
  36783. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36784. /**
  36785. * 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)
  36786. */
  36787. maxDragAngle: number;
  36788. /**
  36789. * @hidden
  36790. */
  36791. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36792. /**
  36793. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36794. */
  36795. currentDraggingPointerID: number;
  36796. /**
  36797. * The last position where the pointer hit the drag plane in world space
  36798. */
  36799. lastDragPosition: Vector3;
  36800. /**
  36801. * If the behavior is currently in a dragging state
  36802. */
  36803. dragging: boolean;
  36804. /**
  36805. * 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)
  36806. */
  36807. dragDeltaRatio: number;
  36808. /**
  36809. * If the drag plane orientation should be updated during the dragging (Default: true)
  36810. */
  36811. updateDragPlane: boolean;
  36812. private _debugMode;
  36813. private _moving;
  36814. /**
  36815. * Fires each time the attached mesh is dragged with the pointer
  36816. * * delta between last drag position and current drag position in world space
  36817. * * dragDistance along the drag axis
  36818. * * dragPlaneNormal normal of the current drag plane used during the drag
  36819. * * dragPlanePoint in world space where the drag intersects the drag plane
  36820. */
  36821. onDragObservable: Observable<{
  36822. delta: Vector3;
  36823. dragPlanePoint: Vector3;
  36824. dragPlaneNormal: Vector3;
  36825. dragDistance: number;
  36826. pointerId: number;
  36827. }>;
  36828. /**
  36829. * Fires each time a drag begins (eg. mouse down on mesh)
  36830. */
  36831. onDragStartObservable: Observable<{
  36832. dragPlanePoint: Vector3;
  36833. pointerId: number;
  36834. }>;
  36835. /**
  36836. * Fires each time a drag ends (eg. mouse release after drag)
  36837. */
  36838. onDragEndObservable: Observable<{
  36839. dragPlanePoint: Vector3;
  36840. pointerId: number;
  36841. }>;
  36842. /**
  36843. * If the attached mesh should be moved when dragged
  36844. */
  36845. moveAttached: boolean;
  36846. /**
  36847. * If the drag behavior will react to drag events (Default: true)
  36848. */
  36849. enabled: boolean;
  36850. /**
  36851. * If camera controls should be detached during the drag
  36852. */
  36853. detachCameraControls: boolean;
  36854. /**
  36855. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36856. */
  36857. useObjectOrienationForDragging: boolean;
  36858. private _options;
  36859. /**
  36860. * Creates a pointer drag behavior that can be attached to a mesh
  36861. * @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)
  36862. */
  36863. constructor(options?: {
  36864. dragAxis?: Vector3;
  36865. dragPlaneNormal?: Vector3;
  36866. });
  36867. /**
  36868. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36869. */
  36870. validateDrag: (targetPosition: Vector3) => boolean;
  36871. /**
  36872. * The name of the behavior
  36873. */
  36874. readonly name: string;
  36875. /**
  36876. * Initializes the behavior
  36877. */
  36878. init(): void;
  36879. private _tmpVector;
  36880. private _alternatePickedPoint;
  36881. private _worldDragAxis;
  36882. private _targetPosition;
  36883. private _attachedElement;
  36884. /**
  36885. * Attaches the drag behavior the passed in mesh
  36886. * @param ownerNode The mesh that will be dragged around once attached
  36887. */
  36888. attach(ownerNode: AbstractMesh): void;
  36889. /**
  36890. * Force relase the drag action by code.
  36891. */
  36892. releaseDrag(): void;
  36893. private _startDragRay;
  36894. private _lastPointerRay;
  36895. /**
  36896. * Simulates the start of a pointer drag event on the behavior
  36897. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36898. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36899. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36900. */
  36901. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36902. private _startDrag;
  36903. private _dragDelta;
  36904. private _moveDrag;
  36905. private _pickWithRayOnDragPlane;
  36906. private _pointA;
  36907. private _pointB;
  36908. private _pointC;
  36909. private _lineA;
  36910. private _lineB;
  36911. private _localAxis;
  36912. private _lookAt;
  36913. private _updateDragPlanePosition;
  36914. /**
  36915. * Detaches the behavior from the mesh
  36916. */
  36917. detach(): void;
  36918. }
  36919. }
  36920. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36921. import { Mesh } from "babylonjs/Meshes/mesh";
  36922. import { Behavior } from "babylonjs/Behaviors/behavior";
  36923. /**
  36924. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36925. */
  36926. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36927. private _dragBehaviorA;
  36928. private _dragBehaviorB;
  36929. private _startDistance;
  36930. private _initialScale;
  36931. private _targetScale;
  36932. private _ownerNode;
  36933. private _sceneRenderObserver;
  36934. /**
  36935. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36936. */
  36937. constructor();
  36938. /**
  36939. * The name of the behavior
  36940. */
  36941. readonly name: string;
  36942. /**
  36943. * Initializes the behavior
  36944. */
  36945. init(): void;
  36946. private _getCurrentDistance;
  36947. /**
  36948. * Attaches the scale behavior the passed in mesh
  36949. * @param ownerNode The mesh that will be scaled around once attached
  36950. */
  36951. attach(ownerNode: Mesh): void;
  36952. /**
  36953. * Detaches the behavior from the mesh
  36954. */
  36955. detach(): void;
  36956. }
  36957. }
  36958. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36959. import { Behavior } from "babylonjs/Behaviors/behavior";
  36960. import { Mesh } from "babylonjs/Meshes/mesh";
  36961. import { Observable } from "babylonjs/Misc/observable";
  36962. /**
  36963. * 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
  36964. */
  36965. export class SixDofDragBehavior implements Behavior<Mesh> {
  36966. private static _virtualScene;
  36967. private _ownerNode;
  36968. private _sceneRenderObserver;
  36969. private _scene;
  36970. private _targetPosition;
  36971. private _virtualOriginMesh;
  36972. private _virtualDragMesh;
  36973. private _pointerObserver;
  36974. private _moving;
  36975. private _startingOrientation;
  36976. /**
  36977. * 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)
  36978. */
  36979. private zDragFactor;
  36980. /**
  36981. * If the object should rotate to face the drag origin
  36982. */
  36983. rotateDraggedObject: boolean;
  36984. /**
  36985. * If the behavior is currently in a dragging state
  36986. */
  36987. dragging: boolean;
  36988. /**
  36989. * 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)
  36990. */
  36991. dragDeltaRatio: number;
  36992. /**
  36993. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36994. */
  36995. currentDraggingPointerID: number;
  36996. /**
  36997. * If camera controls should be detached during the drag
  36998. */
  36999. detachCameraControls: boolean;
  37000. /**
  37001. * Fires each time a drag starts
  37002. */
  37003. onDragStartObservable: Observable<{}>;
  37004. /**
  37005. * Fires each time a drag ends (eg. mouse release after drag)
  37006. */
  37007. onDragEndObservable: Observable<{}>;
  37008. /**
  37009. * 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
  37010. */
  37011. constructor();
  37012. /**
  37013. * The name of the behavior
  37014. */
  37015. readonly name: string;
  37016. /**
  37017. * Initializes the behavior
  37018. */
  37019. init(): void;
  37020. /**
  37021. * Attaches the scale behavior the passed in mesh
  37022. * @param ownerNode The mesh that will be scaled around once attached
  37023. */
  37024. attach(ownerNode: Mesh): void;
  37025. /**
  37026. * Detaches the behavior from the mesh
  37027. */
  37028. detach(): void;
  37029. }
  37030. }
  37031. declare module "babylonjs/Behaviors/Meshes/index" {
  37032. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37033. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37034. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37035. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37036. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37037. }
  37038. declare module "babylonjs/Behaviors/index" {
  37039. export * from "babylonjs/Behaviors/behavior";
  37040. export * from "babylonjs/Behaviors/Cameras/index";
  37041. export * from "babylonjs/Behaviors/Meshes/index";
  37042. }
  37043. declare module "babylonjs/Bones/boneIKController" {
  37044. import { Bone } from "babylonjs/Bones/bone";
  37045. import { Vector3 } from "babylonjs/Maths/math";
  37046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37047. import { Nullable } from "babylonjs/types";
  37048. /**
  37049. * Class used to apply inverse kinematics to bones
  37050. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37051. */
  37052. export class BoneIKController {
  37053. private static _tmpVecs;
  37054. private static _tmpQuat;
  37055. private static _tmpMats;
  37056. /**
  37057. * Gets or sets the target mesh
  37058. */
  37059. targetMesh: AbstractMesh;
  37060. /** Gets or sets the mesh used as pole */
  37061. poleTargetMesh: AbstractMesh;
  37062. /**
  37063. * Gets or sets the bone used as pole
  37064. */
  37065. poleTargetBone: Nullable<Bone>;
  37066. /**
  37067. * Gets or sets the target position
  37068. */
  37069. targetPosition: Vector3;
  37070. /**
  37071. * Gets or sets the pole target position
  37072. */
  37073. poleTargetPosition: Vector3;
  37074. /**
  37075. * Gets or sets the pole target local offset
  37076. */
  37077. poleTargetLocalOffset: Vector3;
  37078. /**
  37079. * Gets or sets the pole angle
  37080. */
  37081. poleAngle: number;
  37082. /**
  37083. * Gets or sets the mesh associated with the controller
  37084. */
  37085. mesh: AbstractMesh;
  37086. /**
  37087. * 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)
  37088. */
  37089. slerpAmount: number;
  37090. private _bone1Quat;
  37091. private _bone1Mat;
  37092. private _bone2Ang;
  37093. private _bone1;
  37094. private _bone2;
  37095. private _bone1Length;
  37096. private _bone2Length;
  37097. private _maxAngle;
  37098. private _maxReach;
  37099. private _rightHandedSystem;
  37100. private _bendAxis;
  37101. private _slerping;
  37102. private _adjustRoll;
  37103. /**
  37104. * Gets or sets maximum allowed angle
  37105. */
  37106. maxAngle: number;
  37107. /**
  37108. * Creates a new BoneIKController
  37109. * @param mesh defines the mesh to control
  37110. * @param bone defines the bone to control
  37111. * @param options defines options to set up the controller
  37112. */
  37113. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37114. targetMesh?: AbstractMesh;
  37115. poleTargetMesh?: AbstractMesh;
  37116. poleTargetBone?: Bone;
  37117. poleTargetLocalOffset?: Vector3;
  37118. poleAngle?: number;
  37119. bendAxis?: Vector3;
  37120. maxAngle?: number;
  37121. slerpAmount?: number;
  37122. });
  37123. private _setMaxAngle;
  37124. /**
  37125. * Force the controller to update the bones
  37126. */
  37127. update(): void;
  37128. }
  37129. }
  37130. declare module "babylonjs/Bones/boneLookController" {
  37131. import { Vector3, Space } from "babylonjs/Maths/math";
  37132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37133. import { Bone } from "babylonjs/Bones/bone";
  37134. /**
  37135. * Class used to make a bone look toward a point in space
  37136. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37137. */
  37138. export class BoneLookController {
  37139. private static _tmpVecs;
  37140. private static _tmpQuat;
  37141. private static _tmpMats;
  37142. /**
  37143. * The target Vector3 that the bone will look at
  37144. */
  37145. target: Vector3;
  37146. /**
  37147. * The mesh that the bone is attached to
  37148. */
  37149. mesh: AbstractMesh;
  37150. /**
  37151. * The bone that will be looking to the target
  37152. */
  37153. bone: Bone;
  37154. /**
  37155. * The up axis of the coordinate system that is used when the bone is rotated
  37156. */
  37157. upAxis: Vector3;
  37158. /**
  37159. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37160. */
  37161. upAxisSpace: Space;
  37162. /**
  37163. * Used to make an adjustment to the yaw of the bone
  37164. */
  37165. adjustYaw: number;
  37166. /**
  37167. * Used to make an adjustment to the pitch of the bone
  37168. */
  37169. adjustPitch: number;
  37170. /**
  37171. * Used to make an adjustment to the roll of the bone
  37172. */
  37173. adjustRoll: number;
  37174. /**
  37175. * 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)
  37176. */
  37177. slerpAmount: number;
  37178. private _minYaw;
  37179. private _maxYaw;
  37180. private _minPitch;
  37181. private _maxPitch;
  37182. private _minYawSin;
  37183. private _minYawCos;
  37184. private _maxYawSin;
  37185. private _maxYawCos;
  37186. private _midYawConstraint;
  37187. private _minPitchTan;
  37188. private _maxPitchTan;
  37189. private _boneQuat;
  37190. private _slerping;
  37191. private _transformYawPitch;
  37192. private _transformYawPitchInv;
  37193. private _firstFrameSkipped;
  37194. private _yawRange;
  37195. private _fowardAxis;
  37196. /**
  37197. * Gets or sets the minimum yaw angle that the bone can look to
  37198. */
  37199. minYaw: number;
  37200. /**
  37201. * Gets or sets the maximum yaw angle that the bone can look to
  37202. */
  37203. maxYaw: number;
  37204. /**
  37205. * Gets or sets the minimum pitch angle that the bone can look to
  37206. */
  37207. minPitch: number;
  37208. /**
  37209. * Gets or sets the maximum pitch angle that the bone can look to
  37210. */
  37211. maxPitch: number;
  37212. /**
  37213. * Create a BoneLookController
  37214. * @param mesh the mesh that the bone belongs to
  37215. * @param bone the bone that will be looking to the target
  37216. * @param target the target Vector3 to look at
  37217. * @param options optional settings:
  37218. * * maxYaw: the maximum angle the bone will yaw to
  37219. * * minYaw: the minimum angle the bone will yaw to
  37220. * * maxPitch: the maximum angle the bone will pitch to
  37221. * * minPitch: the minimum angle the bone will yaw to
  37222. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37223. * * upAxis: the up axis of the coordinate system
  37224. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37225. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37226. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37227. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37228. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37229. * * adjustRoll: used to make an adjustment to the roll of the bone
  37230. **/
  37231. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37232. maxYaw?: number;
  37233. minYaw?: number;
  37234. maxPitch?: number;
  37235. minPitch?: number;
  37236. slerpAmount?: number;
  37237. upAxis?: Vector3;
  37238. upAxisSpace?: Space;
  37239. yawAxis?: Vector3;
  37240. pitchAxis?: Vector3;
  37241. adjustYaw?: number;
  37242. adjustPitch?: number;
  37243. adjustRoll?: number;
  37244. });
  37245. /**
  37246. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37247. */
  37248. update(): void;
  37249. private _getAngleDiff;
  37250. private _getAngleBetween;
  37251. private _isAngleBetween;
  37252. }
  37253. }
  37254. declare module "babylonjs/Bones/index" {
  37255. export * from "babylonjs/Bones/bone";
  37256. export * from "babylonjs/Bones/boneIKController";
  37257. export * from "babylonjs/Bones/boneLookController";
  37258. export * from "babylonjs/Bones/skeleton";
  37259. }
  37260. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37261. import { Nullable } from "babylonjs/types";
  37262. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37263. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37264. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37265. /**
  37266. * Manage the gamepad inputs to control an arc rotate camera.
  37267. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37268. */
  37269. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37270. /**
  37271. * Defines the camera the input is attached to.
  37272. */
  37273. camera: ArcRotateCamera;
  37274. /**
  37275. * Defines the gamepad the input is gathering event from.
  37276. */
  37277. gamepad: Nullable<Gamepad>;
  37278. /**
  37279. * Defines the gamepad rotation sensiblity.
  37280. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37281. */
  37282. gamepadRotationSensibility: number;
  37283. /**
  37284. * Defines the gamepad move sensiblity.
  37285. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37286. */
  37287. gamepadMoveSensibility: number;
  37288. private _onGamepadConnectedObserver;
  37289. private _onGamepadDisconnectedObserver;
  37290. /**
  37291. * Attach the input controls to a specific dom element to get the input from.
  37292. * @param element Defines the element the controls should be listened from
  37293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37294. */
  37295. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37296. /**
  37297. * Detach the current controls from the specified dom element.
  37298. * @param element Defines the element to stop listening the inputs from
  37299. */
  37300. detachControl(element: Nullable<HTMLElement>): void;
  37301. /**
  37302. * Update the current camera state depending on the inputs that have been used this frame.
  37303. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37304. */
  37305. checkInputs(): void;
  37306. /**
  37307. * Gets the class name of the current intput.
  37308. * @returns the class name
  37309. */
  37310. getClassName(): string;
  37311. /**
  37312. * Get the friendly name associated with the input class.
  37313. * @returns the input friendly name
  37314. */
  37315. getSimpleName(): string;
  37316. }
  37317. }
  37318. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37319. import { Nullable } from "babylonjs/types";
  37320. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37321. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37322. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37323. interface ArcRotateCameraInputsManager {
  37324. /**
  37325. * Add orientation input support to the input manager.
  37326. * @returns the current input manager
  37327. */
  37328. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37329. }
  37330. }
  37331. /**
  37332. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37333. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37334. */
  37335. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37336. /**
  37337. * Defines the camera the input is attached to.
  37338. */
  37339. camera: ArcRotateCamera;
  37340. /**
  37341. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37342. */
  37343. alphaCorrection: number;
  37344. /**
  37345. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37346. */
  37347. gammaCorrection: number;
  37348. private _alpha;
  37349. private _gamma;
  37350. private _dirty;
  37351. private _deviceOrientationHandler;
  37352. /**
  37353. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37354. */
  37355. constructor();
  37356. /**
  37357. * Attach the input controls to a specific dom element to get the input from.
  37358. * @param element Defines the element the controls should be listened from
  37359. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37360. */
  37361. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37362. /** @hidden */
  37363. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37364. /**
  37365. * Update the current camera state depending on the inputs that have been used this frame.
  37366. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37367. */
  37368. checkInputs(): void;
  37369. /**
  37370. * Detach the current controls from the specified dom element.
  37371. * @param element Defines the element to stop listening the inputs from
  37372. */
  37373. detachControl(element: Nullable<HTMLElement>): void;
  37374. /**
  37375. * Gets the class name of the current intput.
  37376. * @returns the class name
  37377. */
  37378. getClassName(): string;
  37379. /**
  37380. * Get the friendly name associated with the input class.
  37381. * @returns the input friendly name
  37382. */
  37383. getSimpleName(): string;
  37384. }
  37385. }
  37386. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37387. import { Nullable } from "babylonjs/types";
  37388. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37389. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37390. /**
  37391. * Listen to mouse events to control the camera.
  37392. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37393. */
  37394. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37395. /**
  37396. * Defines the camera the input is attached to.
  37397. */
  37398. camera: FlyCamera;
  37399. /**
  37400. * Defines if touch is enabled. (Default is true.)
  37401. */
  37402. touchEnabled: boolean;
  37403. /**
  37404. * Defines the buttons associated with the input to handle camera rotation.
  37405. */
  37406. buttons: number[];
  37407. /**
  37408. * Assign buttons for Yaw control.
  37409. */
  37410. buttonsYaw: number[];
  37411. /**
  37412. * Assign buttons for Pitch control.
  37413. */
  37414. buttonsPitch: number[];
  37415. /**
  37416. * Assign buttons for Roll control.
  37417. */
  37418. buttonsRoll: number[];
  37419. /**
  37420. * Detect if any button is being pressed while mouse is moved.
  37421. * -1 = Mouse locked.
  37422. * 0 = Left button.
  37423. * 1 = Middle Button.
  37424. * 2 = Right Button.
  37425. */
  37426. activeButton: number;
  37427. /**
  37428. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37429. * Higher values reduce its sensitivity.
  37430. */
  37431. angularSensibility: number;
  37432. private _mousemoveCallback;
  37433. private _observer;
  37434. private _rollObserver;
  37435. private previousPosition;
  37436. private noPreventDefault;
  37437. private element;
  37438. /**
  37439. * Listen to mouse events to control the camera.
  37440. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37441. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37442. */
  37443. constructor(touchEnabled?: boolean);
  37444. /**
  37445. * Attach the mouse control to the HTML DOM element.
  37446. * @param element Defines the element that listens to the input events.
  37447. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37448. */
  37449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37450. /**
  37451. * Detach the current controls from the specified dom element.
  37452. * @param element Defines the element to stop listening the inputs from
  37453. */
  37454. detachControl(element: Nullable<HTMLElement>): void;
  37455. /**
  37456. * Gets the class name of the current input.
  37457. * @returns the class name.
  37458. */
  37459. getClassName(): string;
  37460. /**
  37461. * Get the friendly name associated with the input class.
  37462. * @returns the input's friendly name.
  37463. */
  37464. getSimpleName(): string;
  37465. private _pointerInput;
  37466. private _onMouseMove;
  37467. /**
  37468. * Rotate camera by mouse offset.
  37469. */
  37470. private rotateCamera;
  37471. }
  37472. }
  37473. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37474. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37475. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37476. /**
  37477. * Default Inputs manager for the FlyCamera.
  37478. * It groups all the default supported inputs for ease of use.
  37479. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37480. */
  37481. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37482. /**
  37483. * Instantiates a new FlyCameraInputsManager.
  37484. * @param camera Defines the camera the inputs belong to.
  37485. */
  37486. constructor(camera: FlyCamera);
  37487. /**
  37488. * Add keyboard input support to the input manager.
  37489. * @returns the new FlyCameraKeyboardMoveInput().
  37490. */
  37491. addKeyboard(): FlyCameraInputsManager;
  37492. /**
  37493. * Add mouse input support to the input manager.
  37494. * @param touchEnabled Enable touch screen support.
  37495. * @returns the new FlyCameraMouseInput().
  37496. */
  37497. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37498. }
  37499. }
  37500. declare module "babylonjs/Cameras/flyCamera" {
  37501. import { Scene } from "babylonjs/scene";
  37502. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37504. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37505. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37506. /**
  37507. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37508. * such as in a 3D Space Shooter or a Flight Simulator.
  37509. */
  37510. export class FlyCamera extends TargetCamera {
  37511. /**
  37512. * Define the collision ellipsoid of the camera.
  37513. * This is helpful for simulating a camera body, like a player's body.
  37514. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37515. */
  37516. ellipsoid: Vector3;
  37517. /**
  37518. * Define an offset for the position of the ellipsoid around the camera.
  37519. * This can be helpful if the camera is attached away from the player's body center,
  37520. * such as at its head.
  37521. */
  37522. ellipsoidOffset: Vector3;
  37523. /**
  37524. * Enable or disable collisions of the camera with the rest of the scene objects.
  37525. */
  37526. checkCollisions: boolean;
  37527. /**
  37528. * Enable or disable gravity on the camera.
  37529. */
  37530. applyGravity: boolean;
  37531. /**
  37532. * Define the current direction the camera is moving to.
  37533. */
  37534. cameraDirection: Vector3;
  37535. /**
  37536. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37537. * This overrides and empties cameraRotation.
  37538. */
  37539. rotationQuaternion: Quaternion;
  37540. /**
  37541. * Track Roll to maintain the wanted Rolling when looking around.
  37542. */
  37543. _trackRoll: number;
  37544. /**
  37545. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37546. */
  37547. rollCorrect: number;
  37548. /**
  37549. * Mimic a banked turn, Rolling the camera when Yawing.
  37550. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37551. */
  37552. bankedTurn: boolean;
  37553. /**
  37554. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37555. */
  37556. bankedTurnLimit: number;
  37557. /**
  37558. * Value of 0 disables the banked Roll.
  37559. * Value of 1 is equal to the Yaw angle in radians.
  37560. */
  37561. bankedTurnMultiplier: number;
  37562. /**
  37563. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37564. */
  37565. inputs: FlyCameraInputsManager;
  37566. /**
  37567. * Gets the input sensibility for mouse input.
  37568. * Higher values reduce sensitivity.
  37569. */
  37570. /**
  37571. * Sets the input sensibility for a mouse input.
  37572. * Higher values reduce sensitivity.
  37573. */
  37574. angularSensibility: number;
  37575. /**
  37576. * Get the keys for camera movement forward.
  37577. */
  37578. /**
  37579. * Set the keys for camera movement forward.
  37580. */
  37581. keysForward: number[];
  37582. /**
  37583. * Get the keys for camera movement backward.
  37584. */
  37585. keysBackward: number[];
  37586. /**
  37587. * Get the keys for camera movement up.
  37588. */
  37589. /**
  37590. * Set the keys for camera movement up.
  37591. */
  37592. keysUp: number[];
  37593. /**
  37594. * Get the keys for camera movement down.
  37595. */
  37596. /**
  37597. * Set the keys for camera movement down.
  37598. */
  37599. keysDown: number[];
  37600. /**
  37601. * Get the keys for camera movement left.
  37602. */
  37603. /**
  37604. * Set the keys for camera movement left.
  37605. */
  37606. keysLeft: number[];
  37607. /**
  37608. * Set the keys for camera movement right.
  37609. */
  37610. /**
  37611. * Set the keys for camera movement right.
  37612. */
  37613. keysRight: number[];
  37614. /**
  37615. * Event raised when the camera collides with a mesh in the scene.
  37616. */
  37617. onCollide: (collidedMesh: AbstractMesh) => void;
  37618. private _collider;
  37619. private _needMoveForGravity;
  37620. private _oldPosition;
  37621. private _diffPosition;
  37622. private _newPosition;
  37623. /** @hidden */
  37624. _localDirection: Vector3;
  37625. /** @hidden */
  37626. _transformedDirection: Vector3;
  37627. /**
  37628. * Instantiates a FlyCamera.
  37629. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37630. * such as in a 3D Space Shooter or a Flight Simulator.
  37631. * @param name Define the name of the camera in the scene.
  37632. * @param position Define the starting position of the camera in the scene.
  37633. * @param scene Define the scene the camera belongs to.
  37634. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37635. */
  37636. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37637. /**
  37638. * Attach a control to the HTML DOM element.
  37639. * @param element Defines the element that listens to the input events.
  37640. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37641. */
  37642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37643. /**
  37644. * Detach a control from the HTML DOM element.
  37645. * The camera will stop reacting to that input.
  37646. * @param element Defines the element that listens to the input events.
  37647. */
  37648. detachControl(element: HTMLElement): void;
  37649. private _collisionMask;
  37650. /**
  37651. * Get the mask that the camera ignores in collision events.
  37652. */
  37653. /**
  37654. * Set the mask that the camera ignores in collision events.
  37655. */
  37656. collisionMask: number;
  37657. /** @hidden */
  37658. _collideWithWorld(displacement: Vector3): void;
  37659. /** @hidden */
  37660. private _onCollisionPositionChange;
  37661. /** @hidden */
  37662. _checkInputs(): void;
  37663. /** @hidden */
  37664. _decideIfNeedsToMove(): boolean;
  37665. /** @hidden */
  37666. _updatePosition(): void;
  37667. /**
  37668. * Restore the Roll to its target value at the rate specified.
  37669. * @param rate - Higher means slower restoring.
  37670. * @hidden
  37671. */
  37672. restoreRoll(rate: number): void;
  37673. /**
  37674. * Destroy the camera and release the current resources held by it.
  37675. */
  37676. dispose(): void;
  37677. /**
  37678. * Get the current object class name.
  37679. * @returns the class name.
  37680. */
  37681. getClassName(): string;
  37682. }
  37683. }
  37684. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37685. import { Nullable } from "babylonjs/types";
  37686. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37687. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37688. /**
  37689. * Listen to keyboard events to control the camera.
  37690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37691. */
  37692. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37693. /**
  37694. * Defines the camera the input is attached to.
  37695. */
  37696. camera: FlyCamera;
  37697. /**
  37698. * The list of keyboard keys used to control the forward move of the camera.
  37699. */
  37700. keysForward: number[];
  37701. /**
  37702. * The list of keyboard keys used to control the backward move of the camera.
  37703. */
  37704. keysBackward: number[];
  37705. /**
  37706. * The list of keyboard keys used to control the forward move of the camera.
  37707. */
  37708. keysUp: number[];
  37709. /**
  37710. * The list of keyboard keys used to control the backward move of the camera.
  37711. */
  37712. keysDown: number[];
  37713. /**
  37714. * The list of keyboard keys used to control the right strafe move of the camera.
  37715. */
  37716. keysRight: number[];
  37717. /**
  37718. * The list of keyboard keys used to control the left strafe move of the camera.
  37719. */
  37720. keysLeft: number[];
  37721. private _keys;
  37722. private _onCanvasBlurObserver;
  37723. private _onKeyboardObserver;
  37724. private _engine;
  37725. private _scene;
  37726. /**
  37727. * Attach the input controls to a specific dom element to get the input from.
  37728. * @param element Defines the element the controls should be listened from
  37729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37730. */
  37731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37732. /**
  37733. * Detach the current controls from the specified dom element.
  37734. * @param element Defines the element to stop listening the inputs from
  37735. */
  37736. detachControl(element: Nullable<HTMLElement>): void;
  37737. /**
  37738. * Gets the class name of the current intput.
  37739. * @returns the class name
  37740. */
  37741. getClassName(): string;
  37742. /** @hidden */
  37743. _onLostFocus(e: FocusEvent): void;
  37744. /**
  37745. * Get the friendly name associated with the input class.
  37746. * @returns the input friendly name
  37747. */
  37748. getSimpleName(): string;
  37749. /**
  37750. * Update the current camera state depending on the inputs that have been used this frame.
  37751. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37752. */
  37753. checkInputs(): void;
  37754. }
  37755. }
  37756. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37757. import { Nullable } from "babylonjs/types";
  37758. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37759. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37760. /**
  37761. * Manage the mouse wheel inputs to control a follow camera.
  37762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37763. */
  37764. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37765. /**
  37766. * Defines the camera the input is attached to.
  37767. */
  37768. camera: FollowCamera;
  37769. /**
  37770. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37771. */
  37772. axisControlRadius: boolean;
  37773. /**
  37774. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37775. */
  37776. axisControlHeight: boolean;
  37777. /**
  37778. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37779. */
  37780. axisControlRotation: boolean;
  37781. /**
  37782. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37783. * relation to mouseWheel events.
  37784. */
  37785. wheelPrecision: number;
  37786. /**
  37787. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37788. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37789. */
  37790. wheelDeltaPercentage: number;
  37791. private _wheel;
  37792. private _observer;
  37793. /**
  37794. * Attach the input controls to a specific dom element to get the input from.
  37795. * @param element Defines the element the controls should be listened from
  37796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37797. */
  37798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37799. /**
  37800. * Detach the current controls from the specified dom element.
  37801. * @param element Defines the element to stop listening the inputs from
  37802. */
  37803. detachControl(element: Nullable<HTMLElement>): void;
  37804. /**
  37805. * Gets the class name of the current intput.
  37806. * @returns the class name
  37807. */
  37808. getClassName(): string;
  37809. /**
  37810. * Get the friendly name associated with the input class.
  37811. * @returns the input friendly name
  37812. */
  37813. getSimpleName(): string;
  37814. }
  37815. }
  37816. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37817. import { Nullable } from "babylonjs/types";
  37818. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37819. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37820. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37821. /**
  37822. * Manage the pointers inputs to control an follow camera.
  37823. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37824. */
  37825. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37826. /**
  37827. * Defines the camera the input is attached to.
  37828. */
  37829. camera: FollowCamera;
  37830. /**
  37831. * Gets the class name of the current input.
  37832. * @returns the class name
  37833. */
  37834. getClassName(): string;
  37835. /**
  37836. * Defines the pointer angular sensibility along the X axis or how fast is
  37837. * the camera rotating.
  37838. * A negative number will reverse the axis direction.
  37839. */
  37840. angularSensibilityX: number;
  37841. /**
  37842. * Defines the pointer angular sensibility along the Y axis or how fast is
  37843. * the camera rotating.
  37844. * A negative number will reverse the axis direction.
  37845. */
  37846. angularSensibilityY: number;
  37847. /**
  37848. * Defines the pointer pinch precision or how fast is the camera zooming.
  37849. * A negative number will reverse the axis direction.
  37850. */
  37851. pinchPrecision: number;
  37852. /**
  37853. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37854. * from 0.
  37855. * It defines the percentage of current camera.radius to use as delta when
  37856. * pinch zoom is used.
  37857. */
  37858. pinchDeltaPercentage: number;
  37859. /**
  37860. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37861. */
  37862. axisXControlRadius: boolean;
  37863. /**
  37864. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37865. */
  37866. axisXControlHeight: boolean;
  37867. /**
  37868. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37869. */
  37870. axisXControlRotation: boolean;
  37871. /**
  37872. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37873. */
  37874. axisYControlRadius: boolean;
  37875. /**
  37876. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37877. */
  37878. axisYControlHeight: boolean;
  37879. /**
  37880. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37881. */
  37882. axisYControlRotation: boolean;
  37883. /**
  37884. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37885. */
  37886. axisPinchControlRadius: boolean;
  37887. /**
  37888. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37889. */
  37890. axisPinchControlHeight: boolean;
  37891. /**
  37892. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37893. */
  37894. axisPinchControlRotation: boolean;
  37895. /**
  37896. * Log error messages if basic misconfiguration has occurred.
  37897. */
  37898. warningEnable: boolean;
  37899. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37900. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37901. private _warningCounter;
  37902. private _warning;
  37903. }
  37904. }
  37905. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37906. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37907. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37908. /**
  37909. * Default Inputs manager for the FollowCamera.
  37910. * It groups all the default supported inputs for ease of use.
  37911. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37912. */
  37913. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37914. /**
  37915. * Instantiates a new FollowCameraInputsManager.
  37916. * @param camera Defines the camera the inputs belong to
  37917. */
  37918. constructor(camera: FollowCamera);
  37919. /**
  37920. * Add keyboard input support to the input manager.
  37921. * @returns the current input manager
  37922. */
  37923. addKeyboard(): FollowCameraInputsManager;
  37924. /**
  37925. * Add mouse wheel input support to the input manager.
  37926. * @returns the current input manager
  37927. */
  37928. addMouseWheel(): FollowCameraInputsManager;
  37929. /**
  37930. * Add pointers input support to the input manager.
  37931. * @returns the current input manager
  37932. */
  37933. addPointers(): FollowCameraInputsManager;
  37934. /**
  37935. * Add orientation input support to the input manager.
  37936. * @returns the current input manager
  37937. */
  37938. addVRDeviceOrientation(): FollowCameraInputsManager;
  37939. }
  37940. }
  37941. declare module "babylonjs/Cameras/followCamera" {
  37942. import { Nullable } from "babylonjs/types";
  37943. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37944. import { Scene } from "babylonjs/scene";
  37945. import { Vector3 } from "babylonjs/Maths/math";
  37946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37947. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37948. /**
  37949. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37950. * an arc rotate version arcFollowCamera are available.
  37951. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37952. */
  37953. export class FollowCamera extends TargetCamera {
  37954. /**
  37955. * Distance the follow camera should follow an object at
  37956. */
  37957. radius: number;
  37958. /**
  37959. * Minimum allowed distance of the camera to the axis of rotation
  37960. * (The camera can not get closer).
  37961. * This can help limiting how the Camera is able to move in the scene.
  37962. */
  37963. lowerRadiusLimit: Nullable<number>;
  37964. /**
  37965. * Maximum allowed distance of the camera to the axis of rotation
  37966. * (The camera can not get further).
  37967. * This can help limiting how the Camera is able to move in the scene.
  37968. */
  37969. upperRadiusLimit: Nullable<number>;
  37970. /**
  37971. * Define a rotation offset between the camera and the object it follows
  37972. */
  37973. rotationOffset: number;
  37974. /**
  37975. * Minimum allowed angle to camera position relative to target object.
  37976. * This can help limiting how the Camera is able to move in the scene.
  37977. */
  37978. lowerRotationOffsetLimit: Nullable<number>;
  37979. /**
  37980. * Maximum allowed angle to camera position relative to target object.
  37981. * This can help limiting how the Camera is able to move in the scene.
  37982. */
  37983. upperRotationOffsetLimit: Nullable<number>;
  37984. /**
  37985. * Define a height offset between the camera and the object it follows.
  37986. * It can help following an object from the top (like a car chaing a plane)
  37987. */
  37988. heightOffset: number;
  37989. /**
  37990. * Minimum allowed height of camera position relative to target object.
  37991. * This can help limiting how the Camera is able to move in the scene.
  37992. */
  37993. lowerHeightOffsetLimit: Nullable<number>;
  37994. /**
  37995. * Maximum allowed height of camera position relative to target object.
  37996. * This can help limiting how the Camera is able to move in the scene.
  37997. */
  37998. upperHeightOffsetLimit: Nullable<number>;
  37999. /**
  38000. * Define how fast the camera can accelerate to follow it s target.
  38001. */
  38002. cameraAcceleration: number;
  38003. /**
  38004. * Define the speed limit of the camera following an object.
  38005. */
  38006. maxCameraSpeed: number;
  38007. /**
  38008. * Define the target of the camera.
  38009. */
  38010. lockedTarget: Nullable<AbstractMesh>;
  38011. /**
  38012. * Defines the input associated with the camera.
  38013. */
  38014. inputs: FollowCameraInputsManager;
  38015. /**
  38016. * Instantiates the follow camera.
  38017. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38018. * @param name Define the name of the camera in the scene
  38019. * @param position Define the position of the camera
  38020. * @param scene Define the scene the camera belong to
  38021. * @param lockedTarget Define the target of the camera
  38022. */
  38023. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38024. private _follow;
  38025. /**
  38026. * Attached controls to the current camera.
  38027. * @param element Defines the element the controls should be listened from
  38028. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38029. */
  38030. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38031. /**
  38032. * Detach the current controls from the camera.
  38033. * The camera will stop reacting to inputs.
  38034. * @param element Defines the element to stop listening the inputs from
  38035. */
  38036. detachControl(element: HTMLElement): void;
  38037. /** @hidden */
  38038. _checkInputs(): void;
  38039. private _checkLimits;
  38040. /**
  38041. * Gets the camera class name.
  38042. * @returns the class name
  38043. */
  38044. getClassName(): string;
  38045. }
  38046. /**
  38047. * Arc Rotate version of the follow camera.
  38048. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38049. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38050. */
  38051. export class ArcFollowCamera extends TargetCamera {
  38052. /** The longitudinal angle of the camera */
  38053. alpha: number;
  38054. /** The latitudinal angle of the camera */
  38055. beta: number;
  38056. /** The radius of the camera from its target */
  38057. radius: number;
  38058. /** Define the camera target (the messh it should follow) */
  38059. target: Nullable<AbstractMesh>;
  38060. private _cartesianCoordinates;
  38061. /**
  38062. * Instantiates a new ArcFollowCamera
  38063. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38064. * @param name Define the name of the camera
  38065. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38066. * @param beta Define the rotation angle of the camera around the elevation axis
  38067. * @param radius Define the radius of the camera from its target point
  38068. * @param target Define the target of the camera
  38069. * @param scene Define the scene the camera belongs to
  38070. */
  38071. constructor(name: string,
  38072. /** The longitudinal angle of the camera */
  38073. alpha: number,
  38074. /** The latitudinal angle of the camera */
  38075. beta: number,
  38076. /** The radius of the camera from its target */
  38077. radius: number,
  38078. /** Define the camera target (the messh it should follow) */
  38079. target: Nullable<AbstractMesh>, scene: Scene);
  38080. private _follow;
  38081. /** @hidden */
  38082. _checkInputs(): void;
  38083. /**
  38084. * Returns the class name of the object.
  38085. * It is mostly used internally for serialization purposes.
  38086. */
  38087. getClassName(): string;
  38088. }
  38089. }
  38090. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38091. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38092. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38093. import { Nullable } from "babylonjs/types";
  38094. /**
  38095. * Manage the keyboard inputs to control the movement of a follow camera.
  38096. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38097. */
  38098. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38099. /**
  38100. * Defines the camera the input is attached to.
  38101. */
  38102. camera: FollowCamera;
  38103. /**
  38104. * Defines the list of key codes associated with the up action (increase heightOffset)
  38105. */
  38106. keysHeightOffsetIncr: number[];
  38107. /**
  38108. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38109. */
  38110. keysHeightOffsetDecr: number[];
  38111. /**
  38112. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38113. */
  38114. keysHeightOffsetModifierAlt: boolean;
  38115. /**
  38116. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38117. */
  38118. keysHeightOffsetModifierCtrl: boolean;
  38119. /**
  38120. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38121. */
  38122. keysHeightOffsetModifierShift: boolean;
  38123. /**
  38124. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38125. */
  38126. keysRotationOffsetIncr: number[];
  38127. /**
  38128. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38129. */
  38130. keysRotationOffsetDecr: number[];
  38131. /**
  38132. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38133. */
  38134. keysRotationOffsetModifierAlt: boolean;
  38135. /**
  38136. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38137. */
  38138. keysRotationOffsetModifierCtrl: boolean;
  38139. /**
  38140. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38141. */
  38142. keysRotationOffsetModifierShift: boolean;
  38143. /**
  38144. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38145. */
  38146. keysRadiusIncr: number[];
  38147. /**
  38148. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38149. */
  38150. keysRadiusDecr: number[];
  38151. /**
  38152. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38153. */
  38154. keysRadiusModifierAlt: boolean;
  38155. /**
  38156. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38157. */
  38158. keysRadiusModifierCtrl: boolean;
  38159. /**
  38160. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38161. */
  38162. keysRadiusModifierShift: boolean;
  38163. /**
  38164. * Defines the rate of change of heightOffset.
  38165. */
  38166. heightSensibility: number;
  38167. /**
  38168. * Defines the rate of change of rotationOffset.
  38169. */
  38170. rotationSensibility: number;
  38171. /**
  38172. * Defines the rate of change of radius.
  38173. */
  38174. radiusSensibility: number;
  38175. private _keys;
  38176. private _ctrlPressed;
  38177. private _altPressed;
  38178. private _shiftPressed;
  38179. private _onCanvasBlurObserver;
  38180. private _onKeyboardObserver;
  38181. private _engine;
  38182. private _scene;
  38183. /**
  38184. * Attach the input controls to a specific dom element to get the input from.
  38185. * @param element Defines the element the controls should be listened from
  38186. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38187. */
  38188. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38189. /**
  38190. * Detach the current controls from the specified dom element.
  38191. * @param element Defines the element to stop listening the inputs from
  38192. */
  38193. detachControl(element: Nullable<HTMLElement>): void;
  38194. /**
  38195. * Update the current camera state depending on the inputs that have been used this frame.
  38196. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38197. */
  38198. checkInputs(): void;
  38199. /**
  38200. * Gets the class name of the current input.
  38201. * @returns the class name
  38202. */
  38203. getClassName(): string;
  38204. /**
  38205. * Get the friendly name associated with the input class.
  38206. * @returns the input friendly name
  38207. */
  38208. getSimpleName(): string;
  38209. /**
  38210. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38211. * allow modification of the heightOffset value.
  38212. */
  38213. private _modifierHeightOffset;
  38214. /**
  38215. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38216. * allow modification of the rotationOffset value.
  38217. */
  38218. private _modifierRotationOffset;
  38219. /**
  38220. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38221. * allow modification of the radius value.
  38222. */
  38223. private _modifierRadius;
  38224. }
  38225. }
  38226. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38227. import { Nullable } from "babylonjs/types";
  38228. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38229. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38230. import { Observable } from "babylonjs/Misc/observable";
  38231. module "babylonjs/Cameras/freeCameraInputsManager" {
  38232. interface FreeCameraInputsManager {
  38233. /**
  38234. * @hidden
  38235. */
  38236. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38237. /**
  38238. * Add orientation input support to the input manager.
  38239. * @returns the current input manager
  38240. */
  38241. addDeviceOrientation(): FreeCameraInputsManager;
  38242. }
  38243. }
  38244. /**
  38245. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38246. * Screen rotation is taken into account.
  38247. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38248. */
  38249. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38250. private _camera;
  38251. private _screenOrientationAngle;
  38252. private _constantTranform;
  38253. private _screenQuaternion;
  38254. private _alpha;
  38255. private _beta;
  38256. private _gamma;
  38257. /**
  38258. * @hidden
  38259. */
  38260. _onDeviceOrientationChangedObservable: Observable<void>;
  38261. /**
  38262. * Instantiates a new input
  38263. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38264. */
  38265. constructor();
  38266. /**
  38267. * Define the camera controlled by the input.
  38268. */
  38269. camera: FreeCamera;
  38270. /**
  38271. * Attach the input controls to a specific dom element to get the input from.
  38272. * @param element Defines the element the controls should be listened from
  38273. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38274. */
  38275. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38276. private _orientationChanged;
  38277. private _deviceOrientation;
  38278. /**
  38279. * Detach the current controls from the specified dom element.
  38280. * @param element Defines the element to stop listening the inputs from
  38281. */
  38282. detachControl(element: Nullable<HTMLElement>): void;
  38283. /**
  38284. * Update the current camera state depending on the inputs that have been used this frame.
  38285. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38286. */
  38287. checkInputs(): void;
  38288. /**
  38289. * Gets the class name of the current intput.
  38290. * @returns the class name
  38291. */
  38292. getClassName(): string;
  38293. /**
  38294. * Get the friendly name associated with the input class.
  38295. * @returns the input friendly name
  38296. */
  38297. getSimpleName(): string;
  38298. }
  38299. }
  38300. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38301. import { Nullable } from "babylonjs/types";
  38302. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38303. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38304. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38305. /**
  38306. * Manage the gamepad inputs to control a free camera.
  38307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38308. */
  38309. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38310. /**
  38311. * Define the camera the input is attached to.
  38312. */
  38313. camera: FreeCamera;
  38314. /**
  38315. * Define the Gamepad controlling the input
  38316. */
  38317. gamepad: Nullable<Gamepad>;
  38318. /**
  38319. * Defines the gamepad rotation sensiblity.
  38320. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38321. */
  38322. gamepadAngularSensibility: number;
  38323. /**
  38324. * Defines the gamepad move sensiblity.
  38325. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38326. */
  38327. gamepadMoveSensibility: number;
  38328. private _onGamepadConnectedObserver;
  38329. private _onGamepadDisconnectedObserver;
  38330. private _cameraTransform;
  38331. private _deltaTransform;
  38332. private _vector3;
  38333. private _vector2;
  38334. /**
  38335. * Attach the input controls to a specific dom element to get the input from.
  38336. * @param element Defines the element the controls should be listened from
  38337. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38338. */
  38339. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38340. /**
  38341. * Detach the current controls from the specified dom element.
  38342. * @param element Defines the element to stop listening the inputs from
  38343. */
  38344. detachControl(element: Nullable<HTMLElement>): void;
  38345. /**
  38346. * Update the current camera state depending on the inputs that have been used this frame.
  38347. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38348. */
  38349. checkInputs(): void;
  38350. /**
  38351. * Gets the class name of the current intput.
  38352. * @returns the class name
  38353. */
  38354. getClassName(): string;
  38355. /**
  38356. * Get the friendly name associated with the input class.
  38357. * @returns the input friendly name
  38358. */
  38359. getSimpleName(): string;
  38360. }
  38361. }
  38362. declare module "babylonjs/Misc/virtualJoystick" {
  38363. import { Nullable } from "babylonjs/types";
  38364. import { Vector3 } from "babylonjs/Maths/math";
  38365. /**
  38366. * Defines the potential axis of a Joystick
  38367. */
  38368. export enum JoystickAxis {
  38369. /** X axis */
  38370. X = 0,
  38371. /** Y axis */
  38372. Y = 1,
  38373. /** Z axis */
  38374. Z = 2
  38375. }
  38376. /**
  38377. * Class used to define virtual joystick (used in touch mode)
  38378. */
  38379. export class VirtualJoystick {
  38380. /**
  38381. * Gets or sets a boolean indicating that left and right values must be inverted
  38382. */
  38383. reverseLeftRight: boolean;
  38384. /**
  38385. * Gets or sets a boolean indicating that up and down values must be inverted
  38386. */
  38387. reverseUpDown: boolean;
  38388. /**
  38389. * Gets the offset value for the position (ie. the change of the position value)
  38390. */
  38391. deltaPosition: Vector3;
  38392. /**
  38393. * Gets a boolean indicating if the virtual joystick was pressed
  38394. */
  38395. pressed: boolean;
  38396. /**
  38397. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38398. */
  38399. static Canvas: Nullable<HTMLCanvasElement>;
  38400. private static _globalJoystickIndex;
  38401. private static vjCanvasContext;
  38402. private static vjCanvasWidth;
  38403. private static vjCanvasHeight;
  38404. private static halfWidth;
  38405. private _action;
  38406. private _axisTargetedByLeftAndRight;
  38407. private _axisTargetedByUpAndDown;
  38408. private _joystickSensibility;
  38409. private _inversedSensibility;
  38410. private _joystickPointerID;
  38411. private _joystickColor;
  38412. private _joystickPointerPos;
  38413. private _joystickPreviousPointerPos;
  38414. private _joystickPointerStartPos;
  38415. private _deltaJoystickVector;
  38416. private _leftJoystick;
  38417. private _touches;
  38418. private _onPointerDownHandlerRef;
  38419. private _onPointerMoveHandlerRef;
  38420. private _onPointerUpHandlerRef;
  38421. private _onResize;
  38422. /**
  38423. * Creates a new virtual joystick
  38424. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38425. */
  38426. constructor(leftJoystick?: boolean);
  38427. /**
  38428. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38429. * @param newJoystickSensibility defines the new sensibility
  38430. */
  38431. setJoystickSensibility(newJoystickSensibility: number): void;
  38432. private _onPointerDown;
  38433. private _onPointerMove;
  38434. private _onPointerUp;
  38435. /**
  38436. * Change the color of the virtual joystick
  38437. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38438. */
  38439. setJoystickColor(newColor: string): void;
  38440. /**
  38441. * Defines a callback to call when the joystick is touched
  38442. * @param action defines the callback
  38443. */
  38444. setActionOnTouch(action: () => any): void;
  38445. /**
  38446. * Defines which axis you'd like to control for left & right
  38447. * @param axis defines the axis to use
  38448. */
  38449. setAxisForLeftRight(axis: JoystickAxis): void;
  38450. /**
  38451. * Defines which axis you'd like to control for up & down
  38452. * @param axis defines the axis to use
  38453. */
  38454. setAxisForUpDown(axis: JoystickAxis): void;
  38455. private _drawVirtualJoystick;
  38456. /**
  38457. * Release internal HTML canvas
  38458. */
  38459. releaseCanvas(): void;
  38460. }
  38461. }
  38462. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38463. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38464. import { Nullable } from "babylonjs/types";
  38465. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38466. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38467. module "babylonjs/Cameras/freeCameraInputsManager" {
  38468. interface FreeCameraInputsManager {
  38469. /**
  38470. * Add virtual joystick input support to the input manager.
  38471. * @returns the current input manager
  38472. */
  38473. addVirtualJoystick(): FreeCameraInputsManager;
  38474. }
  38475. }
  38476. /**
  38477. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38478. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38479. */
  38480. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38481. /**
  38482. * Defines the camera the input is attached to.
  38483. */
  38484. camera: FreeCamera;
  38485. private _leftjoystick;
  38486. private _rightjoystick;
  38487. /**
  38488. * Gets the left stick of the virtual joystick.
  38489. * @returns The virtual Joystick
  38490. */
  38491. getLeftJoystick(): VirtualJoystick;
  38492. /**
  38493. * Gets the right stick of the virtual joystick.
  38494. * @returns The virtual Joystick
  38495. */
  38496. getRightJoystick(): VirtualJoystick;
  38497. /**
  38498. * Update the current camera state depending on the inputs that have been used this frame.
  38499. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38500. */
  38501. checkInputs(): void;
  38502. /**
  38503. * Attach the input controls to a specific dom element to get the input from.
  38504. * @param element Defines the element the controls should be listened from
  38505. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38506. */
  38507. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38508. /**
  38509. * Detach the current controls from the specified dom element.
  38510. * @param element Defines the element to stop listening the inputs from
  38511. */
  38512. detachControl(element: Nullable<HTMLElement>): void;
  38513. /**
  38514. * Gets the class name of the current intput.
  38515. * @returns the class name
  38516. */
  38517. getClassName(): string;
  38518. /**
  38519. * Get the friendly name associated with the input class.
  38520. * @returns the input friendly name
  38521. */
  38522. getSimpleName(): string;
  38523. }
  38524. }
  38525. declare module "babylonjs/Cameras/Inputs/index" {
  38526. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38527. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38528. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38529. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38530. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38531. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38532. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38533. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38534. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38535. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38536. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38537. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38538. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38539. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38540. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38541. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38542. }
  38543. declare module "babylonjs/Cameras/touchCamera" {
  38544. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38545. import { Scene } from "babylonjs/scene";
  38546. import { Vector3 } from "babylonjs/Maths/math";
  38547. /**
  38548. * This represents a FPS type of camera controlled by touch.
  38549. * This is like a universal camera minus the Gamepad controls.
  38550. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38551. */
  38552. export class TouchCamera extends FreeCamera {
  38553. /**
  38554. * Defines the touch sensibility for rotation.
  38555. * The higher the faster.
  38556. */
  38557. touchAngularSensibility: number;
  38558. /**
  38559. * Defines the touch sensibility for move.
  38560. * The higher the faster.
  38561. */
  38562. touchMoveSensibility: number;
  38563. /**
  38564. * Instantiates a new touch camera.
  38565. * This represents a FPS type of camera controlled by touch.
  38566. * This is like a universal camera minus the Gamepad controls.
  38567. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38568. * @param name Define the name of the camera in the scene
  38569. * @param position Define the start position of the camera in the scene
  38570. * @param scene Define the scene the camera belongs to
  38571. */
  38572. constructor(name: string, position: Vector3, scene: Scene);
  38573. /**
  38574. * Gets the current object class name.
  38575. * @return the class name
  38576. */
  38577. getClassName(): string;
  38578. /** @hidden */
  38579. _setupInputs(): void;
  38580. }
  38581. }
  38582. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38583. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38584. import { Scene } from "babylonjs/scene";
  38585. import { Vector3, Axis } from "babylonjs/Maths/math";
  38586. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38587. /**
  38588. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38589. * being tilted forward or back and left or right.
  38590. */
  38591. export class DeviceOrientationCamera extends FreeCamera {
  38592. private _initialQuaternion;
  38593. private _quaternionCache;
  38594. private _tmpDragQuaternion;
  38595. /**
  38596. * Creates a new device orientation camera
  38597. * @param name The name of the camera
  38598. * @param position The start position camera
  38599. * @param scene The scene the camera belongs to
  38600. */
  38601. constructor(name: string, position: Vector3, scene: Scene);
  38602. /**
  38603. * @hidden
  38604. * Disabled pointer input on first orientation sensor update (Default: true)
  38605. */
  38606. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38607. private _dragFactor;
  38608. /**
  38609. * Enabled turning on the y axis when the orientation sensor is active
  38610. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38611. */
  38612. enableHorizontalDragging(dragFactor?: number): void;
  38613. /**
  38614. * Gets the current instance class name ("DeviceOrientationCamera").
  38615. * This helps avoiding instanceof at run time.
  38616. * @returns the class name
  38617. */
  38618. getClassName(): string;
  38619. /**
  38620. * @hidden
  38621. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38622. */
  38623. _checkInputs(): void;
  38624. /**
  38625. * Reset the camera to its default orientation on the specified axis only.
  38626. * @param axis The axis to reset
  38627. */
  38628. resetToCurrentRotation(axis?: Axis): void;
  38629. }
  38630. }
  38631. declare module "babylonjs/Gamepads/xboxGamepad" {
  38632. import { Observable } from "babylonjs/Misc/observable";
  38633. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38634. /**
  38635. * Defines supported buttons for XBox360 compatible gamepads
  38636. */
  38637. export enum Xbox360Button {
  38638. /** A */
  38639. A = 0,
  38640. /** B */
  38641. B = 1,
  38642. /** X */
  38643. X = 2,
  38644. /** Y */
  38645. Y = 3,
  38646. /** Start */
  38647. Start = 4,
  38648. /** Back */
  38649. Back = 5,
  38650. /** Left button */
  38651. LB = 6,
  38652. /** Right button */
  38653. RB = 7,
  38654. /** Left stick */
  38655. LeftStick = 8,
  38656. /** Right stick */
  38657. RightStick = 9
  38658. }
  38659. /** Defines values for XBox360 DPad */
  38660. export enum Xbox360Dpad {
  38661. /** Up */
  38662. Up = 0,
  38663. /** Down */
  38664. Down = 1,
  38665. /** Left */
  38666. Left = 2,
  38667. /** Right */
  38668. Right = 3
  38669. }
  38670. /**
  38671. * Defines a XBox360 gamepad
  38672. */
  38673. export class Xbox360Pad extends Gamepad {
  38674. private _leftTrigger;
  38675. private _rightTrigger;
  38676. private _onlefttriggerchanged;
  38677. private _onrighttriggerchanged;
  38678. private _onbuttondown;
  38679. private _onbuttonup;
  38680. private _ondpaddown;
  38681. private _ondpadup;
  38682. /** Observable raised when a button is pressed */
  38683. onButtonDownObservable: Observable<Xbox360Button>;
  38684. /** Observable raised when a button is released */
  38685. onButtonUpObservable: Observable<Xbox360Button>;
  38686. /** Observable raised when a pad is pressed */
  38687. onPadDownObservable: Observable<Xbox360Dpad>;
  38688. /** Observable raised when a pad is released */
  38689. onPadUpObservable: Observable<Xbox360Dpad>;
  38690. private _buttonA;
  38691. private _buttonB;
  38692. private _buttonX;
  38693. private _buttonY;
  38694. private _buttonBack;
  38695. private _buttonStart;
  38696. private _buttonLB;
  38697. private _buttonRB;
  38698. private _buttonLeftStick;
  38699. private _buttonRightStick;
  38700. private _dPadUp;
  38701. private _dPadDown;
  38702. private _dPadLeft;
  38703. private _dPadRight;
  38704. private _isXboxOnePad;
  38705. /**
  38706. * Creates a new XBox360 gamepad object
  38707. * @param id defines the id of this gamepad
  38708. * @param index defines its index
  38709. * @param gamepad defines the internal HTML gamepad object
  38710. * @param xboxOne defines if it is a XBox One gamepad
  38711. */
  38712. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38713. /**
  38714. * Defines the callback to call when left trigger is pressed
  38715. * @param callback defines the callback to use
  38716. */
  38717. onlefttriggerchanged(callback: (value: number) => void): void;
  38718. /**
  38719. * Defines the callback to call when right trigger is pressed
  38720. * @param callback defines the callback to use
  38721. */
  38722. onrighttriggerchanged(callback: (value: number) => void): void;
  38723. /**
  38724. * Gets the left trigger value
  38725. */
  38726. /**
  38727. * Sets the left trigger value
  38728. */
  38729. leftTrigger: number;
  38730. /**
  38731. * Gets the right trigger value
  38732. */
  38733. /**
  38734. * Sets the right trigger value
  38735. */
  38736. rightTrigger: number;
  38737. /**
  38738. * Defines the callback to call when a button is pressed
  38739. * @param callback defines the callback to use
  38740. */
  38741. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38742. /**
  38743. * Defines the callback to call when a button is released
  38744. * @param callback defines the callback to use
  38745. */
  38746. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38747. /**
  38748. * Defines the callback to call when a pad is pressed
  38749. * @param callback defines the callback to use
  38750. */
  38751. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38752. /**
  38753. * Defines the callback to call when a pad is released
  38754. * @param callback defines the callback to use
  38755. */
  38756. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38757. private _setButtonValue;
  38758. private _setDPadValue;
  38759. /**
  38760. * Gets the value of the `A` button
  38761. */
  38762. /**
  38763. * Sets the value of the `A` button
  38764. */
  38765. buttonA: number;
  38766. /**
  38767. * Gets the value of the `B` button
  38768. */
  38769. /**
  38770. * Sets the value of the `B` button
  38771. */
  38772. buttonB: number;
  38773. /**
  38774. * Gets the value of the `X` button
  38775. */
  38776. /**
  38777. * Sets the value of the `X` button
  38778. */
  38779. buttonX: number;
  38780. /**
  38781. * Gets the value of the `Y` button
  38782. */
  38783. /**
  38784. * Sets the value of the `Y` button
  38785. */
  38786. buttonY: number;
  38787. /**
  38788. * Gets the value of the `Start` button
  38789. */
  38790. /**
  38791. * Sets the value of the `Start` button
  38792. */
  38793. buttonStart: number;
  38794. /**
  38795. * Gets the value of the `Back` button
  38796. */
  38797. /**
  38798. * Sets the value of the `Back` button
  38799. */
  38800. buttonBack: number;
  38801. /**
  38802. * Gets the value of the `Left` button
  38803. */
  38804. /**
  38805. * Sets the value of the `Left` button
  38806. */
  38807. buttonLB: number;
  38808. /**
  38809. * Gets the value of the `Right` button
  38810. */
  38811. /**
  38812. * Sets the value of the `Right` button
  38813. */
  38814. buttonRB: number;
  38815. /**
  38816. * Gets the value of the Left joystick
  38817. */
  38818. /**
  38819. * Sets the value of the Left joystick
  38820. */
  38821. buttonLeftStick: number;
  38822. /**
  38823. * Gets the value of the Right joystick
  38824. */
  38825. /**
  38826. * Sets the value of the Right joystick
  38827. */
  38828. buttonRightStick: number;
  38829. /**
  38830. * Gets the value of D-pad up
  38831. */
  38832. /**
  38833. * Sets the value of D-pad up
  38834. */
  38835. dPadUp: number;
  38836. /**
  38837. * Gets the value of D-pad down
  38838. */
  38839. /**
  38840. * Sets the value of D-pad down
  38841. */
  38842. dPadDown: number;
  38843. /**
  38844. * Gets the value of D-pad left
  38845. */
  38846. /**
  38847. * Sets the value of D-pad left
  38848. */
  38849. dPadLeft: number;
  38850. /**
  38851. * Gets the value of D-pad right
  38852. */
  38853. /**
  38854. * Sets the value of D-pad right
  38855. */
  38856. dPadRight: number;
  38857. /**
  38858. * Force the gamepad to synchronize with device values
  38859. */
  38860. update(): void;
  38861. /**
  38862. * Disposes the gamepad
  38863. */
  38864. dispose(): void;
  38865. }
  38866. }
  38867. declare module "babylonjs/Gamepads/gamepadManager" {
  38868. import { Observable } from "babylonjs/Misc/observable";
  38869. import { Nullable } from "babylonjs/types";
  38870. import { Scene } from "babylonjs/scene";
  38871. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38872. /**
  38873. * Manager for handling gamepads
  38874. */
  38875. export class GamepadManager {
  38876. private _scene?;
  38877. private _babylonGamepads;
  38878. private _oneGamepadConnected;
  38879. /** @hidden */
  38880. _isMonitoring: boolean;
  38881. private _gamepadEventSupported;
  38882. private _gamepadSupport;
  38883. /**
  38884. * observable to be triggered when the gamepad controller has been connected
  38885. */
  38886. onGamepadConnectedObservable: Observable<Gamepad>;
  38887. /**
  38888. * observable to be triggered when the gamepad controller has been disconnected
  38889. */
  38890. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38891. private _onGamepadConnectedEvent;
  38892. private _onGamepadDisconnectedEvent;
  38893. /**
  38894. * Initializes the gamepad manager
  38895. * @param _scene BabylonJS scene
  38896. */
  38897. constructor(_scene?: Scene | undefined);
  38898. /**
  38899. * The gamepads in the game pad manager
  38900. */
  38901. readonly gamepads: Gamepad[];
  38902. /**
  38903. * Get the gamepad controllers based on type
  38904. * @param type The type of gamepad controller
  38905. * @returns Nullable gamepad
  38906. */
  38907. getGamepadByType(type?: number): Nullable<Gamepad>;
  38908. /**
  38909. * Disposes the gamepad manager
  38910. */
  38911. dispose(): void;
  38912. private _addNewGamepad;
  38913. private _startMonitoringGamepads;
  38914. private _stopMonitoringGamepads;
  38915. /** @hidden */
  38916. _checkGamepadsStatus(): void;
  38917. private _updateGamepadObjects;
  38918. }
  38919. }
  38920. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  38921. import { Nullable } from "babylonjs/types";
  38922. import { Scene } from "babylonjs/scene";
  38923. import { ISceneComponent } from "babylonjs/sceneComponent";
  38924. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  38925. module "babylonjs/scene" {
  38926. interface Scene {
  38927. /** @hidden */
  38928. _gamepadManager: Nullable<GamepadManager>;
  38929. /**
  38930. * Gets the gamepad manager associated with the scene
  38931. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38932. */
  38933. gamepadManager: GamepadManager;
  38934. }
  38935. }
  38936. module "babylonjs/Cameras/freeCameraInputsManager" {
  38937. /**
  38938. * Interface representing a free camera inputs manager
  38939. */
  38940. interface FreeCameraInputsManager {
  38941. /**
  38942. * Adds gamepad input support to the FreeCameraInputsManager.
  38943. * @returns the FreeCameraInputsManager
  38944. */
  38945. addGamepad(): FreeCameraInputsManager;
  38946. }
  38947. }
  38948. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38949. /**
  38950. * Interface representing an arc rotate camera inputs manager
  38951. */
  38952. interface ArcRotateCameraInputsManager {
  38953. /**
  38954. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38955. * @returns the camera inputs manager
  38956. */
  38957. addGamepad(): ArcRotateCameraInputsManager;
  38958. }
  38959. }
  38960. /**
  38961. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38962. */
  38963. export class GamepadSystemSceneComponent implements ISceneComponent {
  38964. /**
  38965. * The component name helpfull to identify the component in the list of scene components.
  38966. */
  38967. readonly name: string;
  38968. /**
  38969. * The scene the component belongs to.
  38970. */
  38971. scene: Scene;
  38972. /**
  38973. * Creates a new instance of the component for the given scene
  38974. * @param scene Defines the scene to register the component in
  38975. */
  38976. constructor(scene: Scene);
  38977. /**
  38978. * Registers the component in a given scene
  38979. */
  38980. register(): void;
  38981. /**
  38982. * Rebuilds the elements related to this component in case of
  38983. * context lost for instance.
  38984. */
  38985. rebuild(): void;
  38986. /**
  38987. * Disposes the component and the associated ressources
  38988. */
  38989. dispose(): void;
  38990. private _beforeCameraUpdate;
  38991. }
  38992. }
  38993. declare module "babylonjs/Cameras/universalCamera" {
  38994. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38995. import { Scene } from "babylonjs/scene";
  38996. import { Vector3 } from "babylonjs/Maths/math";
  38997. import "babylonjs/Gamepads/gamepadSceneComponent";
  38998. /**
  38999. * 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,
  39000. * which still works and will still be found in many Playgrounds.
  39001. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39002. */
  39003. export class UniversalCamera extends TouchCamera {
  39004. /**
  39005. * Defines the gamepad rotation sensiblity.
  39006. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39007. */
  39008. gamepadAngularSensibility: number;
  39009. /**
  39010. * Defines the gamepad move sensiblity.
  39011. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39012. */
  39013. gamepadMoveSensibility: number;
  39014. /**
  39015. * 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,
  39016. * which still works and will still be found in many Playgrounds.
  39017. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39018. * @param name Define the name of the camera in the scene
  39019. * @param position Define the start position of the camera in the scene
  39020. * @param scene Define the scene the camera belongs to
  39021. */
  39022. constructor(name: string, position: Vector3, scene: Scene);
  39023. /**
  39024. * Gets the current object class name.
  39025. * @return the class name
  39026. */
  39027. getClassName(): string;
  39028. }
  39029. }
  39030. declare module "babylonjs/Cameras/gamepadCamera" {
  39031. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39032. import { Scene } from "babylonjs/scene";
  39033. import { Vector3 } from "babylonjs/Maths/math";
  39034. /**
  39035. * This represents a FPS type of camera. This is only here for back compat purpose.
  39036. * Please use the UniversalCamera instead as both are identical.
  39037. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39038. */
  39039. export class GamepadCamera extends UniversalCamera {
  39040. /**
  39041. * Instantiates a new Gamepad Camera
  39042. * This represents a FPS type of camera. This is only here for back compat purpose.
  39043. * Please use the UniversalCamera instead as both are identical.
  39044. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39045. * @param name Define the name of the camera in the scene
  39046. * @param position Define the start position of the camera in the scene
  39047. * @param scene Define the scene the camera belongs to
  39048. */
  39049. constructor(name: string, position: Vector3, scene: Scene);
  39050. /**
  39051. * Gets the current object class name.
  39052. * @return the class name
  39053. */
  39054. getClassName(): string;
  39055. }
  39056. }
  39057. declare module "babylonjs/Shaders/pass.fragment" {
  39058. /** @hidden */
  39059. export var passPixelShader: {
  39060. name: string;
  39061. shader: string;
  39062. };
  39063. }
  39064. declare module "babylonjs/Shaders/passCube.fragment" {
  39065. /** @hidden */
  39066. export var passCubePixelShader: {
  39067. name: string;
  39068. shader: string;
  39069. };
  39070. }
  39071. declare module "babylonjs/PostProcesses/passPostProcess" {
  39072. import { Nullable } from "babylonjs/types";
  39073. import { Camera } from "babylonjs/Cameras/camera";
  39074. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39075. import { Engine } from "babylonjs/Engines/engine";
  39076. import "babylonjs/Shaders/pass.fragment";
  39077. import "babylonjs/Shaders/passCube.fragment";
  39078. /**
  39079. * PassPostProcess which produces an output the same as it's input
  39080. */
  39081. export class PassPostProcess extends PostProcess {
  39082. /**
  39083. * Creates the PassPostProcess
  39084. * @param name The name of the effect.
  39085. * @param options The required width/height ratio to downsize to before computing the render pass.
  39086. * @param camera The camera to apply the render pass to.
  39087. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39088. * @param engine The engine which the post process will be applied. (default: current engine)
  39089. * @param reusable If the post process can be reused on the same frame. (default: false)
  39090. * @param textureType The type of texture to be used when performing the post processing.
  39091. * @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)
  39092. */
  39093. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39094. }
  39095. /**
  39096. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39097. */
  39098. export class PassCubePostProcess extends PostProcess {
  39099. private _face;
  39100. /**
  39101. * Gets or sets the cube face to display.
  39102. * * 0 is +X
  39103. * * 1 is -X
  39104. * * 2 is +Y
  39105. * * 3 is -Y
  39106. * * 4 is +Z
  39107. * * 5 is -Z
  39108. */
  39109. face: number;
  39110. /**
  39111. * Creates the PassCubePostProcess
  39112. * @param name The name of the effect.
  39113. * @param options The required width/height ratio to downsize to before computing the render pass.
  39114. * @param camera The camera to apply the render pass to.
  39115. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39116. * @param engine The engine which the post process will be applied. (default: current engine)
  39117. * @param reusable If the post process can be reused on the same frame. (default: false)
  39118. * @param textureType The type of texture to be used when performing the post processing.
  39119. * @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)
  39120. */
  39121. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39122. }
  39123. }
  39124. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39125. /** @hidden */
  39126. export var anaglyphPixelShader: {
  39127. name: string;
  39128. shader: string;
  39129. };
  39130. }
  39131. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39132. import { Engine } from "babylonjs/Engines/engine";
  39133. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39134. import { Camera } from "babylonjs/Cameras/camera";
  39135. import "babylonjs/Shaders/anaglyph.fragment";
  39136. /**
  39137. * Postprocess used to generate anaglyphic rendering
  39138. */
  39139. export class AnaglyphPostProcess extends PostProcess {
  39140. private _passedProcess;
  39141. /**
  39142. * Creates a new AnaglyphPostProcess
  39143. * @param name defines postprocess name
  39144. * @param options defines creation options or target ratio scale
  39145. * @param rigCameras defines cameras using this postprocess
  39146. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39147. * @param engine defines hosting engine
  39148. * @param reusable defines if the postprocess will be reused multiple times per frame
  39149. */
  39150. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39151. }
  39152. }
  39153. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39154. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39155. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39156. import { Scene } from "babylonjs/scene";
  39157. import { Vector3 } from "babylonjs/Maths/math";
  39158. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39159. /**
  39160. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39161. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39162. */
  39163. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39164. /**
  39165. * Creates a new AnaglyphArcRotateCamera
  39166. * @param name defines camera name
  39167. * @param alpha defines alpha angle (in radians)
  39168. * @param beta defines beta angle (in radians)
  39169. * @param radius defines radius
  39170. * @param target defines camera target
  39171. * @param interaxialDistance defines distance between each color axis
  39172. * @param scene defines the hosting scene
  39173. */
  39174. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39175. /**
  39176. * Gets camera class name
  39177. * @returns AnaglyphArcRotateCamera
  39178. */
  39179. getClassName(): string;
  39180. }
  39181. }
  39182. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39183. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39184. import { Scene } from "babylonjs/scene";
  39185. import { Vector3 } from "babylonjs/Maths/math";
  39186. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39187. /**
  39188. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39189. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39190. */
  39191. export class AnaglyphFreeCamera extends FreeCamera {
  39192. /**
  39193. * Creates a new AnaglyphFreeCamera
  39194. * @param name defines camera name
  39195. * @param position defines initial position
  39196. * @param interaxialDistance defines distance between each color axis
  39197. * @param scene defines the hosting scene
  39198. */
  39199. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39200. /**
  39201. * Gets camera class name
  39202. * @returns AnaglyphFreeCamera
  39203. */
  39204. getClassName(): string;
  39205. }
  39206. }
  39207. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39208. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39209. import { Scene } from "babylonjs/scene";
  39210. import { Vector3 } from "babylonjs/Maths/math";
  39211. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39212. /**
  39213. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39214. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39215. */
  39216. export class AnaglyphGamepadCamera extends GamepadCamera {
  39217. /**
  39218. * Creates a new AnaglyphGamepadCamera
  39219. * @param name defines camera name
  39220. * @param position defines initial position
  39221. * @param interaxialDistance defines distance between each color axis
  39222. * @param scene defines the hosting scene
  39223. */
  39224. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39225. /**
  39226. * Gets camera class name
  39227. * @returns AnaglyphGamepadCamera
  39228. */
  39229. getClassName(): string;
  39230. }
  39231. }
  39232. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39233. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39234. import { Scene } from "babylonjs/scene";
  39235. import { Vector3 } from "babylonjs/Maths/math";
  39236. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39237. /**
  39238. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39239. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39240. */
  39241. export class AnaglyphUniversalCamera extends UniversalCamera {
  39242. /**
  39243. * Creates a new AnaglyphUniversalCamera
  39244. * @param name defines camera name
  39245. * @param position defines initial position
  39246. * @param interaxialDistance defines distance between each color axis
  39247. * @param scene defines the hosting scene
  39248. */
  39249. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39250. /**
  39251. * Gets camera class name
  39252. * @returns AnaglyphUniversalCamera
  39253. */
  39254. getClassName(): string;
  39255. }
  39256. }
  39257. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39258. /** @hidden */
  39259. export var stereoscopicInterlacePixelShader: {
  39260. name: string;
  39261. shader: string;
  39262. };
  39263. }
  39264. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39265. import { Camera } from "babylonjs/Cameras/camera";
  39266. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39267. import { Engine } from "babylonjs/Engines/engine";
  39268. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39269. /**
  39270. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39271. */
  39272. export class StereoscopicInterlacePostProcess extends PostProcess {
  39273. private _stepSize;
  39274. private _passedProcess;
  39275. /**
  39276. * Initializes a StereoscopicInterlacePostProcess
  39277. * @param name The name of the effect.
  39278. * @param rigCameras The rig cameras to be appled to the post process
  39279. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39280. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39281. * @param engine The engine which the post process will be applied. (default: current engine)
  39282. * @param reusable If the post process can be reused on the same frame. (default: false)
  39283. */
  39284. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39285. }
  39286. }
  39287. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39288. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39289. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39290. import { Scene } from "babylonjs/scene";
  39291. import { Vector3 } from "babylonjs/Maths/math";
  39292. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39293. /**
  39294. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39295. * @see http://doc.babylonjs.com/features/cameras
  39296. */
  39297. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39298. /**
  39299. * Creates a new StereoscopicArcRotateCamera
  39300. * @param name defines camera name
  39301. * @param alpha defines alpha angle (in radians)
  39302. * @param beta defines beta angle (in radians)
  39303. * @param radius defines radius
  39304. * @param target defines camera target
  39305. * @param interaxialDistance defines distance between each color axis
  39306. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39307. * @param scene defines the hosting scene
  39308. */
  39309. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39310. /**
  39311. * Gets camera class name
  39312. * @returns StereoscopicArcRotateCamera
  39313. */
  39314. getClassName(): string;
  39315. }
  39316. }
  39317. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39318. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39319. import { Scene } from "babylonjs/scene";
  39320. import { Vector3 } from "babylonjs/Maths/math";
  39321. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39322. /**
  39323. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39324. * @see http://doc.babylonjs.com/features/cameras
  39325. */
  39326. export class StereoscopicFreeCamera extends FreeCamera {
  39327. /**
  39328. * Creates a new StereoscopicFreeCamera
  39329. * @param name defines camera name
  39330. * @param position defines initial position
  39331. * @param interaxialDistance defines distance between each color axis
  39332. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39333. * @param scene defines the hosting scene
  39334. */
  39335. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39336. /**
  39337. * Gets camera class name
  39338. * @returns StereoscopicFreeCamera
  39339. */
  39340. getClassName(): string;
  39341. }
  39342. }
  39343. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39344. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39345. import { Scene } from "babylonjs/scene";
  39346. import { Vector3 } from "babylonjs/Maths/math";
  39347. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39348. /**
  39349. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39350. * @see http://doc.babylonjs.com/features/cameras
  39351. */
  39352. export class StereoscopicGamepadCamera extends GamepadCamera {
  39353. /**
  39354. * Creates a new StereoscopicGamepadCamera
  39355. * @param name defines camera name
  39356. * @param position defines initial position
  39357. * @param interaxialDistance defines distance between each color axis
  39358. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39359. * @param scene defines the hosting scene
  39360. */
  39361. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39362. /**
  39363. * Gets camera class name
  39364. * @returns StereoscopicGamepadCamera
  39365. */
  39366. getClassName(): string;
  39367. }
  39368. }
  39369. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39370. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39371. import { Scene } from "babylonjs/scene";
  39372. import { Vector3 } from "babylonjs/Maths/math";
  39373. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39374. /**
  39375. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39376. * @see http://doc.babylonjs.com/features/cameras
  39377. */
  39378. export class StereoscopicUniversalCamera extends UniversalCamera {
  39379. /**
  39380. * Creates a new StereoscopicUniversalCamera
  39381. * @param name defines camera name
  39382. * @param position defines initial position
  39383. * @param interaxialDistance defines distance between each color axis
  39384. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39385. * @param scene defines the hosting scene
  39386. */
  39387. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39388. /**
  39389. * Gets camera class name
  39390. * @returns StereoscopicUniversalCamera
  39391. */
  39392. getClassName(): string;
  39393. }
  39394. }
  39395. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39396. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39397. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39398. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39399. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39400. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39401. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39402. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39403. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39404. }
  39405. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39406. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39407. import { Scene } from "babylonjs/scene";
  39408. import { Vector3 } from "babylonjs/Maths/math";
  39409. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39410. /**
  39411. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39412. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39413. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39414. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39415. */
  39416. export class VirtualJoysticksCamera extends FreeCamera {
  39417. /**
  39418. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39419. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39420. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39421. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39422. * @param name Define the name of the camera in the scene
  39423. * @param position Define the start position of the camera in the scene
  39424. * @param scene Define the scene the camera belongs to
  39425. */
  39426. constructor(name: string, position: Vector3, scene: Scene);
  39427. /**
  39428. * Gets the current object class name.
  39429. * @return the class name
  39430. */
  39431. getClassName(): string;
  39432. }
  39433. }
  39434. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39435. import { Matrix } from "babylonjs/Maths/math";
  39436. /**
  39437. * This represents all the required metrics to create a VR camera.
  39438. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39439. */
  39440. export class VRCameraMetrics {
  39441. /**
  39442. * Define the horizontal resolution off the screen.
  39443. */
  39444. hResolution: number;
  39445. /**
  39446. * Define the vertical resolution off the screen.
  39447. */
  39448. vResolution: number;
  39449. /**
  39450. * Define the horizontal screen size.
  39451. */
  39452. hScreenSize: number;
  39453. /**
  39454. * Define the vertical screen size.
  39455. */
  39456. vScreenSize: number;
  39457. /**
  39458. * Define the vertical screen center position.
  39459. */
  39460. vScreenCenter: number;
  39461. /**
  39462. * Define the distance of the eyes to the screen.
  39463. */
  39464. eyeToScreenDistance: number;
  39465. /**
  39466. * Define the distance between both lenses
  39467. */
  39468. lensSeparationDistance: number;
  39469. /**
  39470. * Define the distance between both viewer's eyes.
  39471. */
  39472. interpupillaryDistance: number;
  39473. /**
  39474. * Define the distortion factor of the VR postprocess.
  39475. * Please, touch with care.
  39476. */
  39477. distortionK: number[];
  39478. /**
  39479. * Define the chromatic aberration correction factors for the VR post process.
  39480. */
  39481. chromaAbCorrection: number[];
  39482. /**
  39483. * Define the scale factor of the post process.
  39484. * The smaller the better but the slower.
  39485. */
  39486. postProcessScaleFactor: number;
  39487. /**
  39488. * Define an offset for the lens center.
  39489. */
  39490. lensCenterOffset: number;
  39491. /**
  39492. * Define if the current vr camera should compensate the distortion of the lense or not.
  39493. */
  39494. compensateDistortion: boolean;
  39495. /**
  39496. * Defines if multiview should be enabled when rendering (Default: false)
  39497. */
  39498. multiviewEnabled: boolean;
  39499. /**
  39500. * Gets the rendering aspect ratio based on the provided resolutions.
  39501. */
  39502. readonly aspectRatio: number;
  39503. /**
  39504. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39505. */
  39506. readonly aspectRatioFov: number;
  39507. /**
  39508. * @hidden
  39509. */
  39510. readonly leftHMatrix: Matrix;
  39511. /**
  39512. * @hidden
  39513. */
  39514. readonly rightHMatrix: Matrix;
  39515. /**
  39516. * @hidden
  39517. */
  39518. readonly leftPreViewMatrix: Matrix;
  39519. /**
  39520. * @hidden
  39521. */
  39522. readonly rightPreViewMatrix: Matrix;
  39523. /**
  39524. * Get the default VRMetrics based on the most generic setup.
  39525. * @returns the default vr metrics
  39526. */
  39527. static GetDefault(): VRCameraMetrics;
  39528. }
  39529. }
  39530. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39531. /** @hidden */
  39532. export var vrDistortionCorrectionPixelShader: {
  39533. name: string;
  39534. shader: string;
  39535. };
  39536. }
  39537. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39538. import { Camera } from "babylonjs/Cameras/camera";
  39539. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39540. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39541. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39542. /**
  39543. * VRDistortionCorrectionPostProcess used for mobile VR
  39544. */
  39545. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39546. private _isRightEye;
  39547. private _distortionFactors;
  39548. private _postProcessScaleFactor;
  39549. private _lensCenterOffset;
  39550. private _scaleIn;
  39551. private _scaleFactor;
  39552. private _lensCenter;
  39553. /**
  39554. * Initializes the VRDistortionCorrectionPostProcess
  39555. * @param name The name of the effect.
  39556. * @param camera The camera to apply the render pass to.
  39557. * @param isRightEye If this is for the right eye distortion
  39558. * @param vrMetrics All the required metrics for the VR camera
  39559. */
  39560. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39561. }
  39562. }
  39563. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39564. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39565. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39566. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39567. import { Scene } from "babylonjs/scene";
  39568. import { Vector3 } from "babylonjs/Maths/math";
  39569. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39570. import "babylonjs/Cameras/RigModes/vrRigMode";
  39571. /**
  39572. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39573. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39574. */
  39575. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39576. /**
  39577. * Creates a new VRDeviceOrientationArcRotateCamera
  39578. * @param name defines camera name
  39579. * @param alpha defines the camera rotation along the logitudinal axis
  39580. * @param beta defines the camera rotation along the latitudinal axis
  39581. * @param radius defines the camera distance from its target
  39582. * @param target defines the camera target
  39583. * @param scene defines the scene the camera belongs to
  39584. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39585. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39586. */
  39587. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39588. /**
  39589. * Gets camera class name
  39590. * @returns VRDeviceOrientationArcRotateCamera
  39591. */
  39592. getClassName(): string;
  39593. }
  39594. }
  39595. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39596. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39597. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39598. import { Scene } from "babylonjs/scene";
  39599. import { Vector3 } from "babylonjs/Maths/math";
  39600. import "babylonjs/Cameras/RigModes/vrRigMode";
  39601. /**
  39602. * Camera used to simulate VR rendering (based on FreeCamera)
  39603. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39604. */
  39605. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39606. /**
  39607. * Creates a new VRDeviceOrientationFreeCamera
  39608. * @param name defines camera name
  39609. * @param position defines the start position of the camera
  39610. * @param scene defines the scene the camera belongs to
  39611. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39612. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39613. */
  39614. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39615. /**
  39616. * Gets camera class name
  39617. * @returns VRDeviceOrientationFreeCamera
  39618. */
  39619. getClassName(): string;
  39620. }
  39621. }
  39622. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39623. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39624. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39625. import { Scene } from "babylonjs/scene";
  39626. import { Vector3 } from "babylonjs/Maths/math";
  39627. import "babylonjs/Gamepads/gamepadSceneComponent";
  39628. /**
  39629. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39630. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39631. */
  39632. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39633. /**
  39634. * Creates a new VRDeviceOrientationGamepadCamera
  39635. * @param name defines camera name
  39636. * @param position defines the start position of the camera
  39637. * @param scene defines the scene the camera belongs to
  39638. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39639. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39640. */
  39641. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39642. /**
  39643. * Gets camera class name
  39644. * @returns VRDeviceOrientationGamepadCamera
  39645. */
  39646. getClassName(): string;
  39647. }
  39648. }
  39649. declare module "babylonjs/Materials/pushMaterial" {
  39650. import { Nullable } from "babylonjs/types";
  39651. import { Scene } from "babylonjs/scene";
  39652. import { Matrix } from "babylonjs/Maths/math";
  39653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39654. import { Mesh } from "babylonjs/Meshes/mesh";
  39655. import { Material } from "babylonjs/Materials/material";
  39656. import { Effect } from "babylonjs/Materials/effect";
  39657. /**
  39658. * Base class of materials working in push mode in babylon JS
  39659. * @hidden
  39660. */
  39661. export class PushMaterial extends Material {
  39662. protected _activeEffect: Effect;
  39663. protected _normalMatrix: Matrix;
  39664. /**
  39665. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39666. * This means that the material can keep using a previous shader while a new one is being compiled.
  39667. * This is mostly used when shader parallel compilation is supported (true by default)
  39668. */
  39669. allowShaderHotSwapping: boolean;
  39670. constructor(name: string, scene: Scene);
  39671. getEffect(): Effect;
  39672. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39673. /**
  39674. * Binds the given world matrix to the active effect
  39675. *
  39676. * @param world the matrix to bind
  39677. */
  39678. bindOnlyWorldMatrix(world: Matrix): void;
  39679. /**
  39680. * Binds the given normal matrix to the active effect
  39681. *
  39682. * @param normalMatrix the matrix to bind
  39683. */
  39684. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39685. bind(world: Matrix, mesh?: Mesh): void;
  39686. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39687. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39688. }
  39689. }
  39690. declare module "babylonjs/Materials/materialFlags" {
  39691. /**
  39692. * This groups all the flags used to control the materials channel.
  39693. */
  39694. export class MaterialFlags {
  39695. private static _DiffuseTextureEnabled;
  39696. /**
  39697. * Are diffuse textures enabled in the application.
  39698. */
  39699. static DiffuseTextureEnabled: boolean;
  39700. private static _AmbientTextureEnabled;
  39701. /**
  39702. * Are ambient textures enabled in the application.
  39703. */
  39704. static AmbientTextureEnabled: boolean;
  39705. private static _OpacityTextureEnabled;
  39706. /**
  39707. * Are opacity textures enabled in the application.
  39708. */
  39709. static OpacityTextureEnabled: boolean;
  39710. private static _ReflectionTextureEnabled;
  39711. /**
  39712. * Are reflection textures enabled in the application.
  39713. */
  39714. static ReflectionTextureEnabled: boolean;
  39715. private static _EmissiveTextureEnabled;
  39716. /**
  39717. * Are emissive textures enabled in the application.
  39718. */
  39719. static EmissiveTextureEnabled: boolean;
  39720. private static _SpecularTextureEnabled;
  39721. /**
  39722. * Are specular textures enabled in the application.
  39723. */
  39724. static SpecularTextureEnabled: boolean;
  39725. private static _BumpTextureEnabled;
  39726. /**
  39727. * Are bump textures enabled in the application.
  39728. */
  39729. static BumpTextureEnabled: boolean;
  39730. private static _LightmapTextureEnabled;
  39731. /**
  39732. * Are lightmap textures enabled in the application.
  39733. */
  39734. static LightmapTextureEnabled: boolean;
  39735. private static _RefractionTextureEnabled;
  39736. /**
  39737. * Are refraction textures enabled in the application.
  39738. */
  39739. static RefractionTextureEnabled: boolean;
  39740. private static _ColorGradingTextureEnabled;
  39741. /**
  39742. * Are color grading textures enabled in the application.
  39743. */
  39744. static ColorGradingTextureEnabled: boolean;
  39745. private static _FresnelEnabled;
  39746. /**
  39747. * Are fresnels enabled in the application.
  39748. */
  39749. static FresnelEnabled: boolean;
  39750. private static _ClearCoatTextureEnabled;
  39751. /**
  39752. * Are clear coat textures enabled in the application.
  39753. */
  39754. static ClearCoatTextureEnabled: boolean;
  39755. private static _ClearCoatBumpTextureEnabled;
  39756. /**
  39757. * Are clear coat bump textures enabled in the application.
  39758. */
  39759. static ClearCoatBumpTextureEnabled: boolean;
  39760. private static _ClearCoatTintTextureEnabled;
  39761. /**
  39762. * Are clear coat tint textures enabled in the application.
  39763. */
  39764. static ClearCoatTintTextureEnabled: boolean;
  39765. private static _SheenTextureEnabled;
  39766. /**
  39767. * Are sheen textures enabled in the application.
  39768. */
  39769. static SheenTextureEnabled: boolean;
  39770. private static _AnisotropicTextureEnabled;
  39771. /**
  39772. * Are anisotropic textures enabled in the application.
  39773. */
  39774. static AnisotropicTextureEnabled: boolean;
  39775. private static _ThicknessTextureEnabled;
  39776. /**
  39777. * Are thickness textures enabled in the application.
  39778. */
  39779. static ThicknessTextureEnabled: boolean;
  39780. }
  39781. }
  39782. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39783. /** @hidden */
  39784. export var defaultFragmentDeclaration: {
  39785. name: string;
  39786. shader: string;
  39787. };
  39788. }
  39789. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39790. /** @hidden */
  39791. export var defaultUboDeclaration: {
  39792. name: string;
  39793. shader: string;
  39794. };
  39795. }
  39796. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39797. /** @hidden */
  39798. export var lightFragmentDeclaration: {
  39799. name: string;
  39800. shader: string;
  39801. };
  39802. }
  39803. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39804. /** @hidden */
  39805. export var lightUboDeclaration: {
  39806. name: string;
  39807. shader: string;
  39808. };
  39809. }
  39810. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39811. /** @hidden */
  39812. export var lightsFragmentFunctions: {
  39813. name: string;
  39814. shader: string;
  39815. };
  39816. }
  39817. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39818. /** @hidden */
  39819. export var shadowsFragmentFunctions: {
  39820. name: string;
  39821. shader: string;
  39822. };
  39823. }
  39824. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39825. /** @hidden */
  39826. export var fresnelFunction: {
  39827. name: string;
  39828. shader: string;
  39829. };
  39830. }
  39831. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39832. /** @hidden */
  39833. export var reflectionFunction: {
  39834. name: string;
  39835. shader: string;
  39836. };
  39837. }
  39838. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39839. /** @hidden */
  39840. export var bumpFragmentFunctions: {
  39841. name: string;
  39842. shader: string;
  39843. };
  39844. }
  39845. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39846. /** @hidden */
  39847. export var logDepthDeclaration: {
  39848. name: string;
  39849. shader: string;
  39850. };
  39851. }
  39852. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39853. /** @hidden */
  39854. export var bumpFragment: {
  39855. name: string;
  39856. shader: string;
  39857. };
  39858. }
  39859. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39860. /** @hidden */
  39861. export var depthPrePass: {
  39862. name: string;
  39863. shader: string;
  39864. };
  39865. }
  39866. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39867. /** @hidden */
  39868. export var lightFragment: {
  39869. name: string;
  39870. shader: string;
  39871. };
  39872. }
  39873. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39874. /** @hidden */
  39875. export var logDepthFragment: {
  39876. name: string;
  39877. shader: string;
  39878. };
  39879. }
  39880. declare module "babylonjs/Shaders/default.fragment" {
  39881. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39882. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39883. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39884. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39885. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39886. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39887. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39888. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39889. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39890. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39891. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39892. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39893. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39894. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39895. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39896. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39897. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39898. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39899. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39900. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39901. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39902. /** @hidden */
  39903. export var defaultPixelShader: {
  39904. name: string;
  39905. shader: string;
  39906. };
  39907. }
  39908. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39909. /** @hidden */
  39910. export var defaultVertexDeclaration: {
  39911. name: string;
  39912. shader: string;
  39913. };
  39914. }
  39915. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39916. /** @hidden */
  39917. export var bumpVertexDeclaration: {
  39918. name: string;
  39919. shader: string;
  39920. };
  39921. }
  39922. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39923. /** @hidden */
  39924. export var bumpVertex: {
  39925. name: string;
  39926. shader: string;
  39927. };
  39928. }
  39929. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39930. /** @hidden */
  39931. export var fogVertex: {
  39932. name: string;
  39933. shader: string;
  39934. };
  39935. }
  39936. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39937. /** @hidden */
  39938. export var shadowsVertex: {
  39939. name: string;
  39940. shader: string;
  39941. };
  39942. }
  39943. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39944. /** @hidden */
  39945. export var pointCloudVertex: {
  39946. name: string;
  39947. shader: string;
  39948. };
  39949. }
  39950. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39951. /** @hidden */
  39952. export var logDepthVertex: {
  39953. name: string;
  39954. shader: string;
  39955. };
  39956. }
  39957. declare module "babylonjs/Shaders/default.vertex" {
  39958. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39959. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39960. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39961. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39962. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39963. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39964. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39965. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39966. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39967. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39968. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39969. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39970. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39971. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39972. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39973. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39974. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39975. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39976. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39977. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39978. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39979. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39980. /** @hidden */
  39981. export var defaultVertexShader: {
  39982. name: string;
  39983. shader: string;
  39984. };
  39985. }
  39986. declare module "babylonjs/Materials/standardMaterial" {
  39987. import { SmartArray } from "babylonjs/Misc/smartArray";
  39988. import { IAnimatable } from "babylonjs/Misc/tools";
  39989. import { Nullable } from "babylonjs/types";
  39990. import { Scene } from "babylonjs/scene";
  39991. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39992. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39994. import { Mesh } from "babylonjs/Meshes/mesh";
  39995. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39996. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39997. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39998. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39999. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40000. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40001. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40002. import "babylonjs/Shaders/default.fragment";
  40003. import "babylonjs/Shaders/default.vertex";
  40004. /** @hidden */
  40005. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40006. MAINUV1: boolean;
  40007. MAINUV2: boolean;
  40008. DIFFUSE: boolean;
  40009. DIFFUSEDIRECTUV: number;
  40010. AMBIENT: boolean;
  40011. AMBIENTDIRECTUV: number;
  40012. OPACITY: boolean;
  40013. OPACITYDIRECTUV: number;
  40014. OPACITYRGB: boolean;
  40015. REFLECTION: boolean;
  40016. EMISSIVE: boolean;
  40017. EMISSIVEDIRECTUV: number;
  40018. SPECULAR: boolean;
  40019. SPECULARDIRECTUV: number;
  40020. BUMP: boolean;
  40021. BUMPDIRECTUV: number;
  40022. PARALLAX: boolean;
  40023. PARALLAXOCCLUSION: boolean;
  40024. SPECULAROVERALPHA: boolean;
  40025. CLIPPLANE: boolean;
  40026. CLIPPLANE2: boolean;
  40027. CLIPPLANE3: boolean;
  40028. CLIPPLANE4: boolean;
  40029. ALPHATEST: boolean;
  40030. DEPTHPREPASS: boolean;
  40031. ALPHAFROMDIFFUSE: boolean;
  40032. POINTSIZE: boolean;
  40033. FOG: boolean;
  40034. SPECULARTERM: boolean;
  40035. DIFFUSEFRESNEL: boolean;
  40036. OPACITYFRESNEL: boolean;
  40037. REFLECTIONFRESNEL: boolean;
  40038. REFRACTIONFRESNEL: boolean;
  40039. EMISSIVEFRESNEL: boolean;
  40040. FRESNEL: boolean;
  40041. NORMAL: boolean;
  40042. UV1: boolean;
  40043. UV2: boolean;
  40044. VERTEXCOLOR: boolean;
  40045. VERTEXALPHA: boolean;
  40046. NUM_BONE_INFLUENCERS: number;
  40047. BonesPerMesh: number;
  40048. BONETEXTURE: boolean;
  40049. INSTANCES: boolean;
  40050. GLOSSINESS: boolean;
  40051. ROUGHNESS: boolean;
  40052. EMISSIVEASILLUMINATION: boolean;
  40053. LINKEMISSIVEWITHDIFFUSE: boolean;
  40054. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40055. LIGHTMAP: boolean;
  40056. LIGHTMAPDIRECTUV: number;
  40057. OBJECTSPACE_NORMALMAP: boolean;
  40058. USELIGHTMAPASSHADOWMAP: boolean;
  40059. REFLECTIONMAP_3D: boolean;
  40060. REFLECTIONMAP_SPHERICAL: boolean;
  40061. REFLECTIONMAP_PLANAR: boolean;
  40062. REFLECTIONMAP_CUBIC: boolean;
  40063. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40064. REFLECTIONMAP_PROJECTION: boolean;
  40065. REFLECTIONMAP_SKYBOX: boolean;
  40066. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40067. REFLECTIONMAP_EXPLICIT: boolean;
  40068. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40069. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40070. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40071. INVERTCUBICMAP: boolean;
  40072. LOGARITHMICDEPTH: boolean;
  40073. REFRACTION: boolean;
  40074. REFRACTIONMAP_3D: boolean;
  40075. REFLECTIONOVERALPHA: boolean;
  40076. TWOSIDEDLIGHTING: boolean;
  40077. SHADOWFLOAT: boolean;
  40078. MORPHTARGETS: boolean;
  40079. MORPHTARGETS_NORMAL: boolean;
  40080. MORPHTARGETS_TANGENT: boolean;
  40081. NUM_MORPH_INFLUENCERS: number;
  40082. NONUNIFORMSCALING: boolean;
  40083. PREMULTIPLYALPHA: boolean;
  40084. IMAGEPROCESSING: boolean;
  40085. VIGNETTE: boolean;
  40086. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40087. VIGNETTEBLENDMODEOPAQUE: boolean;
  40088. TONEMAPPING: boolean;
  40089. TONEMAPPING_ACES: boolean;
  40090. CONTRAST: boolean;
  40091. COLORCURVES: boolean;
  40092. COLORGRADING: boolean;
  40093. COLORGRADING3D: boolean;
  40094. SAMPLER3DGREENDEPTH: boolean;
  40095. SAMPLER3DBGRMAP: boolean;
  40096. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40097. MULTIVIEW: boolean;
  40098. /**
  40099. * If the reflection texture on this material is in linear color space
  40100. * @hidden
  40101. */
  40102. IS_REFLECTION_LINEAR: boolean;
  40103. /**
  40104. * If the refraction texture on this material is in linear color space
  40105. * @hidden
  40106. */
  40107. IS_REFRACTION_LINEAR: boolean;
  40108. EXPOSURE: boolean;
  40109. constructor();
  40110. setReflectionMode(modeToEnable: string): void;
  40111. }
  40112. /**
  40113. * This is the default material used in Babylon. It is the best trade off between quality
  40114. * and performances.
  40115. * @see http://doc.babylonjs.com/babylon101/materials
  40116. */
  40117. export class StandardMaterial extends PushMaterial {
  40118. private _diffuseTexture;
  40119. /**
  40120. * The basic texture of the material as viewed under a light.
  40121. */
  40122. diffuseTexture: Nullable<BaseTexture>;
  40123. private _ambientTexture;
  40124. /**
  40125. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40126. */
  40127. ambientTexture: Nullable<BaseTexture>;
  40128. private _opacityTexture;
  40129. /**
  40130. * Define the transparency of the material from a texture.
  40131. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40132. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40133. */
  40134. opacityTexture: Nullable<BaseTexture>;
  40135. private _reflectionTexture;
  40136. /**
  40137. * Define the texture used to display the reflection.
  40138. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40139. */
  40140. reflectionTexture: Nullable<BaseTexture>;
  40141. private _emissiveTexture;
  40142. /**
  40143. * Define texture of the material as if self lit.
  40144. * This will be mixed in the final result even in the absence of light.
  40145. */
  40146. emissiveTexture: Nullable<BaseTexture>;
  40147. private _specularTexture;
  40148. /**
  40149. * Define how the color and intensity of the highlight given by the light in the material.
  40150. */
  40151. specularTexture: Nullable<BaseTexture>;
  40152. private _bumpTexture;
  40153. /**
  40154. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40155. * 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.
  40156. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40157. */
  40158. bumpTexture: Nullable<BaseTexture>;
  40159. private _lightmapTexture;
  40160. /**
  40161. * Complex lighting can be computationally expensive to compute at runtime.
  40162. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40163. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40164. */
  40165. lightmapTexture: Nullable<BaseTexture>;
  40166. private _refractionTexture;
  40167. /**
  40168. * Define the texture used to display the refraction.
  40169. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40170. */
  40171. refractionTexture: Nullable<BaseTexture>;
  40172. /**
  40173. * The color of the material lit by the environmental background lighting.
  40174. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40175. */
  40176. ambientColor: Color3;
  40177. /**
  40178. * The basic color of the material as viewed under a light.
  40179. */
  40180. diffuseColor: Color3;
  40181. /**
  40182. * Define how the color and intensity of the highlight given by the light in the material.
  40183. */
  40184. specularColor: Color3;
  40185. /**
  40186. * Define the color of the material as if self lit.
  40187. * This will be mixed in the final result even in the absence of light.
  40188. */
  40189. emissiveColor: Color3;
  40190. /**
  40191. * Defines how sharp are the highlights in the material.
  40192. * The bigger the value the sharper giving a more glossy feeling to the result.
  40193. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40194. */
  40195. specularPower: number;
  40196. private _useAlphaFromDiffuseTexture;
  40197. /**
  40198. * Does the transparency come from the diffuse texture alpha channel.
  40199. */
  40200. useAlphaFromDiffuseTexture: boolean;
  40201. private _useEmissiveAsIllumination;
  40202. /**
  40203. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40204. */
  40205. useEmissiveAsIllumination: boolean;
  40206. private _linkEmissiveWithDiffuse;
  40207. /**
  40208. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40209. * the emissive level when the final color is close to one.
  40210. */
  40211. linkEmissiveWithDiffuse: boolean;
  40212. private _useSpecularOverAlpha;
  40213. /**
  40214. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40215. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40216. */
  40217. useSpecularOverAlpha: boolean;
  40218. private _useReflectionOverAlpha;
  40219. /**
  40220. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40221. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40222. */
  40223. useReflectionOverAlpha: boolean;
  40224. private _disableLighting;
  40225. /**
  40226. * Does lights from the scene impacts this material.
  40227. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40228. */
  40229. disableLighting: boolean;
  40230. private _useObjectSpaceNormalMap;
  40231. /**
  40232. * Allows using an object space normal map (instead of tangent space).
  40233. */
  40234. useObjectSpaceNormalMap: boolean;
  40235. private _useParallax;
  40236. /**
  40237. * Is parallax enabled or not.
  40238. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40239. */
  40240. useParallax: boolean;
  40241. private _useParallaxOcclusion;
  40242. /**
  40243. * Is parallax occlusion enabled or not.
  40244. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40245. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40246. */
  40247. useParallaxOcclusion: boolean;
  40248. /**
  40249. * 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.
  40250. */
  40251. parallaxScaleBias: number;
  40252. private _roughness;
  40253. /**
  40254. * Helps to define how blurry the reflections should appears in the material.
  40255. */
  40256. roughness: number;
  40257. /**
  40258. * In case of refraction, define the value of the indice of refraction.
  40259. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40260. */
  40261. indexOfRefraction: number;
  40262. /**
  40263. * Invert the refraction texture alongside the y axis.
  40264. * It can be useful with procedural textures or probe for instance.
  40265. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40266. */
  40267. invertRefractionY: boolean;
  40268. /**
  40269. * Defines the alpha limits in alpha test mode.
  40270. */
  40271. alphaCutOff: number;
  40272. private _useLightmapAsShadowmap;
  40273. /**
  40274. * In case of light mapping, define whether the map contains light or shadow informations.
  40275. */
  40276. useLightmapAsShadowmap: boolean;
  40277. private _diffuseFresnelParameters;
  40278. /**
  40279. * Define the diffuse fresnel parameters of the material.
  40280. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40281. */
  40282. diffuseFresnelParameters: FresnelParameters;
  40283. private _opacityFresnelParameters;
  40284. /**
  40285. * Define the opacity fresnel parameters of the material.
  40286. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40287. */
  40288. opacityFresnelParameters: FresnelParameters;
  40289. private _reflectionFresnelParameters;
  40290. /**
  40291. * Define the reflection fresnel parameters of the material.
  40292. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40293. */
  40294. reflectionFresnelParameters: FresnelParameters;
  40295. private _refractionFresnelParameters;
  40296. /**
  40297. * Define the refraction fresnel parameters of the material.
  40298. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40299. */
  40300. refractionFresnelParameters: FresnelParameters;
  40301. private _emissiveFresnelParameters;
  40302. /**
  40303. * Define the emissive fresnel parameters of the material.
  40304. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40305. */
  40306. emissiveFresnelParameters: FresnelParameters;
  40307. private _useReflectionFresnelFromSpecular;
  40308. /**
  40309. * If true automatically deducts the fresnels values from the material specularity.
  40310. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40311. */
  40312. useReflectionFresnelFromSpecular: boolean;
  40313. private _useGlossinessFromSpecularMapAlpha;
  40314. /**
  40315. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40316. */
  40317. useGlossinessFromSpecularMapAlpha: boolean;
  40318. private _maxSimultaneousLights;
  40319. /**
  40320. * Defines the maximum number of lights that can be used in the material
  40321. */
  40322. maxSimultaneousLights: number;
  40323. private _invertNormalMapX;
  40324. /**
  40325. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40326. */
  40327. invertNormalMapX: boolean;
  40328. private _invertNormalMapY;
  40329. /**
  40330. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40331. */
  40332. invertNormalMapY: boolean;
  40333. private _twoSidedLighting;
  40334. /**
  40335. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40336. */
  40337. twoSidedLighting: boolean;
  40338. /**
  40339. * Default configuration related to image processing available in the standard Material.
  40340. */
  40341. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40342. /**
  40343. * Gets the image processing configuration used either in this material.
  40344. */
  40345. /**
  40346. * Sets the Default image processing configuration used either in the this material.
  40347. *
  40348. * If sets to null, the scene one is in use.
  40349. */
  40350. imageProcessingConfiguration: ImageProcessingConfiguration;
  40351. /**
  40352. * Keep track of the image processing observer to allow dispose and replace.
  40353. */
  40354. private _imageProcessingObserver;
  40355. /**
  40356. * Attaches a new image processing configuration to the Standard Material.
  40357. * @param configuration
  40358. */
  40359. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40360. /**
  40361. * Gets wether the color curves effect is enabled.
  40362. */
  40363. /**
  40364. * Sets wether the color curves effect is enabled.
  40365. */
  40366. cameraColorCurvesEnabled: boolean;
  40367. /**
  40368. * Gets wether the color grading effect is enabled.
  40369. */
  40370. /**
  40371. * Gets wether the color grading effect is enabled.
  40372. */
  40373. cameraColorGradingEnabled: boolean;
  40374. /**
  40375. * Gets wether tonemapping is enabled or not.
  40376. */
  40377. /**
  40378. * Sets wether tonemapping is enabled or not
  40379. */
  40380. cameraToneMappingEnabled: boolean;
  40381. /**
  40382. * The camera exposure used on this material.
  40383. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40384. * This corresponds to a photographic exposure.
  40385. */
  40386. /**
  40387. * The camera exposure used on this material.
  40388. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40389. * This corresponds to a photographic exposure.
  40390. */
  40391. cameraExposure: number;
  40392. /**
  40393. * Gets The camera contrast used on this material.
  40394. */
  40395. /**
  40396. * Sets The camera contrast used on this material.
  40397. */
  40398. cameraContrast: number;
  40399. /**
  40400. * Gets the Color Grading 2D Lookup Texture.
  40401. */
  40402. /**
  40403. * Sets the Color Grading 2D Lookup Texture.
  40404. */
  40405. cameraColorGradingTexture: Nullable<BaseTexture>;
  40406. /**
  40407. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40408. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40409. * 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;
  40410. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40411. */
  40412. /**
  40413. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40414. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40415. * 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;
  40416. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40417. */
  40418. cameraColorCurves: Nullable<ColorCurves>;
  40419. /**
  40420. * Custom callback helping to override the default shader used in the material.
  40421. */
  40422. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40423. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40424. protected _worldViewProjectionMatrix: Matrix;
  40425. protected _globalAmbientColor: Color3;
  40426. protected _useLogarithmicDepth: boolean;
  40427. /**
  40428. * Instantiates a new standard material.
  40429. * This is the default material used in Babylon. It is the best trade off between quality
  40430. * and performances.
  40431. * @see http://doc.babylonjs.com/babylon101/materials
  40432. * @param name Define the name of the material in the scene
  40433. * @param scene Define the scene the material belong to
  40434. */
  40435. constructor(name: string, scene: Scene);
  40436. /**
  40437. * Gets a boolean indicating that current material needs to register RTT
  40438. */
  40439. readonly hasRenderTargetTextures: boolean;
  40440. /**
  40441. * Gets the current class name of the material e.g. "StandardMaterial"
  40442. * Mainly use in serialization.
  40443. * @returns the class name
  40444. */
  40445. getClassName(): string;
  40446. /**
  40447. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40448. * You can try switching to logarithmic depth.
  40449. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40450. */
  40451. useLogarithmicDepth: boolean;
  40452. /**
  40453. * Specifies if the material will require alpha blending
  40454. * @returns a boolean specifying if alpha blending is needed
  40455. */
  40456. needAlphaBlending(): boolean;
  40457. /**
  40458. * Specifies if this material should be rendered in alpha test mode
  40459. * @returns a boolean specifying if an alpha test is needed.
  40460. */
  40461. needAlphaTesting(): boolean;
  40462. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40463. /**
  40464. * Get the texture used for alpha test purpose.
  40465. * @returns the diffuse texture in case of the standard material.
  40466. */
  40467. getAlphaTestTexture(): Nullable<BaseTexture>;
  40468. /**
  40469. * Get if the submesh is ready to be used and all its information available.
  40470. * Child classes can use it to update shaders
  40471. * @param mesh defines the mesh to check
  40472. * @param subMesh defines which submesh to check
  40473. * @param useInstances specifies that instances should be used
  40474. * @returns a boolean indicating that the submesh is ready or not
  40475. */
  40476. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40477. /**
  40478. * Builds the material UBO layouts.
  40479. * Used internally during the effect preparation.
  40480. */
  40481. buildUniformLayout(): void;
  40482. /**
  40483. * Unbinds the material from the mesh
  40484. */
  40485. unbind(): void;
  40486. /**
  40487. * Binds the submesh to this material by preparing the effect and shader to draw
  40488. * @param world defines the world transformation matrix
  40489. * @param mesh defines the mesh containing the submesh
  40490. * @param subMesh defines the submesh to bind the material to
  40491. */
  40492. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40493. /**
  40494. * Get the list of animatables in the material.
  40495. * @returns the list of animatables object used in the material
  40496. */
  40497. getAnimatables(): IAnimatable[];
  40498. /**
  40499. * Gets the active textures from the material
  40500. * @returns an array of textures
  40501. */
  40502. getActiveTextures(): BaseTexture[];
  40503. /**
  40504. * Specifies if the material uses a texture
  40505. * @param texture defines the texture to check against the material
  40506. * @returns a boolean specifying if the material uses the texture
  40507. */
  40508. hasTexture(texture: BaseTexture): boolean;
  40509. /**
  40510. * Disposes the material
  40511. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40512. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40513. */
  40514. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40515. /**
  40516. * Makes a duplicate of the material, and gives it a new name
  40517. * @param name defines the new name for the duplicated material
  40518. * @returns the cloned material
  40519. */
  40520. clone(name: string): StandardMaterial;
  40521. /**
  40522. * Serializes this material in a JSON representation
  40523. * @returns the serialized material object
  40524. */
  40525. serialize(): any;
  40526. /**
  40527. * Creates a standard material from parsed material data
  40528. * @param source defines the JSON representation of the material
  40529. * @param scene defines the hosting scene
  40530. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40531. * @returns a new standard material
  40532. */
  40533. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40534. /**
  40535. * Are diffuse textures enabled in the application.
  40536. */
  40537. static DiffuseTextureEnabled: boolean;
  40538. /**
  40539. * Are ambient textures enabled in the application.
  40540. */
  40541. static AmbientTextureEnabled: boolean;
  40542. /**
  40543. * Are opacity textures enabled in the application.
  40544. */
  40545. static OpacityTextureEnabled: boolean;
  40546. /**
  40547. * Are reflection textures enabled in the application.
  40548. */
  40549. static ReflectionTextureEnabled: boolean;
  40550. /**
  40551. * Are emissive textures enabled in the application.
  40552. */
  40553. static EmissiveTextureEnabled: boolean;
  40554. /**
  40555. * Are specular textures enabled in the application.
  40556. */
  40557. static SpecularTextureEnabled: boolean;
  40558. /**
  40559. * Are bump textures enabled in the application.
  40560. */
  40561. static BumpTextureEnabled: boolean;
  40562. /**
  40563. * Are lightmap textures enabled in the application.
  40564. */
  40565. static LightmapTextureEnabled: boolean;
  40566. /**
  40567. * Are refraction textures enabled in the application.
  40568. */
  40569. static RefractionTextureEnabled: boolean;
  40570. /**
  40571. * Are color grading textures enabled in the application.
  40572. */
  40573. static ColorGradingTextureEnabled: boolean;
  40574. /**
  40575. * Are fresnels enabled in the application.
  40576. */
  40577. static FresnelEnabled: boolean;
  40578. }
  40579. }
  40580. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40581. import { Scene } from "babylonjs/scene";
  40582. import { Texture } from "babylonjs/Materials/Textures/texture";
  40583. /**
  40584. * A class extending Texture allowing drawing on a texture
  40585. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40586. */
  40587. export class DynamicTexture extends Texture {
  40588. private _generateMipMaps;
  40589. private _canvas;
  40590. private _context;
  40591. private _engine;
  40592. /**
  40593. * Creates a DynamicTexture
  40594. * @param name defines the name of the texture
  40595. * @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
  40596. * @param scene defines the scene where you want the texture
  40597. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40598. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40599. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40600. */
  40601. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40602. /**
  40603. * Get the current class name of the texture useful for serialization or dynamic coding.
  40604. * @returns "DynamicTexture"
  40605. */
  40606. getClassName(): string;
  40607. /**
  40608. * Gets the current state of canRescale
  40609. */
  40610. readonly canRescale: boolean;
  40611. private _recreate;
  40612. /**
  40613. * Scales the texture
  40614. * @param ratio the scale factor to apply to both width and height
  40615. */
  40616. scale(ratio: number): void;
  40617. /**
  40618. * Resizes the texture
  40619. * @param width the new width
  40620. * @param height the new height
  40621. */
  40622. scaleTo(width: number, height: number): void;
  40623. /**
  40624. * Gets the context of the canvas used by the texture
  40625. * @returns the canvas context of the dynamic texture
  40626. */
  40627. getContext(): CanvasRenderingContext2D;
  40628. /**
  40629. * Clears the texture
  40630. */
  40631. clear(): void;
  40632. /**
  40633. * Updates the texture
  40634. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40635. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40636. */
  40637. update(invertY?: boolean, premulAlpha?: boolean): void;
  40638. /**
  40639. * Draws text onto the texture
  40640. * @param text defines the text to be drawn
  40641. * @param x defines the placement of the text from the left
  40642. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40643. * @param font defines the font to be used with font-style, font-size, font-name
  40644. * @param color defines the color used for the text
  40645. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40646. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40647. * @param update defines whether texture is immediately update (default is true)
  40648. */
  40649. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40650. /**
  40651. * Clones the texture
  40652. * @returns the clone of the texture.
  40653. */
  40654. clone(): DynamicTexture;
  40655. /**
  40656. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40657. * @returns a serialized dynamic texture object
  40658. */
  40659. serialize(): any;
  40660. /** @hidden */
  40661. _rebuild(): void;
  40662. }
  40663. }
  40664. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40665. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40666. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40667. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40668. /** @hidden */
  40669. export var imageProcessingPixelShader: {
  40670. name: string;
  40671. shader: string;
  40672. };
  40673. }
  40674. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40675. import { Nullable } from "babylonjs/types";
  40676. import { Color4 } from "babylonjs/Maths/math";
  40677. import { Camera } from "babylonjs/Cameras/camera";
  40678. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40679. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40680. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40681. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40682. import { Engine } from "babylonjs/Engines/engine";
  40683. import "babylonjs/Shaders/imageProcessing.fragment";
  40684. import "babylonjs/Shaders/postprocess.vertex";
  40685. /**
  40686. * ImageProcessingPostProcess
  40687. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40688. */
  40689. export class ImageProcessingPostProcess extends PostProcess {
  40690. /**
  40691. * Default configuration related to image processing available in the PBR Material.
  40692. */
  40693. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40694. /**
  40695. * Gets the image processing configuration used either in this material.
  40696. */
  40697. /**
  40698. * Sets the Default image processing configuration used either in the this material.
  40699. *
  40700. * If sets to null, the scene one is in use.
  40701. */
  40702. imageProcessingConfiguration: ImageProcessingConfiguration;
  40703. /**
  40704. * Keep track of the image processing observer to allow dispose and replace.
  40705. */
  40706. private _imageProcessingObserver;
  40707. /**
  40708. * Attaches a new image processing configuration to the PBR Material.
  40709. * @param configuration
  40710. */
  40711. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40712. /**
  40713. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40714. */
  40715. /**
  40716. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40717. */
  40718. colorCurves: Nullable<ColorCurves>;
  40719. /**
  40720. * Gets wether the color curves effect is enabled.
  40721. */
  40722. /**
  40723. * Sets wether the color curves effect is enabled.
  40724. */
  40725. colorCurvesEnabled: boolean;
  40726. /**
  40727. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40728. */
  40729. /**
  40730. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40731. */
  40732. colorGradingTexture: Nullable<BaseTexture>;
  40733. /**
  40734. * Gets wether the color grading effect is enabled.
  40735. */
  40736. /**
  40737. * Gets wether the color grading effect is enabled.
  40738. */
  40739. colorGradingEnabled: boolean;
  40740. /**
  40741. * Gets exposure used in the effect.
  40742. */
  40743. /**
  40744. * Sets exposure used in the effect.
  40745. */
  40746. exposure: number;
  40747. /**
  40748. * Gets wether tonemapping is enabled or not.
  40749. */
  40750. /**
  40751. * Sets wether tonemapping is enabled or not
  40752. */
  40753. toneMappingEnabled: boolean;
  40754. /**
  40755. * Gets the type of tone mapping effect.
  40756. */
  40757. /**
  40758. * Sets the type of tone mapping effect.
  40759. */
  40760. toneMappingType: number;
  40761. /**
  40762. * Gets contrast used in the effect.
  40763. */
  40764. /**
  40765. * Sets contrast used in the effect.
  40766. */
  40767. contrast: number;
  40768. /**
  40769. * Gets Vignette stretch size.
  40770. */
  40771. /**
  40772. * Sets Vignette stretch size.
  40773. */
  40774. vignetteStretch: number;
  40775. /**
  40776. * Gets Vignette centre X Offset.
  40777. */
  40778. /**
  40779. * Sets Vignette centre X Offset.
  40780. */
  40781. vignetteCentreX: number;
  40782. /**
  40783. * Gets Vignette centre Y Offset.
  40784. */
  40785. /**
  40786. * Sets Vignette centre Y Offset.
  40787. */
  40788. vignetteCentreY: number;
  40789. /**
  40790. * Gets Vignette weight or intensity of the vignette effect.
  40791. */
  40792. /**
  40793. * Sets Vignette weight or intensity of the vignette effect.
  40794. */
  40795. vignetteWeight: number;
  40796. /**
  40797. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40798. * if vignetteEnabled is set to true.
  40799. */
  40800. /**
  40801. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40802. * if vignetteEnabled is set to true.
  40803. */
  40804. vignetteColor: Color4;
  40805. /**
  40806. * Gets Camera field of view used by the Vignette effect.
  40807. */
  40808. /**
  40809. * Sets Camera field of view used by the Vignette effect.
  40810. */
  40811. vignetteCameraFov: number;
  40812. /**
  40813. * Gets the vignette blend mode allowing different kind of effect.
  40814. */
  40815. /**
  40816. * Sets the vignette blend mode allowing different kind of effect.
  40817. */
  40818. vignetteBlendMode: number;
  40819. /**
  40820. * Gets wether the vignette effect is enabled.
  40821. */
  40822. /**
  40823. * Sets wether the vignette effect is enabled.
  40824. */
  40825. vignetteEnabled: boolean;
  40826. private _fromLinearSpace;
  40827. /**
  40828. * Gets wether the input of the processing is in Gamma or Linear Space.
  40829. */
  40830. /**
  40831. * Sets wether the input of the processing is in Gamma or Linear Space.
  40832. */
  40833. fromLinearSpace: boolean;
  40834. /**
  40835. * Defines cache preventing GC.
  40836. */
  40837. private _defines;
  40838. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40839. /**
  40840. * "ImageProcessingPostProcess"
  40841. * @returns "ImageProcessingPostProcess"
  40842. */
  40843. getClassName(): string;
  40844. protected _updateParameters(): void;
  40845. dispose(camera?: Camera): void;
  40846. }
  40847. }
  40848. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40849. import { Scene } from "babylonjs/scene";
  40850. import { Color3 } from "babylonjs/Maths/math";
  40851. import { Mesh } from "babylonjs/Meshes/mesh";
  40852. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40853. import { Nullable } from "babylonjs/types";
  40854. /**
  40855. * Class containing static functions to help procedurally build meshes
  40856. */
  40857. export class GroundBuilder {
  40858. /**
  40859. * Creates a ground mesh
  40860. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40861. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40863. * @param name defines the name of the mesh
  40864. * @param options defines the options used to create the mesh
  40865. * @param scene defines the hosting scene
  40866. * @returns the ground mesh
  40867. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40868. */
  40869. static CreateGround(name: string, options: {
  40870. width?: number;
  40871. height?: number;
  40872. subdivisions?: number;
  40873. subdivisionsX?: number;
  40874. subdivisionsY?: number;
  40875. updatable?: boolean;
  40876. }, scene: any): Mesh;
  40877. /**
  40878. * Creates a tiled ground mesh
  40879. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40880. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40881. * * 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
  40882. * * 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
  40883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40884. * @param name defines the name of the mesh
  40885. * @param options defines the options used to create the mesh
  40886. * @param scene defines the hosting scene
  40887. * @returns the tiled ground mesh
  40888. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40889. */
  40890. static CreateTiledGround(name: string, options: {
  40891. xmin: number;
  40892. zmin: number;
  40893. xmax: number;
  40894. zmax: number;
  40895. subdivisions?: {
  40896. w: number;
  40897. h: number;
  40898. };
  40899. precision?: {
  40900. w: number;
  40901. h: number;
  40902. };
  40903. updatable?: boolean;
  40904. }, scene?: Nullable<Scene>): Mesh;
  40905. /**
  40906. * Creates a ground mesh from a height map
  40907. * * The parameter `url` sets the URL of the height map image resource.
  40908. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40909. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40910. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40911. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40912. * * 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.
  40913. * * 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).
  40914. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40916. * @param name defines the name of the mesh
  40917. * @param url defines the url to the height map
  40918. * @param options defines the options used to create the mesh
  40919. * @param scene defines the hosting scene
  40920. * @returns the ground mesh
  40921. * @see https://doc.babylonjs.com/babylon101/height_map
  40922. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40923. */
  40924. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40925. width?: number;
  40926. height?: number;
  40927. subdivisions?: number;
  40928. minHeight?: number;
  40929. maxHeight?: number;
  40930. colorFilter?: Color3;
  40931. alphaFilter?: number;
  40932. updatable?: boolean;
  40933. onReady?: (mesh: GroundMesh) => void;
  40934. }, scene?: Nullable<Scene>): GroundMesh;
  40935. }
  40936. }
  40937. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40938. import { Vector4 } from "babylonjs/Maths/math";
  40939. import { Mesh } from "babylonjs/Meshes/mesh";
  40940. /**
  40941. * Class containing static functions to help procedurally build meshes
  40942. */
  40943. export class TorusBuilder {
  40944. /**
  40945. * Creates a torus mesh
  40946. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40947. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40948. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40950. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40952. * @param name defines the name of the mesh
  40953. * @param options defines the options used to create the mesh
  40954. * @param scene defines the hosting scene
  40955. * @returns the torus mesh
  40956. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40957. */
  40958. static CreateTorus(name: string, options: {
  40959. diameter?: number;
  40960. thickness?: number;
  40961. tessellation?: number;
  40962. updatable?: boolean;
  40963. sideOrientation?: number;
  40964. frontUVs?: Vector4;
  40965. backUVs?: Vector4;
  40966. }, scene: any): Mesh;
  40967. }
  40968. }
  40969. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40970. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40971. import { Mesh } from "babylonjs/Meshes/mesh";
  40972. /**
  40973. * Class containing static functions to help procedurally build meshes
  40974. */
  40975. export class CylinderBuilder {
  40976. /**
  40977. * Creates a cylinder or a cone mesh
  40978. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40979. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40980. * * 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.
  40981. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40982. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40983. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40984. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40985. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40986. * * 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).
  40987. * * 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
  40988. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40989. * * 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
  40990. * * 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.
  40991. * * If `enclose` is false, a ring surface is one element.
  40992. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40993. * * 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
  40994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40995. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40997. * @param name defines the name of the mesh
  40998. * @param options defines the options used to create the mesh
  40999. * @param scene defines the hosting scene
  41000. * @returns the cylinder mesh
  41001. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41002. */
  41003. static CreateCylinder(name: string, options: {
  41004. height?: number;
  41005. diameterTop?: number;
  41006. diameterBottom?: number;
  41007. diameter?: number;
  41008. tessellation?: number;
  41009. subdivisions?: number;
  41010. arc?: number;
  41011. faceColors?: Color4[];
  41012. faceUV?: Vector4[];
  41013. updatable?: boolean;
  41014. hasRings?: boolean;
  41015. enclose?: boolean;
  41016. sideOrientation?: number;
  41017. frontUVs?: Vector4;
  41018. backUVs?: Vector4;
  41019. }, scene: any): Mesh;
  41020. }
  41021. }
  41022. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41023. import { Observable } from "babylonjs/Misc/observable";
  41024. import { Nullable } from "babylonjs/types";
  41025. import { Camera } from "babylonjs/Cameras/camera";
  41026. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41027. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41028. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41029. import { Scene } from "babylonjs/scene";
  41030. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41031. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41033. import { Mesh } from "babylonjs/Meshes/mesh";
  41034. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41035. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41036. import "babylonjs/Meshes/Builders/groundBuilder";
  41037. import "babylonjs/Meshes/Builders/torusBuilder";
  41038. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41039. import "babylonjs/Gamepads/gamepadSceneComponent";
  41040. import "babylonjs/Animations/animatable";
  41041. /**
  41042. * Options to modify the vr teleportation behavior.
  41043. */
  41044. export interface VRTeleportationOptions {
  41045. /**
  41046. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41047. */
  41048. floorMeshName?: string;
  41049. /**
  41050. * A list of meshes to be used as the teleportation floor. (default: empty)
  41051. */
  41052. floorMeshes?: Mesh[];
  41053. }
  41054. /**
  41055. * Options to modify the vr experience helper's behavior.
  41056. */
  41057. export interface VRExperienceHelperOptions extends WebVROptions {
  41058. /**
  41059. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41060. */
  41061. createDeviceOrientationCamera?: boolean;
  41062. /**
  41063. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41064. */
  41065. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41066. /**
  41067. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41068. */
  41069. laserToggle?: boolean;
  41070. /**
  41071. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41072. */
  41073. floorMeshes?: Mesh[];
  41074. /**
  41075. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41076. */
  41077. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41078. }
  41079. /**
  41080. * Event containing information after VR has been entered
  41081. */
  41082. export class OnAfterEnteringVRObservableEvent {
  41083. /**
  41084. * If entering vr was successful
  41085. */
  41086. success: boolean;
  41087. }
  41088. /**
  41089. * Helps to quickly add VR support to an existing scene.
  41090. * See http://doc.babylonjs.com/how_to/webvr_helper
  41091. */
  41092. export class VRExperienceHelper {
  41093. /** Options to modify the vr experience helper's behavior. */
  41094. webVROptions: VRExperienceHelperOptions;
  41095. private _scene;
  41096. private _position;
  41097. private _btnVR;
  41098. private _btnVRDisplayed;
  41099. private _webVRsupported;
  41100. private _webVRready;
  41101. private _webVRrequesting;
  41102. private _webVRpresenting;
  41103. private _hasEnteredVR;
  41104. private _fullscreenVRpresenting;
  41105. private _canvas;
  41106. private _webVRCamera;
  41107. private _vrDeviceOrientationCamera;
  41108. private _deviceOrientationCamera;
  41109. private _existingCamera;
  41110. private _onKeyDown;
  41111. private _onVrDisplayPresentChange;
  41112. private _onVRDisplayChanged;
  41113. private _onVRRequestPresentStart;
  41114. private _onVRRequestPresentComplete;
  41115. /**
  41116. * Observable raised right before entering VR.
  41117. */
  41118. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41119. /**
  41120. * Observable raised when entering VR has completed.
  41121. */
  41122. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41123. /**
  41124. * Observable raised when exiting VR.
  41125. */
  41126. onExitingVRObservable: Observable<VRExperienceHelper>;
  41127. /**
  41128. * Observable raised when controller mesh is loaded.
  41129. */
  41130. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41131. /** Return this.onEnteringVRObservable
  41132. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41133. */
  41134. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41135. /** Return this.onExitingVRObservable
  41136. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41137. */
  41138. readonly onExitingVR: Observable<VRExperienceHelper>;
  41139. /** Return this.onControllerMeshLoadedObservable
  41140. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41141. */
  41142. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41143. private _rayLength;
  41144. private _useCustomVRButton;
  41145. private _teleportationRequested;
  41146. private _teleportActive;
  41147. private _floorMeshName;
  41148. private _floorMeshesCollection;
  41149. private _rotationAllowed;
  41150. private _teleportBackwardsVector;
  41151. private _teleportationTarget;
  41152. private _isDefaultTeleportationTarget;
  41153. private _postProcessMove;
  41154. private _teleportationFillColor;
  41155. private _teleportationBorderColor;
  41156. private _rotationAngle;
  41157. private _haloCenter;
  41158. private _cameraGazer;
  41159. private _padSensibilityUp;
  41160. private _padSensibilityDown;
  41161. private _leftController;
  41162. private _rightController;
  41163. /**
  41164. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41165. */
  41166. onNewMeshSelected: Observable<AbstractMesh>;
  41167. /**
  41168. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41169. */
  41170. onNewMeshPicked: Observable<PickingInfo>;
  41171. private _circleEase;
  41172. /**
  41173. * Observable raised before camera teleportation
  41174. */
  41175. onBeforeCameraTeleport: Observable<Vector3>;
  41176. /**
  41177. * Observable raised after camera teleportation
  41178. */
  41179. onAfterCameraTeleport: Observable<Vector3>;
  41180. /**
  41181. * Observable raised when current selected mesh gets unselected
  41182. */
  41183. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41184. private _raySelectionPredicate;
  41185. /**
  41186. * To be optionaly changed by user to define custom ray selection
  41187. */
  41188. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41189. /**
  41190. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41191. */
  41192. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41193. /**
  41194. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41195. */
  41196. teleportationEnabled: boolean;
  41197. private _defaultHeight;
  41198. private _teleportationInitialized;
  41199. private _interactionsEnabled;
  41200. private _interactionsRequested;
  41201. private _displayGaze;
  41202. private _displayLaserPointer;
  41203. /**
  41204. * The mesh used to display where the user is going to teleport.
  41205. */
  41206. /**
  41207. * Sets the mesh to be used to display where the user is going to teleport.
  41208. */
  41209. teleportationTarget: Mesh;
  41210. /**
  41211. * 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
  41212. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41213. * See http://doc.babylonjs.com/resources/baking_transformations
  41214. */
  41215. gazeTrackerMesh: Mesh;
  41216. /**
  41217. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41218. */
  41219. updateGazeTrackerScale: boolean;
  41220. /**
  41221. * If the gaze trackers color should be updated when selecting meshes
  41222. */
  41223. updateGazeTrackerColor: boolean;
  41224. /**
  41225. * The gaze tracking mesh corresponding to the left controller
  41226. */
  41227. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41228. /**
  41229. * The gaze tracking mesh corresponding to the right controller
  41230. */
  41231. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41232. /**
  41233. * If the ray of the gaze should be displayed.
  41234. */
  41235. /**
  41236. * Sets if the ray of the gaze should be displayed.
  41237. */
  41238. displayGaze: boolean;
  41239. /**
  41240. * If the ray of the LaserPointer should be displayed.
  41241. */
  41242. /**
  41243. * Sets if the ray of the LaserPointer should be displayed.
  41244. */
  41245. displayLaserPointer: boolean;
  41246. /**
  41247. * The deviceOrientationCamera used as the camera when not in VR.
  41248. */
  41249. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41250. /**
  41251. * Based on the current WebVR support, returns the current VR camera used.
  41252. */
  41253. readonly currentVRCamera: Nullable<Camera>;
  41254. /**
  41255. * The webVRCamera which is used when in VR.
  41256. */
  41257. readonly webVRCamera: WebVRFreeCamera;
  41258. /**
  41259. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41260. */
  41261. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41262. private readonly _teleportationRequestInitiated;
  41263. /**
  41264. * Defines wether or not Pointer lock should be requested when switching to
  41265. * full screen.
  41266. */
  41267. requestPointerLockOnFullScreen: boolean;
  41268. /**
  41269. * Instantiates a VRExperienceHelper.
  41270. * Helps to quickly add VR support to an existing scene.
  41271. * @param scene The scene the VRExperienceHelper belongs to.
  41272. * @param webVROptions Options to modify the vr experience helper's behavior.
  41273. */
  41274. constructor(scene: Scene,
  41275. /** Options to modify the vr experience helper's behavior. */
  41276. webVROptions?: VRExperienceHelperOptions);
  41277. private _onDefaultMeshLoaded;
  41278. private _onResize;
  41279. private _onFullscreenChange;
  41280. /**
  41281. * Gets a value indicating if we are currently in VR mode.
  41282. */
  41283. readonly isInVRMode: boolean;
  41284. private onVrDisplayPresentChange;
  41285. private onVRDisplayChanged;
  41286. private moveButtonToBottomRight;
  41287. private displayVRButton;
  41288. private updateButtonVisibility;
  41289. private _cachedAngularSensibility;
  41290. /**
  41291. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41292. * Otherwise, will use the fullscreen API.
  41293. */
  41294. enterVR(): void;
  41295. /**
  41296. * Attempt to exit VR, or fullscreen.
  41297. */
  41298. exitVR(): void;
  41299. /**
  41300. * The position of the vr experience helper.
  41301. */
  41302. /**
  41303. * Sets the position of the vr experience helper.
  41304. */
  41305. position: Vector3;
  41306. /**
  41307. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41308. */
  41309. enableInteractions(): void;
  41310. private readonly _noControllerIsActive;
  41311. private beforeRender;
  41312. private _isTeleportationFloor;
  41313. /**
  41314. * Adds a floor mesh to be used for teleportation.
  41315. * @param floorMesh the mesh to be used for teleportation.
  41316. */
  41317. addFloorMesh(floorMesh: Mesh): void;
  41318. /**
  41319. * Removes a floor mesh from being used for teleportation.
  41320. * @param floorMesh the mesh to be removed.
  41321. */
  41322. removeFloorMesh(floorMesh: Mesh): void;
  41323. /**
  41324. * Enables interactions and teleportation using the VR controllers and gaze.
  41325. * @param vrTeleportationOptions options to modify teleportation behavior.
  41326. */
  41327. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41328. private _onNewGamepadConnected;
  41329. private _tryEnableInteractionOnController;
  41330. private _onNewGamepadDisconnected;
  41331. private _enableInteractionOnController;
  41332. private _checkTeleportWithRay;
  41333. private _checkRotate;
  41334. private _checkTeleportBackwards;
  41335. private _enableTeleportationOnController;
  41336. private _createTeleportationCircles;
  41337. private _displayTeleportationTarget;
  41338. private _hideTeleportationTarget;
  41339. private _rotateCamera;
  41340. private _moveTeleportationSelectorTo;
  41341. private _workingVector;
  41342. private _workingQuaternion;
  41343. private _workingMatrix;
  41344. /**
  41345. * Teleports the users feet to the desired location
  41346. * @param location The location where the user's feet should be placed
  41347. */
  41348. teleportCamera(location: Vector3): void;
  41349. private _convertNormalToDirectionOfRay;
  41350. private _castRayAndSelectObject;
  41351. private _notifySelectedMeshUnselected;
  41352. /**
  41353. * Sets the color of the laser ray from the vr controllers.
  41354. * @param color new color for the ray.
  41355. */
  41356. changeLaserColor(color: Color3): void;
  41357. /**
  41358. * Sets the color of the ray from the vr headsets gaze.
  41359. * @param color new color for the ray.
  41360. */
  41361. changeGazeColor(color: Color3): void;
  41362. /**
  41363. * Exits VR and disposes of the vr experience helper
  41364. */
  41365. dispose(): void;
  41366. /**
  41367. * Gets the name of the VRExperienceHelper class
  41368. * @returns "VRExperienceHelper"
  41369. */
  41370. getClassName(): string;
  41371. }
  41372. }
  41373. declare module "babylonjs/Cameras/VR/index" {
  41374. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41375. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41376. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41377. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41378. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41379. export * from "babylonjs/Cameras/VR/webVRCamera";
  41380. }
  41381. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41382. import { Observable } from "babylonjs/Misc/observable";
  41383. import { Nullable } from "babylonjs/types";
  41384. import { IDisposable, Scene } from "babylonjs/scene";
  41385. import { Vector3 } from "babylonjs/Maths/math";
  41386. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41387. import { Ray } from "babylonjs/Culling/ray";
  41388. /**
  41389. * Manages an XRSession
  41390. * @see https://doc.babylonjs.com/how_to/webxr
  41391. */
  41392. export class WebXRSessionManager implements IDisposable {
  41393. private scene;
  41394. /**
  41395. * Fires every time a new xrFrame arrives which can be used to update the camera
  41396. */
  41397. onXRFrameObservable: Observable<any>;
  41398. /**
  41399. * Fires when the xr session is ended either by the device or manually done
  41400. */
  41401. onXRSessionEnded: Observable<any>;
  41402. /** @hidden */
  41403. _xrSession: XRSession;
  41404. /** @hidden */
  41405. _frameOfReference: XRFrameOfReference;
  41406. /** @hidden */
  41407. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41408. /** @hidden */
  41409. _currentXRFrame: Nullable<XRFrame>;
  41410. private _xrNavigator;
  41411. private _xrDevice;
  41412. private _tmpMatrix;
  41413. /**
  41414. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41415. * @param scene The scene which the session should be created for
  41416. */
  41417. constructor(scene: Scene);
  41418. /**
  41419. * Initializes the manager
  41420. * After initialization enterXR can be called to start an XR session
  41421. * @returns Promise which resolves after it is initialized
  41422. */
  41423. initializeAsync(): Promise<void>;
  41424. /**
  41425. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41426. * @param sessionCreationOptions xr options to create the session with
  41427. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41428. * @returns Promise which resolves after it enters XR
  41429. */
  41430. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41431. /**
  41432. * Stops the xrSession and restores the renderloop
  41433. * @returns Promise which resolves after it exits XR
  41434. */
  41435. exitXRAsync(): Promise<void>;
  41436. /**
  41437. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41438. * @param ray ray to cast into the environment
  41439. * @returns Promise which resolves with a collision point in the environment if it exists
  41440. */
  41441. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41442. /**
  41443. * Checks if a session would be supported for the creation options specified
  41444. * @param options creation options to check if they are supported
  41445. * @returns true if supported
  41446. */
  41447. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41448. /**
  41449. * @hidden
  41450. * Converts the render layer of xrSession to a render target
  41451. * @param session session to create render target for
  41452. * @param scene scene the new render target should be created for
  41453. */
  41454. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41455. /**
  41456. * Disposes of the session manager
  41457. */
  41458. dispose(): void;
  41459. }
  41460. }
  41461. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41462. import { Scene } from "babylonjs/scene";
  41463. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41464. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41465. /**
  41466. * WebXR Camera which holds the views for the xrSession
  41467. * @see https://doc.babylonjs.com/how_to/webxr
  41468. */
  41469. export class WebXRCamera extends FreeCamera {
  41470. private static _TmpMatrix;
  41471. /**
  41472. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41473. * @param name the name of the camera
  41474. * @param scene the scene to add the camera to
  41475. */
  41476. constructor(name: string, scene: Scene);
  41477. private _updateNumberOfRigCameras;
  41478. /** @hidden */
  41479. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41480. /**
  41481. * Updates the cameras position from the current pose information of the XR session
  41482. * @param xrSessionManager the session containing pose information
  41483. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41484. */
  41485. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41486. }
  41487. }
  41488. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41489. import { Nullable } from "babylonjs/types";
  41490. import { Observable } from "babylonjs/Misc/observable";
  41491. import { IDisposable, Scene } from "babylonjs/scene";
  41492. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41494. import { Ray } from "babylonjs/Culling/ray";
  41495. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41496. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41497. /**
  41498. * States of the webXR experience
  41499. */
  41500. export enum WebXRState {
  41501. /**
  41502. * Transitioning to being in XR mode
  41503. */
  41504. ENTERING_XR = 0,
  41505. /**
  41506. * Transitioning to non XR mode
  41507. */
  41508. EXITING_XR = 1,
  41509. /**
  41510. * In XR mode and presenting
  41511. */
  41512. IN_XR = 2,
  41513. /**
  41514. * Not entered XR mode
  41515. */
  41516. NOT_IN_XR = 3
  41517. }
  41518. /**
  41519. * Helper class used to enable XR
  41520. * @see https://doc.babylonjs.com/how_to/webxr
  41521. */
  41522. export class WebXRExperienceHelper implements IDisposable {
  41523. private scene;
  41524. /**
  41525. * 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
  41526. */
  41527. container: AbstractMesh;
  41528. /**
  41529. * Camera used to render xr content
  41530. */
  41531. camera: WebXRCamera;
  41532. /**
  41533. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41534. */
  41535. state: WebXRState;
  41536. private _setState;
  41537. private static _TmpVector;
  41538. /**
  41539. * Fires when the state of the experience helper has changed
  41540. */
  41541. onStateChangedObservable: Observable<WebXRState>;
  41542. /** @hidden */
  41543. _sessionManager: WebXRSessionManager;
  41544. private _nonVRCamera;
  41545. private _originalSceneAutoClear;
  41546. private _supported;
  41547. /**
  41548. * Creates the experience helper
  41549. * @param scene the scene to attach the experience helper to
  41550. * @returns a promise for the experience helper
  41551. */
  41552. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41553. /**
  41554. * Creates a WebXRExperienceHelper
  41555. * @param scene The scene the helper should be created in
  41556. */
  41557. private constructor();
  41558. /**
  41559. * Exits XR mode and returns the scene to its original state
  41560. * @returns promise that resolves after xr mode has exited
  41561. */
  41562. exitXRAsync(): Promise<void>;
  41563. /**
  41564. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41565. * @param sessionCreationOptions options for the XR session
  41566. * @param frameOfReference frame of reference of the XR session
  41567. * @returns promise that resolves after xr mode has entered
  41568. */
  41569. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41570. /**
  41571. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41572. * @param ray ray to cast into the environment
  41573. * @returns Promise which resolves with a collision point in the environment if it exists
  41574. */
  41575. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41576. /**
  41577. * Updates the global position of the camera by moving the camera's container
  41578. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41579. * @param position The desired global position of the camera
  41580. */
  41581. setPositionOfCameraUsingContainer(position: Vector3): void;
  41582. /**
  41583. * Rotates the xr camera by rotating the camera's container around the camera's position
  41584. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41585. * @param rotation the desired quaternion rotation to apply to the camera
  41586. */
  41587. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41588. /**
  41589. * Checks if the creation options are supported by the xr session
  41590. * @param options creation options
  41591. * @returns true if supported
  41592. */
  41593. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41594. /**
  41595. * Disposes of the experience helper
  41596. */
  41597. dispose(): void;
  41598. }
  41599. }
  41600. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41601. import { Nullable } from "babylonjs/types";
  41602. import { Observable } from "babylonjs/Misc/observable";
  41603. import { IDisposable, Scene } from "babylonjs/scene";
  41604. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41605. /**
  41606. * Button which can be used to enter a different mode of XR
  41607. */
  41608. export class WebXREnterExitUIButton {
  41609. /** button element */
  41610. element: HTMLElement;
  41611. /** XR initialization options for the button */
  41612. initializationOptions: XRSessionCreationOptions;
  41613. /**
  41614. * Creates a WebXREnterExitUIButton
  41615. * @param element button element
  41616. * @param initializationOptions XR initialization options for the button
  41617. */
  41618. constructor(
  41619. /** button element */
  41620. element: HTMLElement,
  41621. /** XR initialization options for the button */
  41622. initializationOptions: XRSessionCreationOptions);
  41623. /**
  41624. * Overwritable function which can be used to update the button's visuals when the state changes
  41625. * @param activeButton the current active button in the UI
  41626. */
  41627. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41628. }
  41629. /**
  41630. * Options to create the webXR UI
  41631. */
  41632. export class WebXREnterExitUIOptions {
  41633. /**
  41634. * Context to enter xr with
  41635. */
  41636. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41637. /**
  41638. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41639. */
  41640. customButtons?: Array<WebXREnterExitUIButton>;
  41641. }
  41642. /**
  41643. * UI to allow the user to enter/exit XR mode
  41644. */
  41645. export class WebXREnterExitUI implements IDisposable {
  41646. private scene;
  41647. private _overlay;
  41648. private _buttons;
  41649. private _activeButton;
  41650. /**
  41651. * Fired every time the active button is changed.
  41652. *
  41653. * When xr is entered via a button that launches xr that button will be the callback parameter
  41654. *
  41655. * When exiting xr the callback parameter will be null)
  41656. */
  41657. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41658. /**
  41659. * Creates UI to allow the user to enter/exit XR mode
  41660. * @param scene the scene to add the ui to
  41661. * @param helper the xr experience helper to enter/exit xr with
  41662. * @param options options to configure the UI
  41663. * @returns the created ui
  41664. */
  41665. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41666. private constructor();
  41667. private _updateButtons;
  41668. /**
  41669. * Disposes of the object
  41670. */
  41671. dispose(): void;
  41672. }
  41673. }
  41674. declare module "babylonjs/Cameras/XR/webXRInput" {
  41675. import { IDisposable, Scene } from "babylonjs/scene";
  41676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41677. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41678. /**
  41679. * Represents an XR input
  41680. */
  41681. export class WebXRController {
  41682. /**
  41683. * 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
  41684. */
  41685. grip?: AbstractMesh;
  41686. /**
  41687. * Pointer which can be used to select objects or attach a visible laser to
  41688. */
  41689. pointer: AbstractMesh;
  41690. /**
  41691. * Creates the controller
  41692. * @see https://doc.babylonjs.com/how_to/webxr
  41693. * @param scene the scene which the controller should be associated to
  41694. */
  41695. constructor(scene: Scene);
  41696. /**
  41697. * Disposes of the object
  41698. */
  41699. dispose(): void;
  41700. }
  41701. /**
  41702. * XR input used to track XR inputs such as controllers/rays
  41703. */
  41704. export class WebXRInput implements IDisposable {
  41705. private helper;
  41706. /**
  41707. * XR controllers being tracked
  41708. */
  41709. controllers: Array<WebXRController>;
  41710. private _tmpMatrix;
  41711. private _frameObserver;
  41712. /**
  41713. * Initializes the WebXRInput
  41714. * @param helper experience helper which the input should be created for
  41715. */
  41716. constructor(helper: WebXRExperienceHelper);
  41717. /**
  41718. * Disposes of the object
  41719. */
  41720. dispose(): void;
  41721. }
  41722. }
  41723. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41724. import { Nullable } from "babylonjs/types";
  41725. import { IDisposable } from "babylonjs/scene";
  41726. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41727. /**
  41728. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41729. */
  41730. export class WebXRManagedOutputCanvas implements IDisposable {
  41731. private _canvas;
  41732. /**
  41733. * xrpresent context of the canvas which can be used to display/mirror xr content
  41734. */
  41735. canvasContext: Nullable<WebGLRenderingContext>;
  41736. /**
  41737. * Initializes the canvas to be added/removed upon entering/exiting xr
  41738. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41739. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41740. */
  41741. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41742. /**
  41743. * Disposes of the object
  41744. */
  41745. dispose(): void;
  41746. private _setManagedOutputCanvas;
  41747. private _addCanvas;
  41748. private _removeCanvas;
  41749. }
  41750. }
  41751. declare module "babylonjs/Cameras/XR/index" {
  41752. export * from "babylonjs/Cameras/XR/webXRCamera";
  41753. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41754. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41755. export * from "babylonjs/Cameras/XR/webXRInput";
  41756. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41757. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41758. }
  41759. declare module "babylonjs/Cameras/RigModes/index" {
  41760. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41761. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41762. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41763. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41764. }
  41765. declare module "babylonjs/Cameras/index" {
  41766. export * from "babylonjs/Cameras/Inputs/index";
  41767. export * from "babylonjs/Cameras/cameraInputsManager";
  41768. export * from "babylonjs/Cameras/camera";
  41769. export * from "babylonjs/Cameras/targetCamera";
  41770. export * from "babylonjs/Cameras/freeCamera";
  41771. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41772. export * from "babylonjs/Cameras/touchCamera";
  41773. export * from "babylonjs/Cameras/arcRotateCamera";
  41774. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41775. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41776. export * from "babylonjs/Cameras/flyCamera";
  41777. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41778. export * from "babylonjs/Cameras/followCamera";
  41779. export * from "babylonjs/Cameras/gamepadCamera";
  41780. export * from "babylonjs/Cameras/Stereoscopic/index";
  41781. export * from "babylonjs/Cameras/universalCamera";
  41782. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41783. export * from "babylonjs/Cameras/VR/index";
  41784. export * from "babylonjs/Cameras/XR/index";
  41785. export * from "babylonjs/Cameras/RigModes/index";
  41786. }
  41787. declare module "babylonjs/Collisions/index" {
  41788. export * from "babylonjs/Collisions/collider";
  41789. export * from "babylonjs/Collisions/collisionCoordinator";
  41790. export * from "babylonjs/Collisions/pickingInfo";
  41791. export * from "babylonjs/Collisions/intersectionInfo";
  41792. export * from "babylonjs/Collisions/meshCollisionData";
  41793. }
  41794. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41795. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41796. import { Vector3, Plane } from "babylonjs/Maths/math";
  41797. import { Ray } from "babylonjs/Culling/ray";
  41798. /**
  41799. * Contains an array of blocks representing the octree
  41800. */
  41801. export interface IOctreeContainer<T> {
  41802. /**
  41803. * Blocks within the octree
  41804. */
  41805. blocks: Array<OctreeBlock<T>>;
  41806. }
  41807. /**
  41808. * Class used to store a cell in an octree
  41809. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41810. */
  41811. export class OctreeBlock<T> {
  41812. /**
  41813. * Gets the content of the current block
  41814. */
  41815. entries: T[];
  41816. /**
  41817. * Gets the list of block children
  41818. */
  41819. blocks: Array<OctreeBlock<T>>;
  41820. private _depth;
  41821. private _maxDepth;
  41822. private _capacity;
  41823. private _minPoint;
  41824. private _maxPoint;
  41825. private _boundingVectors;
  41826. private _creationFunc;
  41827. /**
  41828. * Creates a new block
  41829. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41830. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41831. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41832. * @param depth defines the current depth of this block in the octree
  41833. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41834. * @param creationFunc defines a callback to call when an element is added to the block
  41835. */
  41836. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41837. /**
  41838. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41839. */
  41840. readonly capacity: number;
  41841. /**
  41842. * Gets the minimum vector (in world space) of the block's bounding box
  41843. */
  41844. readonly minPoint: Vector3;
  41845. /**
  41846. * Gets the maximum vector (in world space) of the block's bounding box
  41847. */
  41848. readonly maxPoint: Vector3;
  41849. /**
  41850. * Add a new element to this block
  41851. * @param entry defines the element to add
  41852. */
  41853. addEntry(entry: T): void;
  41854. /**
  41855. * Remove an element from this block
  41856. * @param entry defines the element to remove
  41857. */
  41858. removeEntry(entry: T): void;
  41859. /**
  41860. * Add an array of elements to this block
  41861. * @param entries defines the array of elements to add
  41862. */
  41863. addEntries(entries: T[]): void;
  41864. /**
  41865. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41866. * @param frustumPlanes defines the frustum planes to test
  41867. * @param selection defines the array to store current content if selection is positive
  41868. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41869. */
  41870. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41871. /**
  41872. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41873. * @param sphereCenter defines the bounding sphere center
  41874. * @param sphereRadius defines the bounding sphere radius
  41875. * @param selection defines the array to store current content if selection is positive
  41876. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41877. */
  41878. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41879. /**
  41880. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41881. * @param ray defines the ray to test with
  41882. * @param selection defines the array to store current content if selection is positive
  41883. */
  41884. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41885. /**
  41886. * Subdivide the content into child blocks (this block will then be empty)
  41887. */
  41888. createInnerBlocks(): void;
  41889. /**
  41890. * @hidden
  41891. */
  41892. 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;
  41893. }
  41894. }
  41895. declare module "babylonjs/Culling/Octrees/octree" {
  41896. import { SmartArray } from "babylonjs/Misc/smartArray";
  41897. import { Vector3, Plane } from "babylonjs/Maths/math";
  41898. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41900. import { Ray } from "babylonjs/Culling/ray";
  41901. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41902. /**
  41903. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41904. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41905. */
  41906. export class Octree<T> {
  41907. /** 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.) */
  41908. maxDepth: number;
  41909. /**
  41910. * Blocks within the octree containing objects
  41911. */
  41912. blocks: Array<OctreeBlock<T>>;
  41913. /**
  41914. * Content stored in the octree
  41915. */
  41916. dynamicContent: T[];
  41917. private _maxBlockCapacity;
  41918. private _selectionContent;
  41919. private _creationFunc;
  41920. /**
  41921. * Creates a octree
  41922. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41923. * @param creationFunc function to be used to instatiate the octree
  41924. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41925. * @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.)
  41926. */
  41927. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41928. /** 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.) */
  41929. maxDepth?: number);
  41930. /**
  41931. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41932. * @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);
  41933. * @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);
  41934. * @param entries meshes to be added to the octree blocks
  41935. */
  41936. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41937. /**
  41938. * Adds a mesh to the octree
  41939. * @param entry Mesh to add to the octree
  41940. */
  41941. addMesh(entry: T): void;
  41942. /**
  41943. * Remove an element from the octree
  41944. * @param entry defines the element to remove
  41945. */
  41946. removeMesh(entry: T): void;
  41947. /**
  41948. * Selects an array of meshes within the frustum
  41949. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41950. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41951. * @returns array of meshes within the frustum
  41952. */
  41953. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41954. /**
  41955. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41956. * @param sphereCenter defines the bounding sphere center
  41957. * @param sphereRadius defines the bounding sphere radius
  41958. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41959. * @returns an array of objects that intersect the sphere
  41960. */
  41961. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41962. /**
  41963. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41964. * @param ray defines the ray to test with
  41965. * @returns array of intersected objects
  41966. */
  41967. intersectsRay(ray: Ray): SmartArray<T>;
  41968. /**
  41969. * Adds a mesh into the octree block if it intersects the block
  41970. */
  41971. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41972. /**
  41973. * Adds a submesh into the octree block if it intersects the block
  41974. */
  41975. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41976. }
  41977. }
  41978. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41979. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41980. import { Scene } from "babylonjs/scene";
  41981. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41983. import { Ray } from "babylonjs/Culling/ray";
  41984. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41985. import { Collider } from "babylonjs/Collisions/collider";
  41986. module "babylonjs/scene" {
  41987. interface Scene {
  41988. /**
  41989. * @hidden
  41990. * Backing Filed
  41991. */
  41992. _selectionOctree: Octree<AbstractMesh>;
  41993. /**
  41994. * Gets the octree used to boost mesh selection (picking)
  41995. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41996. */
  41997. selectionOctree: Octree<AbstractMesh>;
  41998. /**
  41999. * Creates or updates the octree used to boost selection (picking)
  42000. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42001. * @param maxCapacity defines the maximum capacity per leaf
  42002. * @param maxDepth defines the maximum depth of the octree
  42003. * @returns an octree of AbstractMesh
  42004. */
  42005. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42006. }
  42007. }
  42008. module "babylonjs/Meshes/abstractMesh" {
  42009. interface AbstractMesh {
  42010. /**
  42011. * @hidden
  42012. * Backing Field
  42013. */
  42014. _submeshesOctree: Octree<SubMesh>;
  42015. /**
  42016. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42017. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42018. * @param maxCapacity defines the maximum size of each block (64 by default)
  42019. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42020. * @returns the new octree
  42021. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42022. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42023. */
  42024. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42025. }
  42026. }
  42027. /**
  42028. * Defines the octree scene component responsible to manage any octrees
  42029. * in a given scene.
  42030. */
  42031. export class OctreeSceneComponent {
  42032. /**
  42033. * The component name help to identify the component in the list of scene components.
  42034. */
  42035. readonly name: string;
  42036. /**
  42037. * The scene the component belongs to.
  42038. */
  42039. scene: Scene;
  42040. /**
  42041. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42042. */
  42043. readonly checksIsEnabled: boolean;
  42044. /**
  42045. * Creates a new instance of the component for the given scene
  42046. * @param scene Defines the scene to register the component in
  42047. */
  42048. constructor(scene: Scene);
  42049. /**
  42050. * Registers the component in a given scene
  42051. */
  42052. register(): void;
  42053. /**
  42054. * Return the list of active meshes
  42055. * @returns the list of active meshes
  42056. */
  42057. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42058. /**
  42059. * Return the list of active sub meshes
  42060. * @param mesh The mesh to get the candidates sub meshes from
  42061. * @returns the list of active sub meshes
  42062. */
  42063. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42064. private _tempRay;
  42065. /**
  42066. * Return the list of sub meshes intersecting with a given local ray
  42067. * @param mesh defines the mesh to find the submesh for
  42068. * @param localRay defines the ray in local space
  42069. * @returns the list of intersecting sub meshes
  42070. */
  42071. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42072. /**
  42073. * Return the list of sub meshes colliding with a collider
  42074. * @param mesh defines the mesh to find the submesh for
  42075. * @param collider defines the collider to evaluate the collision against
  42076. * @returns the list of colliding sub meshes
  42077. */
  42078. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42079. /**
  42080. * Rebuilds the elements related to this component in case of
  42081. * context lost for instance.
  42082. */
  42083. rebuild(): void;
  42084. /**
  42085. * Disposes the component and the associated ressources.
  42086. */
  42087. dispose(): void;
  42088. }
  42089. }
  42090. declare module "babylonjs/Culling/Octrees/index" {
  42091. export * from "babylonjs/Culling/Octrees/octree";
  42092. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42093. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42094. }
  42095. declare module "babylonjs/Culling/index" {
  42096. export * from "babylonjs/Culling/boundingBox";
  42097. export * from "babylonjs/Culling/boundingInfo";
  42098. export * from "babylonjs/Culling/boundingSphere";
  42099. export * from "babylonjs/Culling/Octrees/index";
  42100. export * from "babylonjs/Culling/ray";
  42101. }
  42102. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42103. import { IDisposable, Scene } from "babylonjs/scene";
  42104. import { Nullable } from "babylonjs/types";
  42105. import { Observable } from "babylonjs/Misc/observable";
  42106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42107. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42108. /**
  42109. * Renders a layer on top of an existing scene
  42110. */
  42111. export class UtilityLayerRenderer implements IDisposable {
  42112. /** the original scene that will be rendered on top of */
  42113. originalScene: Scene;
  42114. private _pointerCaptures;
  42115. private _lastPointerEvents;
  42116. private static _DefaultUtilityLayer;
  42117. private static _DefaultKeepDepthUtilityLayer;
  42118. private _sharedGizmoLight;
  42119. /**
  42120. * @hidden
  42121. * Light which used by gizmos to get light shading
  42122. */
  42123. _getSharedGizmoLight(): HemisphericLight;
  42124. /**
  42125. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42126. */
  42127. pickUtilitySceneFirst: boolean;
  42128. /**
  42129. * 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)
  42130. */
  42131. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42132. /**
  42133. * 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)
  42134. */
  42135. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42136. /**
  42137. * The scene that is rendered on top of the original scene
  42138. */
  42139. utilityLayerScene: Scene;
  42140. /**
  42141. * If the utility layer should automatically be rendered on top of existing scene
  42142. */
  42143. shouldRender: boolean;
  42144. /**
  42145. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42146. */
  42147. onlyCheckPointerDownEvents: boolean;
  42148. /**
  42149. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42150. */
  42151. processAllEvents: boolean;
  42152. /**
  42153. * Observable raised when the pointer move from the utility layer scene to the main scene
  42154. */
  42155. onPointerOutObservable: Observable<number>;
  42156. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42157. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42158. private _afterRenderObserver;
  42159. private _sceneDisposeObserver;
  42160. private _originalPointerObserver;
  42161. /**
  42162. * Instantiates a UtilityLayerRenderer
  42163. * @param originalScene the original scene that will be rendered on top of
  42164. * @param handleEvents boolean indicating if the utility layer should handle events
  42165. */
  42166. constructor(
  42167. /** the original scene that will be rendered on top of */
  42168. originalScene: Scene, handleEvents?: boolean);
  42169. private _notifyObservers;
  42170. /**
  42171. * Renders the utility layers scene on top of the original scene
  42172. */
  42173. render(): void;
  42174. /**
  42175. * Disposes of the renderer
  42176. */
  42177. dispose(): void;
  42178. private _updateCamera;
  42179. }
  42180. }
  42181. declare module "babylonjs/Gizmos/gizmo" {
  42182. import { Nullable } from "babylonjs/types";
  42183. import { IDisposable } from "babylonjs/scene";
  42184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42185. import { Mesh } from "babylonjs/Meshes/mesh";
  42186. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42187. /**
  42188. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42189. */
  42190. export class Gizmo implements IDisposable {
  42191. /** The utility layer the gizmo will be added to */
  42192. gizmoLayer: UtilityLayerRenderer;
  42193. /**
  42194. * The root mesh of the gizmo
  42195. */
  42196. _rootMesh: Mesh;
  42197. private _attachedMesh;
  42198. /**
  42199. * Ratio for the scale of the gizmo (Default: 1)
  42200. */
  42201. scaleRatio: number;
  42202. /**
  42203. * If a custom mesh has been set (Default: false)
  42204. */
  42205. protected _customMeshSet: boolean;
  42206. /**
  42207. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42208. * * When set, interactions will be enabled
  42209. */
  42210. attachedMesh: Nullable<AbstractMesh>;
  42211. /**
  42212. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42213. * @param mesh The mesh to replace the default mesh of the gizmo
  42214. */
  42215. setCustomMesh(mesh: Mesh): void;
  42216. /**
  42217. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42218. */
  42219. updateGizmoRotationToMatchAttachedMesh: boolean;
  42220. /**
  42221. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42222. */
  42223. updateGizmoPositionToMatchAttachedMesh: boolean;
  42224. /**
  42225. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42226. */
  42227. protected _updateScale: boolean;
  42228. protected _interactionsEnabled: boolean;
  42229. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42230. private _beforeRenderObserver;
  42231. private _tempVector;
  42232. /**
  42233. * Creates a gizmo
  42234. * @param gizmoLayer The utility layer the gizmo will be added to
  42235. */
  42236. constructor(
  42237. /** The utility layer the gizmo will be added to */
  42238. gizmoLayer?: UtilityLayerRenderer);
  42239. /**
  42240. * Updates the gizmo to match the attached mesh's position/rotation
  42241. */
  42242. protected _update(): void;
  42243. /**
  42244. * Disposes of the gizmo
  42245. */
  42246. dispose(): void;
  42247. }
  42248. }
  42249. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42250. import { Observable } from "babylonjs/Misc/observable";
  42251. import { Nullable } from "babylonjs/types";
  42252. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42253. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42255. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42256. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42257. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42258. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42259. import { Scene } from "babylonjs/scene";
  42260. /**
  42261. * Single axis drag gizmo
  42262. */
  42263. export class AxisDragGizmo extends Gizmo {
  42264. /**
  42265. * Drag behavior responsible for the gizmos dragging interactions
  42266. */
  42267. dragBehavior: PointerDragBehavior;
  42268. private _pointerObserver;
  42269. /**
  42270. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42271. */
  42272. snapDistance: number;
  42273. /**
  42274. * Event that fires each time the gizmo snaps to a new location.
  42275. * * snapDistance is the the change in distance
  42276. */
  42277. onSnapObservable: Observable<{
  42278. snapDistance: number;
  42279. }>;
  42280. /** @hidden */
  42281. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42282. /** @hidden */
  42283. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42284. /**
  42285. * Creates an AxisDragGizmo
  42286. * @param gizmoLayer The utility layer the gizmo will be added to
  42287. * @param dragAxis The axis which the gizmo will be able to drag on
  42288. * @param color The color of the gizmo
  42289. */
  42290. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42291. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42292. /**
  42293. * Disposes of the gizmo
  42294. */
  42295. dispose(): void;
  42296. }
  42297. }
  42298. declare module "babylonjs/Debug/axesViewer" {
  42299. import { Vector3 } from "babylonjs/Maths/math";
  42300. import { Nullable } from "babylonjs/types";
  42301. import { Scene } from "babylonjs/scene";
  42302. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42303. /**
  42304. * The Axes viewer will show 3 axes in a specific point in space
  42305. */
  42306. export class AxesViewer {
  42307. private _xAxis;
  42308. private _yAxis;
  42309. private _zAxis;
  42310. private _scaleLinesFactor;
  42311. private _instanced;
  42312. /**
  42313. * Gets the hosting scene
  42314. */
  42315. scene: Scene;
  42316. /**
  42317. * Gets or sets a number used to scale line length
  42318. */
  42319. scaleLines: number;
  42320. /** Gets the node hierarchy used to render x-axis */
  42321. readonly xAxis: TransformNode;
  42322. /** Gets the node hierarchy used to render y-axis */
  42323. readonly yAxis: TransformNode;
  42324. /** Gets the node hierarchy used to render z-axis */
  42325. readonly zAxis: TransformNode;
  42326. /**
  42327. * Creates a new AxesViewer
  42328. * @param scene defines the hosting scene
  42329. * @param scaleLines defines a number used to scale line length (1 by default)
  42330. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42331. * @param xAxis defines the node hierarchy used to render the x-axis
  42332. * @param yAxis defines the node hierarchy used to render the y-axis
  42333. * @param zAxis defines the node hierarchy used to render the z-axis
  42334. */
  42335. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42336. /**
  42337. * Force the viewer to update
  42338. * @param position defines the position of the viewer
  42339. * @param xaxis defines the x axis of the viewer
  42340. * @param yaxis defines the y axis of the viewer
  42341. * @param zaxis defines the z axis of the viewer
  42342. */
  42343. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42344. /**
  42345. * Creates an instance of this axes viewer.
  42346. * @returns a new axes viewer with instanced meshes
  42347. */
  42348. createInstance(): AxesViewer;
  42349. /** Releases resources */
  42350. dispose(): void;
  42351. private static _SetRenderingGroupId;
  42352. }
  42353. }
  42354. declare module "babylonjs/Debug/boneAxesViewer" {
  42355. import { Nullable } from "babylonjs/types";
  42356. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42357. import { Vector3 } from "babylonjs/Maths/math";
  42358. import { Mesh } from "babylonjs/Meshes/mesh";
  42359. import { Bone } from "babylonjs/Bones/bone";
  42360. import { Scene } from "babylonjs/scene";
  42361. /**
  42362. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42363. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42364. */
  42365. export class BoneAxesViewer extends AxesViewer {
  42366. /**
  42367. * Gets or sets the target mesh where to display the axes viewer
  42368. */
  42369. mesh: Nullable<Mesh>;
  42370. /**
  42371. * Gets or sets the target bone where to display the axes viewer
  42372. */
  42373. bone: Nullable<Bone>;
  42374. /** Gets current position */
  42375. pos: Vector3;
  42376. /** Gets direction of X axis */
  42377. xaxis: Vector3;
  42378. /** Gets direction of Y axis */
  42379. yaxis: Vector3;
  42380. /** Gets direction of Z axis */
  42381. zaxis: Vector3;
  42382. /**
  42383. * Creates a new BoneAxesViewer
  42384. * @param scene defines the hosting scene
  42385. * @param bone defines the target bone
  42386. * @param mesh defines the target mesh
  42387. * @param scaleLines defines a scaling factor for line length (1 by default)
  42388. */
  42389. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42390. /**
  42391. * Force the viewer to update
  42392. */
  42393. update(): void;
  42394. /** Releases resources */
  42395. dispose(): void;
  42396. }
  42397. }
  42398. declare module "babylonjs/Debug/debugLayer" {
  42399. import { Observable } from "babylonjs/Misc/observable";
  42400. import { Scene } from "babylonjs/scene";
  42401. /**
  42402. * Interface used to define scene explorer extensibility option
  42403. */
  42404. export interface IExplorerExtensibilityOption {
  42405. /**
  42406. * Define the option label
  42407. */
  42408. label: string;
  42409. /**
  42410. * Defines the action to execute on click
  42411. */
  42412. action: (entity: any) => void;
  42413. }
  42414. /**
  42415. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42416. */
  42417. export interface IExplorerExtensibilityGroup {
  42418. /**
  42419. * Defines a predicate to test if a given type mut be extended
  42420. */
  42421. predicate: (entity: any) => boolean;
  42422. /**
  42423. * Gets the list of options added to a type
  42424. */
  42425. entries: IExplorerExtensibilityOption[];
  42426. }
  42427. /**
  42428. * Interface used to define the options to use to create the Inspector
  42429. */
  42430. export interface IInspectorOptions {
  42431. /**
  42432. * Display in overlay mode (default: false)
  42433. */
  42434. overlay?: boolean;
  42435. /**
  42436. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42437. */
  42438. globalRoot?: HTMLElement;
  42439. /**
  42440. * Display the Scene explorer
  42441. */
  42442. showExplorer?: boolean;
  42443. /**
  42444. * Display the property inspector
  42445. */
  42446. showInspector?: boolean;
  42447. /**
  42448. * Display in embed mode (both panes on the right)
  42449. */
  42450. embedMode?: boolean;
  42451. /**
  42452. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42453. */
  42454. handleResize?: boolean;
  42455. /**
  42456. * Allow the panes to popup (default: true)
  42457. */
  42458. enablePopup?: boolean;
  42459. /**
  42460. * Allow the panes to be closed by users (default: true)
  42461. */
  42462. enableClose?: boolean;
  42463. /**
  42464. * Optional list of extensibility entries
  42465. */
  42466. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42467. /**
  42468. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42469. */
  42470. inspectorURL?: string;
  42471. }
  42472. module "babylonjs/scene" {
  42473. interface Scene {
  42474. /**
  42475. * @hidden
  42476. * Backing field
  42477. */
  42478. _debugLayer: DebugLayer;
  42479. /**
  42480. * Gets the debug layer (aka Inspector) associated with the scene
  42481. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42482. */
  42483. debugLayer: DebugLayer;
  42484. }
  42485. }
  42486. /**
  42487. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42488. * what is happening in your scene
  42489. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42490. */
  42491. export class DebugLayer {
  42492. /**
  42493. * Define the url to get the inspector script from.
  42494. * By default it uses the babylonjs CDN.
  42495. * @ignoreNaming
  42496. */
  42497. static InspectorURL: string;
  42498. private _scene;
  42499. private BJSINSPECTOR;
  42500. /**
  42501. * Observable triggered when a property is changed through the inspector.
  42502. */
  42503. onPropertyChangedObservable: Observable<{
  42504. object: any;
  42505. property: string;
  42506. value: any;
  42507. initialValue: any;
  42508. }>;
  42509. /**
  42510. * Instantiates a new debug layer.
  42511. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42512. * what is happening in your scene
  42513. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42514. * @param scene Defines the scene to inspect
  42515. */
  42516. constructor(scene: Scene);
  42517. /** Creates the inspector window. */
  42518. private _createInspector;
  42519. /**
  42520. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42521. * @param entity defines the entity to select
  42522. * @param lineContainerTitle defines the specific block to highlight
  42523. */
  42524. select(entity: any, lineContainerTitle?: string): void;
  42525. /** Get the inspector from bundle or global */
  42526. private _getGlobalInspector;
  42527. /**
  42528. * Get if the inspector is visible or not.
  42529. * @returns true if visible otherwise, false
  42530. */
  42531. isVisible(): boolean;
  42532. /**
  42533. * Hide the inspector and close its window.
  42534. */
  42535. hide(): void;
  42536. /**
  42537. * Launch the debugLayer.
  42538. * @param config Define the configuration of the inspector
  42539. * @return a promise fulfilled when the debug layer is visible
  42540. */
  42541. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42542. }
  42543. }
  42544. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42545. import { Nullable } from "babylonjs/types";
  42546. import { Scene } from "babylonjs/scene";
  42547. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42548. import { Mesh } from "babylonjs/Meshes/mesh";
  42549. /**
  42550. * Class containing static functions to help procedurally build meshes
  42551. */
  42552. export class BoxBuilder {
  42553. /**
  42554. * Creates a box mesh
  42555. * * The parameter `size` sets the size (float) of each box side (default 1)
  42556. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42557. * * 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)
  42558. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42560. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42562. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42563. * @param name defines the name of the mesh
  42564. * @param options defines the options used to create the mesh
  42565. * @param scene defines the hosting scene
  42566. * @returns the box mesh
  42567. */
  42568. static CreateBox(name: string, options: {
  42569. size?: number;
  42570. width?: number;
  42571. height?: number;
  42572. depth?: number;
  42573. faceUV?: Vector4[];
  42574. faceColors?: Color4[];
  42575. sideOrientation?: number;
  42576. frontUVs?: Vector4;
  42577. backUVs?: Vector4;
  42578. wrap?: boolean;
  42579. topBaseAt?: number;
  42580. bottomBaseAt?: number;
  42581. updatable?: boolean;
  42582. }, scene?: Nullable<Scene>): Mesh;
  42583. }
  42584. }
  42585. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42586. import { Vector4 } from "babylonjs/Maths/math";
  42587. import { Mesh } from "babylonjs/Meshes/mesh";
  42588. /**
  42589. * Class containing static functions to help procedurally build meshes
  42590. */
  42591. export class SphereBuilder {
  42592. /**
  42593. * Creates a sphere mesh
  42594. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42595. * * 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`)
  42596. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42597. * * 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
  42598. * * 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)
  42599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42600. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42602. * @param name defines the name of the mesh
  42603. * @param options defines the options used to create the mesh
  42604. * @param scene defines the hosting scene
  42605. * @returns the sphere mesh
  42606. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42607. */
  42608. static CreateSphere(name: string, options: {
  42609. segments?: number;
  42610. diameter?: number;
  42611. diameterX?: number;
  42612. diameterY?: number;
  42613. diameterZ?: number;
  42614. arc?: number;
  42615. slice?: number;
  42616. sideOrientation?: number;
  42617. frontUVs?: Vector4;
  42618. backUVs?: Vector4;
  42619. updatable?: boolean;
  42620. }, scene: any): Mesh;
  42621. }
  42622. }
  42623. declare module "babylonjs/Debug/physicsViewer" {
  42624. import { Nullable } from "babylonjs/types";
  42625. import { Scene } from "babylonjs/scene";
  42626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42627. import { Mesh } from "babylonjs/Meshes/mesh";
  42628. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42629. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42630. /**
  42631. * Used to show the physics impostor around the specific mesh
  42632. */
  42633. export class PhysicsViewer {
  42634. /** @hidden */
  42635. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42636. /** @hidden */
  42637. protected _meshes: Array<Nullable<AbstractMesh>>;
  42638. /** @hidden */
  42639. protected _scene: Nullable<Scene>;
  42640. /** @hidden */
  42641. protected _numMeshes: number;
  42642. /** @hidden */
  42643. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42644. private _renderFunction;
  42645. private _utilityLayer;
  42646. private _debugBoxMesh;
  42647. private _debugSphereMesh;
  42648. private _debugCylinderMesh;
  42649. private _debugMaterial;
  42650. private _debugMeshMeshes;
  42651. /**
  42652. * Creates a new PhysicsViewer
  42653. * @param scene defines the hosting scene
  42654. */
  42655. constructor(scene: Scene);
  42656. /** @hidden */
  42657. protected _updateDebugMeshes(): void;
  42658. /**
  42659. * Renders a specified physic impostor
  42660. * @param impostor defines the impostor to render
  42661. * @param targetMesh defines the mesh represented by the impostor
  42662. * @returns the new debug mesh used to render the impostor
  42663. */
  42664. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42665. /**
  42666. * Hides a specified physic impostor
  42667. * @param impostor defines the impostor to hide
  42668. */
  42669. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42670. private _getDebugMaterial;
  42671. private _getDebugBoxMesh;
  42672. private _getDebugSphereMesh;
  42673. private _getDebugCylinderMesh;
  42674. private _getDebugMeshMesh;
  42675. private _getDebugMesh;
  42676. /** Releases all resources */
  42677. dispose(): void;
  42678. }
  42679. }
  42680. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42681. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42682. import { Nullable } from "babylonjs/types";
  42683. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42684. import { Scene } from "babylonjs/scene";
  42685. /**
  42686. * Class containing static functions to help procedurally build meshes
  42687. */
  42688. export class LinesBuilder {
  42689. /**
  42690. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42691. * * 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
  42692. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42693. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42694. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42695. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42696. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42697. * * 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
  42698. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42700. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42701. * @param name defines the name of the new line system
  42702. * @param options defines the options used to create the line system
  42703. * @param scene defines the hosting scene
  42704. * @returns a new line system mesh
  42705. */
  42706. static CreateLineSystem(name: string, options: {
  42707. lines: Vector3[][];
  42708. updatable?: boolean;
  42709. instance?: Nullable<LinesMesh>;
  42710. colors?: Nullable<Color4[][]>;
  42711. useVertexAlpha?: boolean;
  42712. }, scene: Nullable<Scene>): LinesMesh;
  42713. /**
  42714. * Creates a line mesh
  42715. * 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
  42716. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42717. * * The parameter `points` is an array successive Vector3
  42718. * * 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
  42719. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42720. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42721. * * When updating an instance, remember that only point positions can change, not the number of points
  42722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42724. * @param name defines the name of the new line system
  42725. * @param options defines the options used to create the line system
  42726. * @param scene defines the hosting scene
  42727. * @returns a new line mesh
  42728. */
  42729. static CreateLines(name: string, options: {
  42730. points: Vector3[];
  42731. updatable?: boolean;
  42732. instance?: Nullable<LinesMesh>;
  42733. colors?: Color4[];
  42734. useVertexAlpha?: boolean;
  42735. }, scene?: Nullable<Scene>): LinesMesh;
  42736. /**
  42737. * Creates a dashed line mesh
  42738. * * 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
  42739. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42740. * * The parameter `points` is an array successive Vector3
  42741. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42742. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42743. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42744. * * 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
  42745. * * When updating an instance, remember that only point positions can change, not the number of points
  42746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42747. * @param name defines the name of the mesh
  42748. * @param options defines the options used to create the mesh
  42749. * @param scene defines the hosting scene
  42750. * @returns the dashed line mesh
  42751. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42752. */
  42753. static CreateDashedLines(name: string, options: {
  42754. points: Vector3[];
  42755. dashSize?: number;
  42756. gapSize?: number;
  42757. dashNb?: number;
  42758. updatable?: boolean;
  42759. instance?: LinesMesh;
  42760. }, scene?: Nullable<Scene>): LinesMesh;
  42761. }
  42762. }
  42763. declare module "babylonjs/Debug/rayHelper" {
  42764. import { Nullable } from "babylonjs/types";
  42765. import { Ray } from "babylonjs/Culling/ray";
  42766. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42767. import { Scene } from "babylonjs/scene";
  42768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42769. import "babylonjs/Meshes/Builders/linesBuilder";
  42770. /**
  42771. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42772. * in order to better appreciate the issue one might have.
  42773. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42774. */
  42775. export class RayHelper {
  42776. /**
  42777. * Defines the ray we are currently tryin to visualize.
  42778. */
  42779. ray: Nullable<Ray>;
  42780. private _renderPoints;
  42781. private _renderLine;
  42782. private _renderFunction;
  42783. private _scene;
  42784. private _updateToMeshFunction;
  42785. private _attachedToMesh;
  42786. private _meshSpaceDirection;
  42787. private _meshSpaceOrigin;
  42788. /**
  42789. * Helper function to create a colored helper in a scene in one line.
  42790. * @param ray Defines the ray we are currently tryin to visualize
  42791. * @param scene Defines the scene the ray is used in
  42792. * @param color Defines the color we want to see the ray in
  42793. * @returns The newly created ray helper.
  42794. */
  42795. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42796. /**
  42797. * Instantiate a new ray helper.
  42798. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42799. * in order to better appreciate the issue one might have.
  42800. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42801. * @param ray Defines the ray we are currently tryin to visualize
  42802. */
  42803. constructor(ray: Ray);
  42804. /**
  42805. * Shows the ray we are willing to debug.
  42806. * @param scene Defines the scene the ray needs to be rendered in
  42807. * @param color Defines the color the ray needs to be rendered in
  42808. */
  42809. show(scene: Scene, color?: Color3): void;
  42810. /**
  42811. * Hides the ray we are debugging.
  42812. */
  42813. hide(): void;
  42814. private _render;
  42815. /**
  42816. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42817. * @param mesh Defines the mesh we want the helper attached to
  42818. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42819. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42820. * @param length Defines the length of the ray
  42821. */
  42822. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42823. /**
  42824. * Detach the ray helper from the mesh it has previously been attached to.
  42825. */
  42826. detachFromMesh(): void;
  42827. private _updateToMesh;
  42828. /**
  42829. * Dispose the helper and release its associated resources.
  42830. */
  42831. dispose(): void;
  42832. }
  42833. }
  42834. declare module "babylonjs/Debug/skeletonViewer" {
  42835. import { Color3 } from "babylonjs/Maths/math";
  42836. import { Scene } from "babylonjs/scene";
  42837. import { Nullable } from "babylonjs/types";
  42838. import { Skeleton } from "babylonjs/Bones/skeleton";
  42839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42840. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42841. /**
  42842. * Class used to render a debug view of a given skeleton
  42843. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42844. */
  42845. export class SkeletonViewer {
  42846. /** defines the skeleton to render */
  42847. skeleton: Skeleton;
  42848. /** defines the mesh attached to the skeleton */
  42849. mesh: AbstractMesh;
  42850. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42851. autoUpdateBonesMatrices: boolean;
  42852. /** defines the rendering group id to use with the viewer */
  42853. renderingGroupId: number;
  42854. /** Gets or sets the color used to render the skeleton */
  42855. color: Color3;
  42856. private _scene;
  42857. private _debugLines;
  42858. private _debugMesh;
  42859. private _isEnabled;
  42860. private _renderFunction;
  42861. private _utilityLayer;
  42862. /**
  42863. * Returns the mesh used to render the bones
  42864. */
  42865. readonly debugMesh: Nullable<LinesMesh>;
  42866. /**
  42867. * Creates a new SkeletonViewer
  42868. * @param skeleton defines the skeleton to render
  42869. * @param mesh defines the mesh attached to the skeleton
  42870. * @param scene defines the hosting scene
  42871. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42872. * @param renderingGroupId defines the rendering group id to use with the viewer
  42873. */
  42874. constructor(
  42875. /** defines the skeleton to render */
  42876. skeleton: Skeleton,
  42877. /** defines the mesh attached to the skeleton */
  42878. mesh: AbstractMesh, scene: Scene,
  42879. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42880. autoUpdateBonesMatrices?: boolean,
  42881. /** defines the rendering group id to use with the viewer */
  42882. renderingGroupId?: number);
  42883. /** Gets or sets a boolean indicating if the viewer is enabled */
  42884. isEnabled: boolean;
  42885. private _getBonePosition;
  42886. private _getLinesForBonesWithLength;
  42887. private _getLinesForBonesNoLength;
  42888. /** Update the viewer to sync with current skeleton state */
  42889. update(): void;
  42890. /** Release associated resources */
  42891. dispose(): void;
  42892. }
  42893. }
  42894. declare module "babylonjs/Debug/index" {
  42895. export * from "babylonjs/Debug/axesViewer";
  42896. export * from "babylonjs/Debug/boneAxesViewer";
  42897. export * from "babylonjs/Debug/debugLayer";
  42898. export * from "babylonjs/Debug/physicsViewer";
  42899. export * from "babylonjs/Debug/rayHelper";
  42900. export * from "babylonjs/Debug/skeletonViewer";
  42901. }
  42902. declare module "babylonjs/Engines/nullEngine" {
  42903. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42904. import { Scene } from "babylonjs/scene";
  42905. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42906. import { Engine } from "babylonjs/Engines/engine";
  42907. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42908. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42909. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42910. import { Effect } from "babylonjs/Materials/effect";
  42911. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42912. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42913. /**
  42914. * Options to create the null engine
  42915. */
  42916. export class NullEngineOptions {
  42917. /**
  42918. * Render width (Default: 512)
  42919. */
  42920. renderWidth: number;
  42921. /**
  42922. * Render height (Default: 256)
  42923. */
  42924. renderHeight: number;
  42925. /**
  42926. * Texture size (Default: 512)
  42927. */
  42928. textureSize: number;
  42929. /**
  42930. * If delta time between frames should be constant
  42931. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42932. */
  42933. deterministicLockstep: boolean;
  42934. /**
  42935. * Maximum about of steps between frames (Default: 4)
  42936. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42937. */
  42938. lockstepMaxSteps: number;
  42939. }
  42940. /**
  42941. * The null engine class provides support for headless version of babylon.js.
  42942. * This can be used in server side scenario or for testing purposes
  42943. */
  42944. export class NullEngine extends Engine {
  42945. private _options;
  42946. /**
  42947. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42948. */
  42949. isDeterministicLockStep(): boolean;
  42950. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42951. getLockstepMaxSteps(): number;
  42952. /**
  42953. * Sets hardware scaling, used to save performance if needed
  42954. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42955. */
  42956. getHardwareScalingLevel(): number;
  42957. constructor(options?: NullEngineOptions);
  42958. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42959. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42960. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42961. getRenderWidth(useScreen?: boolean): number;
  42962. getRenderHeight(useScreen?: boolean): number;
  42963. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42964. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42965. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42966. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42967. bindSamplers(effect: Effect): void;
  42968. enableEffect(effect: Effect): void;
  42969. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42970. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42971. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42972. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42973. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42974. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42975. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42976. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42977. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42978. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42979. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42980. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42981. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42982. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42983. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42984. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42985. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42986. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42987. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42988. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42989. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42990. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42991. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42992. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42993. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42994. bindBuffers(vertexBuffers: {
  42995. [key: string]: VertexBuffer;
  42996. }, indexBuffer: DataBuffer, effect: Effect): void;
  42997. wipeCaches(bruteForce?: boolean): void;
  42998. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42999. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43000. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43001. /** @hidden */
  43002. _createTexture(): WebGLTexture;
  43003. /** @hidden */
  43004. _releaseTexture(texture: InternalTexture): void;
  43005. 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;
  43006. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43007. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43008. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43009. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43010. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43011. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43012. areAllEffectsReady(): boolean;
  43013. /**
  43014. * @hidden
  43015. * Get the current error code of the webGL context
  43016. * @returns the error code
  43017. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43018. */
  43019. getError(): number;
  43020. /** @hidden */
  43021. _getUnpackAlignement(): number;
  43022. /** @hidden */
  43023. _unpackFlipY(value: boolean): void;
  43024. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43025. /**
  43026. * Updates a dynamic vertex buffer.
  43027. * @param vertexBuffer the vertex buffer to update
  43028. * @param data the data used to update the vertex buffer
  43029. * @param byteOffset the byte offset of the data (optional)
  43030. * @param byteLength the byte length of the data (optional)
  43031. */
  43032. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43033. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43034. /** @hidden */
  43035. _bindTexture(channel: number, texture: InternalTexture): void;
  43036. /** @hidden */
  43037. _releaseBuffer(buffer: DataBuffer): boolean;
  43038. releaseEffects(): void;
  43039. displayLoadingUI(): void;
  43040. hideLoadingUI(): void;
  43041. /** @hidden */
  43042. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43043. /** @hidden */
  43044. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43045. /** @hidden */
  43046. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43047. /** @hidden */
  43048. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43049. }
  43050. }
  43051. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43052. import { Nullable, int } from "babylonjs/types";
  43053. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43054. /** @hidden */
  43055. export class _OcclusionDataStorage {
  43056. /** @hidden */
  43057. occlusionInternalRetryCounter: number;
  43058. /** @hidden */
  43059. isOcclusionQueryInProgress: boolean;
  43060. /** @hidden */
  43061. isOccluded: boolean;
  43062. /** @hidden */
  43063. occlusionRetryCount: number;
  43064. /** @hidden */
  43065. occlusionType: number;
  43066. /** @hidden */
  43067. occlusionQueryAlgorithmType: number;
  43068. }
  43069. module "babylonjs/Engines/engine" {
  43070. interface Engine {
  43071. /**
  43072. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43073. * @return the new query
  43074. */
  43075. createQuery(): WebGLQuery;
  43076. /**
  43077. * Delete and release a webGL query
  43078. * @param query defines the query to delete
  43079. * @return the current engine
  43080. */
  43081. deleteQuery(query: WebGLQuery): Engine;
  43082. /**
  43083. * Check if a given query has resolved and got its value
  43084. * @param query defines the query to check
  43085. * @returns true if the query got its value
  43086. */
  43087. isQueryResultAvailable(query: WebGLQuery): boolean;
  43088. /**
  43089. * Gets the value of a given query
  43090. * @param query defines the query to check
  43091. * @returns the value of the query
  43092. */
  43093. getQueryResult(query: WebGLQuery): number;
  43094. /**
  43095. * Initiates an occlusion query
  43096. * @param algorithmType defines the algorithm to use
  43097. * @param query defines the query to use
  43098. * @returns the current engine
  43099. * @see http://doc.babylonjs.com/features/occlusionquery
  43100. */
  43101. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43102. /**
  43103. * Ends an occlusion query
  43104. * @see http://doc.babylonjs.com/features/occlusionquery
  43105. * @param algorithmType defines the algorithm to use
  43106. * @returns the current engine
  43107. */
  43108. endOcclusionQuery(algorithmType: number): Engine;
  43109. /**
  43110. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43111. * Please note that only one query can be issued at a time
  43112. * @returns a time token used to track the time span
  43113. */
  43114. startTimeQuery(): Nullable<_TimeToken>;
  43115. /**
  43116. * Ends a time query
  43117. * @param token defines the token used to measure the time span
  43118. * @returns the time spent (in ns)
  43119. */
  43120. endTimeQuery(token: _TimeToken): int;
  43121. /** @hidden */
  43122. _currentNonTimestampToken: Nullable<_TimeToken>;
  43123. /** @hidden */
  43124. _createTimeQuery(): WebGLQuery;
  43125. /** @hidden */
  43126. _deleteTimeQuery(query: WebGLQuery): void;
  43127. /** @hidden */
  43128. _getGlAlgorithmType(algorithmType: number): number;
  43129. /** @hidden */
  43130. _getTimeQueryResult(query: WebGLQuery): any;
  43131. /** @hidden */
  43132. _getTimeQueryAvailability(query: WebGLQuery): any;
  43133. }
  43134. }
  43135. module "babylonjs/Meshes/abstractMesh" {
  43136. interface AbstractMesh {
  43137. /**
  43138. * Backing filed
  43139. * @hidden
  43140. */
  43141. __occlusionDataStorage: _OcclusionDataStorage;
  43142. /**
  43143. * Access property
  43144. * @hidden
  43145. */
  43146. _occlusionDataStorage: _OcclusionDataStorage;
  43147. /**
  43148. * 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.
  43149. * The default value is -1 which means don't break the query and wait till the result
  43150. * @see http://doc.babylonjs.com/features/occlusionquery
  43151. */
  43152. occlusionRetryCount: number;
  43153. /**
  43154. * 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:
  43155. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43156. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43157. * * 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.
  43158. * @see http://doc.babylonjs.com/features/occlusionquery
  43159. */
  43160. occlusionType: number;
  43161. /**
  43162. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43163. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43164. * * 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.
  43165. * @see http://doc.babylonjs.com/features/occlusionquery
  43166. */
  43167. occlusionQueryAlgorithmType: number;
  43168. /**
  43169. * 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
  43170. * @see http://doc.babylonjs.com/features/occlusionquery
  43171. */
  43172. isOccluded: boolean;
  43173. /**
  43174. * Flag to check the progress status of the query
  43175. * @see http://doc.babylonjs.com/features/occlusionquery
  43176. */
  43177. isOcclusionQueryInProgress: boolean;
  43178. }
  43179. }
  43180. }
  43181. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43182. import { Nullable } from "babylonjs/types";
  43183. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43184. /** @hidden */
  43185. export var _forceTransformFeedbackToBundle: boolean;
  43186. module "babylonjs/Engines/engine" {
  43187. interface Engine {
  43188. /**
  43189. * Creates a webGL transform feedback object
  43190. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43191. * @returns the webGL transform feedback object
  43192. */
  43193. createTransformFeedback(): WebGLTransformFeedback;
  43194. /**
  43195. * Delete a webGL transform feedback object
  43196. * @param value defines the webGL transform feedback object to delete
  43197. */
  43198. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43199. /**
  43200. * Bind a webGL transform feedback object to the webgl context
  43201. * @param value defines the webGL transform feedback object to bind
  43202. */
  43203. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43204. /**
  43205. * Begins a transform feedback operation
  43206. * @param usePoints defines if points or triangles must be used
  43207. */
  43208. beginTransformFeedback(usePoints: boolean): void;
  43209. /**
  43210. * Ends a transform feedback operation
  43211. */
  43212. endTransformFeedback(): void;
  43213. /**
  43214. * Specify the varyings to use with transform feedback
  43215. * @param program defines the associated webGL program
  43216. * @param value defines the list of strings representing the varying names
  43217. */
  43218. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43219. /**
  43220. * Bind a webGL buffer for a transform feedback operation
  43221. * @param value defines the webGL buffer to bind
  43222. */
  43223. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43224. }
  43225. }
  43226. }
  43227. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43228. import { Scene } from "babylonjs/scene";
  43229. import { Engine } from "babylonjs/Engines/engine";
  43230. import { Texture } from "babylonjs/Materials/Textures/texture";
  43231. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43232. import "babylonjs/Engines/Extensions/engine.multiRender";
  43233. /**
  43234. * Creation options of the multi render target texture.
  43235. */
  43236. export interface IMultiRenderTargetOptions {
  43237. /**
  43238. * Define if the texture needs to create mip maps after render.
  43239. */
  43240. generateMipMaps?: boolean;
  43241. /**
  43242. * Define the types of all the draw buffers we want to create
  43243. */
  43244. types?: number[];
  43245. /**
  43246. * Define the sampling modes of all the draw buffers we want to create
  43247. */
  43248. samplingModes?: number[];
  43249. /**
  43250. * Define if a depth buffer is required
  43251. */
  43252. generateDepthBuffer?: boolean;
  43253. /**
  43254. * Define if a stencil buffer is required
  43255. */
  43256. generateStencilBuffer?: boolean;
  43257. /**
  43258. * Define if a depth texture is required instead of a depth buffer
  43259. */
  43260. generateDepthTexture?: boolean;
  43261. /**
  43262. * Define the number of desired draw buffers
  43263. */
  43264. textureCount?: number;
  43265. /**
  43266. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43267. */
  43268. doNotChangeAspectRatio?: boolean;
  43269. /**
  43270. * Define the default type of the buffers we are creating
  43271. */
  43272. defaultType?: number;
  43273. }
  43274. /**
  43275. * A multi render target, like a render target provides the ability to render to a texture.
  43276. * Unlike the render target, it can render to several draw buffers in one draw.
  43277. * This is specially interesting in deferred rendering or for any effects requiring more than
  43278. * just one color from a single pass.
  43279. */
  43280. export class MultiRenderTarget extends RenderTargetTexture {
  43281. private _internalTextures;
  43282. private _textures;
  43283. private _multiRenderTargetOptions;
  43284. /**
  43285. * Get if draw buffers are currently supported by the used hardware and browser.
  43286. */
  43287. readonly isSupported: boolean;
  43288. /**
  43289. * Get the list of textures generated by the multi render target.
  43290. */
  43291. readonly textures: Texture[];
  43292. /**
  43293. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43294. */
  43295. readonly depthTexture: Texture;
  43296. /**
  43297. * Set the wrapping mode on U of all the textures we are rendering to.
  43298. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43299. */
  43300. wrapU: number;
  43301. /**
  43302. * Set the wrapping mode on V of all the textures we are rendering to.
  43303. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43304. */
  43305. wrapV: number;
  43306. /**
  43307. * Instantiate a new multi render target texture.
  43308. * A multi render target, like a render target provides the ability to render to a texture.
  43309. * Unlike the render target, it can render to several draw buffers in one draw.
  43310. * This is specially interesting in deferred rendering or for any effects requiring more than
  43311. * just one color from a single pass.
  43312. * @param name Define the name of the texture
  43313. * @param size Define the size of the buffers to render to
  43314. * @param count Define the number of target we are rendering into
  43315. * @param scene Define the scene the texture belongs to
  43316. * @param options Define the options used to create the multi render target
  43317. */
  43318. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43319. /** @hidden */
  43320. _rebuild(): void;
  43321. private _createInternalTextures;
  43322. private _createTextures;
  43323. /**
  43324. * Define the number of samples used if MSAA is enabled.
  43325. */
  43326. samples: number;
  43327. /**
  43328. * Resize all the textures in the multi render target.
  43329. * Be carrefull as it will recreate all the data in the new texture.
  43330. * @param size Define the new size
  43331. */
  43332. resize(size: any): void;
  43333. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43334. /**
  43335. * Dispose the render targets and their associated resources
  43336. */
  43337. dispose(): void;
  43338. /**
  43339. * Release all the underlying texture used as draw buffers.
  43340. */
  43341. releaseInternalTextures(): void;
  43342. }
  43343. }
  43344. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43345. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43346. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43347. import { Nullable } from "babylonjs/types";
  43348. module "babylonjs/Engines/engine" {
  43349. interface Engine {
  43350. /**
  43351. * Unbind a list of render target textures from the webGL context
  43352. * This is used only when drawBuffer extension or webGL2 are active
  43353. * @param textures defines the render target textures to unbind
  43354. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43355. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43356. */
  43357. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43358. /**
  43359. * Create a multi render target texture
  43360. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43361. * @param size defines the size of the texture
  43362. * @param options defines the creation options
  43363. * @returns the cube texture as an InternalTexture
  43364. */
  43365. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43366. /**
  43367. * Update the sample count for a given multiple render target texture
  43368. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43369. * @param textures defines the textures to update
  43370. * @param samples defines the sample count to set
  43371. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43372. */
  43373. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43374. }
  43375. }
  43376. }
  43377. declare module "babylonjs/Engines/Extensions/index" {
  43378. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43379. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43380. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43381. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43382. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43383. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43384. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43385. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43386. }
  43387. declare module "babylonjs/Engines/index" {
  43388. export * from "babylonjs/Engines/constants";
  43389. export * from "babylonjs/Engines/engine";
  43390. export * from "babylonjs/Engines/engineStore";
  43391. export * from "babylonjs/Engines/nullEngine";
  43392. export * from "babylonjs/Engines/Extensions/index";
  43393. export * from "babylonjs/Engines/IPipelineContext";
  43394. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43395. }
  43396. declare module "babylonjs/Events/clipboardEvents" {
  43397. /**
  43398. * Gather the list of clipboard event types as constants.
  43399. */
  43400. export class ClipboardEventTypes {
  43401. /**
  43402. * The clipboard event is fired when a copy command is active (pressed).
  43403. */
  43404. static readonly COPY: number;
  43405. /**
  43406. * The clipboard event is fired when a cut command is active (pressed).
  43407. */
  43408. static readonly CUT: number;
  43409. /**
  43410. * The clipboard event is fired when a paste command is active (pressed).
  43411. */
  43412. static readonly PASTE: number;
  43413. }
  43414. /**
  43415. * This class is used to store clipboard related info for the onClipboardObservable event.
  43416. */
  43417. export class ClipboardInfo {
  43418. /**
  43419. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43420. */
  43421. type: number;
  43422. /**
  43423. * Defines the related dom event
  43424. */
  43425. event: ClipboardEvent;
  43426. /**
  43427. *Creates an instance of ClipboardInfo.
  43428. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43429. * @param event Defines the related dom event
  43430. */
  43431. constructor(
  43432. /**
  43433. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43434. */
  43435. type: number,
  43436. /**
  43437. * Defines the related dom event
  43438. */
  43439. event: ClipboardEvent);
  43440. /**
  43441. * Get the clipboard event's type from the keycode.
  43442. * @param keyCode Defines the keyCode for the current keyboard event.
  43443. * @return {number}
  43444. */
  43445. static GetTypeFromCharacter(keyCode: number): number;
  43446. }
  43447. }
  43448. declare module "babylonjs/Events/index" {
  43449. export * from "babylonjs/Events/keyboardEvents";
  43450. export * from "babylonjs/Events/pointerEvents";
  43451. export * from "babylonjs/Events/clipboardEvents";
  43452. }
  43453. declare module "babylonjs/Loading/sceneLoader" {
  43454. import { Observable } from "babylonjs/Misc/observable";
  43455. import { Nullable } from "babylonjs/types";
  43456. import { Scene } from "babylonjs/scene";
  43457. import { Engine } from "babylonjs/Engines/engine";
  43458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43459. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43460. import { AssetContainer } from "babylonjs/assetContainer";
  43461. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43462. import { Skeleton } from "babylonjs/Bones/skeleton";
  43463. /**
  43464. * Class used to represent data loading progression
  43465. */
  43466. export class SceneLoaderProgressEvent {
  43467. /** defines if data length to load can be evaluated */
  43468. readonly lengthComputable: boolean;
  43469. /** defines the loaded data length */
  43470. readonly loaded: number;
  43471. /** defines the data length to load */
  43472. readonly total: number;
  43473. /**
  43474. * Create a new progress event
  43475. * @param lengthComputable defines if data length to load can be evaluated
  43476. * @param loaded defines the loaded data length
  43477. * @param total defines the data length to load
  43478. */
  43479. constructor(
  43480. /** defines if data length to load can be evaluated */
  43481. lengthComputable: boolean,
  43482. /** defines the loaded data length */
  43483. loaded: number,
  43484. /** defines the data length to load */
  43485. total: number);
  43486. /**
  43487. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43488. * @param event defines the source event
  43489. * @returns a new SceneLoaderProgressEvent
  43490. */
  43491. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43492. }
  43493. /**
  43494. * Interface used by SceneLoader plugins to define supported file extensions
  43495. */
  43496. export interface ISceneLoaderPluginExtensions {
  43497. /**
  43498. * Defines the list of supported extensions
  43499. */
  43500. [extension: string]: {
  43501. isBinary: boolean;
  43502. };
  43503. }
  43504. /**
  43505. * Interface used by SceneLoader plugin factory
  43506. */
  43507. export interface ISceneLoaderPluginFactory {
  43508. /**
  43509. * Defines the name of the factory
  43510. */
  43511. name: string;
  43512. /**
  43513. * Function called to create a new plugin
  43514. * @return the new plugin
  43515. */
  43516. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43517. /**
  43518. * Boolean indicating if the plugin can direct load specific data
  43519. */
  43520. canDirectLoad?: (data: string) => boolean;
  43521. }
  43522. /**
  43523. * Interface used to define a SceneLoader plugin
  43524. */
  43525. export interface ISceneLoaderPlugin {
  43526. /**
  43527. * The friendly name of this plugin.
  43528. */
  43529. name: string;
  43530. /**
  43531. * The file extensions supported by this plugin.
  43532. */
  43533. extensions: string | ISceneLoaderPluginExtensions;
  43534. /**
  43535. * Import meshes into a scene.
  43536. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43537. * @param scene The scene to import into
  43538. * @param data The data to import
  43539. * @param rootUrl The root url for scene and resources
  43540. * @param meshes The meshes array to import into
  43541. * @param particleSystems The particle systems array to import into
  43542. * @param skeletons The skeletons array to import into
  43543. * @param onError The callback when import fails
  43544. * @returns True if successful or false otherwise
  43545. */
  43546. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43547. /**
  43548. * Load into a scene.
  43549. * @param scene The scene to load into
  43550. * @param data The data to import
  43551. * @param rootUrl The root url for scene and resources
  43552. * @param onError The callback when import fails
  43553. * @returns true if successful or false otherwise
  43554. */
  43555. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43556. /**
  43557. * The callback that returns true if the data can be directly loaded.
  43558. */
  43559. canDirectLoad?: (data: string) => boolean;
  43560. /**
  43561. * The callback that allows custom handling of the root url based on the response url.
  43562. */
  43563. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43564. /**
  43565. * Load into an asset container.
  43566. * @param scene The scene to load into
  43567. * @param data The data to import
  43568. * @param rootUrl The root url for scene and resources
  43569. * @param onError The callback when import fails
  43570. * @returns The loaded asset container
  43571. */
  43572. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43573. }
  43574. /**
  43575. * Interface used to define an async SceneLoader plugin
  43576. */
  43577. export interface ISceneLoaderPluginAsync {
  43578. /**
  43579. * The friendly name of this plugin.
  43580. */
  43581. name: string;
  43582. /**
  43583. * The file extensions supported by this plugin.
  43584. */
  43585. extensions: string | ISceneLoaderPluginExtensions;
  43586. /**
  43587. * Import meshes into a scene.
  43588. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43589. * @param scene The scene to import into
  43590. * @param data The data to import
  43591. * @param rootUrl The root url for scene and resources
  43592. * @param onProgress The callback when the load progresses
  43593. * @param fileName Defines the name of the file to load
  43594. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43595. */
  43596. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43597. meshes: AbstractMesh[];
  43598. particleSystems: IParticleSystem[];
  43599. skeletons: Skeleton[];
  43600. animationGroups: AnimationGroup[];
  43601. }>;
  43602. /**
  43603. * Load into a scene.
  43604. * @param scene The scene to load into
  43605. * @param data The data to import
  43606. * @param rootUrl The root url for scene and resources
  43607. * @param onProgress The callback when the load progresses
  43608. * @param fileName Defines the name of the file to load
  43609. * @returns Nothing
  43610. */
  43611. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43612. /**
  43613. * The callback that returns true if the data can be directly loaded.
  43614. */
  43615. canDirectLoad?: (data: string) => boolean;
  43616. /**
  43617. * The callback that allows custom handling of the root url based on the response url.
  43618. */
  43619. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43620. /**
  43621. * Load into an asset container.
  43622. * @param scene The scene to load into
  43623. * @param data The data to import
  43624. * @param rootUrl The root url for scene and resources
  43625. * @param onProgress The callback when the load progresses
  43626. * @param fileName Defines the name of the file to load
  43627. * @returns The loaded asset container
  43628. */
  43629. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43630. }
  43631. /**
  43632. * Class used to load scene from various file formats using registered plugins
  43633. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43634. */
  43635. export class SceneLoader {
  43636. /**
  43637. * No logging while loading
  43638. */
  43639. static readonly NO_LOGGING: number;
  43640. /**
  43641. * Minimal logging while loading
  43642. */
  43643. static readonly MINIMAL_LOGGING: number;
  43644. /**
  43645. * Summary logging while loading
  43646. */
  43647. static readonly SUMMARY_LOGGING: number;
  43648. /**
  43649. * Detailled logging while loading
  43650. */
  43651. static readonly DETAILED_LOGGING: number;
  43652. /**
  43653. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43654. */
  43655. static ForceFullSceneLoadingForIncremental: boolean;
  43656. /**
  43657. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43658. */
  43659. static ShowLoadingScreen: boolean;
  43660. /**
  43661. * Defines the current logging level (while loading the scene)
  43662. * @ignorenaming
  43663. */
  43664. static loggingLevel: number;
  43665. /**
  43666. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43667. */
  43668. static CleanBoneMatrixWeights: boolean;
  43669. /**
  43670. * Event raised when a plugin is used to load a scene
  43671. */
  43672. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43673. private static _registeredPlugins;
  43674. private static _getDefaultPlugin;
  43675. private static _getPluginForExtension;
  43676. private static _getPluginForDirectLoad;
  43677. private static _getPluginForFilename;
  43678. private static _getDirectLoad;
  43679. private static _loadData;
  43680. private static _getFileInfo;
  43681. /**
  43682. * Gets a plugin that can load the given extension
  43683. * @param extension defines the extension to load
  43684. * @returns a plugin or null if none works
  43685. */
  43686. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43687. /**
  43688. * Gets a boolean indicating that the given extension can be loaded
  43689. * @param extension defines the extension to load
  43690. * @returns true if the extension is supported
  43691. */
  43692. static IsPluginForExtensionAvailable(extension: string): boolean;
  43693. /**
  43694. * Adds a new plugin to the list of registered plugins
  43695. * @param plugin defines the plugin to add
  43696. */
  43697. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43698. /**
  43699. * Import meshes into a scene
  43700. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43701. * @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)
  43702. * @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)
  43703. * @param scene the instance of BABYLON.Scene to append to
  43704. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43705. * @param onProgress a callback with a progress event for each file being loaded
  43706. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43707. * @param pluginExtension the extension used to determine the plugin
  43708. * @returns The loaded plugin
  43709. */
  43710. 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>;
  43711. /**
  43712. * Import meshes into a scene
  43713. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43714. * @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)
  43715. * @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)
  43716. * @param scene the instance of BABYLON.Scene to append to
  43717. * @param onProgress a callback with a progress event for each file being loaded
  43718. * @param pluginExtension the extension used to determine the plugin
  43719. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43720. */
  43721. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43722. meshes: AbstractMesh[];
  43723. particleSystems: IParticleSystem[];
  43724. skeletons: Skeleton[];
  43725. animationGroups: AnimationGroup[];
  43726. }>;
  43727. /**
  43728. * Load a scene
  43729. * @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)
  43730. * @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)
  43731. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43732. * @param onSuccess a callback with the scene when import succeeds
  43733. * @param onProgress a callback with a progress event for each file being loaded
  43734. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43735. * @param pluginExtension the extension used to determine the plugin
  43736. * @returns The loaded plugin
  43737. */
  43738. 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>;
  43739. /**
  43740. * Load a scene
  43741. * @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)
  43742. * @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)
  43743. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43744. * @param onProgress a callback with a progress event for each file being loaded
  43745. * @param pluginExtension the extension used to determine the plugin
  43746. * @returns The loaded scene
  43747. */
  43748. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43749. /**
  43750. * Append a scene
  43751. * @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)
  43752. * @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)
  43753. * @param scene is the instance of BABYLON.Scene to append to
  43754. * @param onSuccess a callback with the scene when import succeeds
  43755. * @param onProgress a callback with a progress event for each file being loaded
  43756. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43757. * @param pluginExtension the extension used to determine the plugin
  43758. * @returns The loaded plugin
  43759. */
  43760. 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>;
  43761. /**
  43762. * Append a scene
  43763. * @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)
  43764. * @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)
  43765. * @param scene is the instance of BABYLON.Scene to append to
  43766. * @param onProgress a callback with a progress event for each file being loaded
  43767. * @param pluginExtension the extension used to determine the plugin
  43768. * @returns The given scene
  43769. */
  43770. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43771. /**
  43772. * Load a scene into an asset container
  43773. * @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)
  43774. * @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)
  43775. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43776. * @param onSuccess a callback with the scene when import succeeds
  43777. * @param onProgress a callback with a progress event for each file being loaded
  43778. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43779. * @param pluginExtension the extension used to determine the plugin
  43780. * @returns The loaded plugin
  43781. */
  43782. 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>;
  43783. /**
  43784. * Load a scene into an asset container
  43785. * @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)
  43786. * @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)
  43787. * @param scene is the instance of Scene to append to
  43788. * @param onProgress a callback with a progress event for each file being loaded
  43789. * @param pluginExtension the extension used to determine the plugin
  43790. * @returns The loaded asset container
  43791. */
  43792. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43793. }
  43794. }
  43795. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43796. import { Scene } from "babylonjs/scene";
  43797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43798. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43799. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43800. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43801. /**
  43802. * Google Daydream controller
  43803. */
  43804. export class DaydreamController extends WebVRController {
  43805. /**
  43806. * Base Url for the controller model.
  43807. */
  43808. static MODEL_BASE_URL: string;
  43809. /**
  43810. * File name for the controller model.
  43811. */
  43812. static MODEL_FILENAME: string;
  43813. /**
  43814. * Gamepad Id prefix used to identify Daydream Controller.
  43815. */
  43816. static readonly GAMEPAD_ID_PREFIX: string;
  43817. /**
  43818. * Creates a new DaydreamController from a gamepad
  43819. * @param vrGamepad the gamepad that the controller should be created from
  43820. */
  43821. constructor(vrGamepad: any);
  43822. /**
  43823. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43824. * @param scene scene in which to add meshes
  43825. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43826. */
  43827. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43828. /**
  43829. * Called once for each button that changed state since the last frame
  43830. * @param buttonIdx Which button index changed
  43831. * @param state New state of the button
  43832. * @param changes Which properties on the state changed since last frame
  43833. */
  43834. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43835. }
  43836. }
  43837. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43838. import { Scene } from "babylonjs/scene";
  43839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43840. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43841. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43842. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43843. /**
  43844. * Gear VR Controller
  43845. */
  43846. export class GearVRController extends WebVRController {
  43847. /**
  43848. * Base Url for the controller model.
  43849. */
  43850. static MODEL_BASE_URL: string;
  43851. /**
  43852. * File name for the controller model.
  43853. */
  43854. static MODEL_FILENAME: string;
  43855. /**
  43856. * Gamepad Id prefix used to identify this controller.
  43857. */
  43858. static readonly GAMEPAD_ID_PREFIX: string;
  43859. private readonly _buttonIndexToObservableNameMap;
  43860. /**
  43861. * Creates a new GearVRController from a gamepad
  43862. * @param vrGamepad the gamepad that the controller should be created from
  43863. */
  43864. constructor(vrGamepad: any);
  43865. /**
  43866. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43867. * @param scene scene in which to add meshes
  43868. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43869. */
  43870. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43871. /**
  43872. * Called once for each button that changed state since the last frame
  43873. * @param buttonIdx Which button index changed
  43874. * @param state New state of the button
  43875. * @param changes Which properties on the state changed since last frame
  43876. */
  43877. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43878. }
  43879. }
  43880. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43881. import { Scene } from "babylonjs/scene";
  43882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43883. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43884. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43885. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43886. /**
  43887. * Generic Controller
  43888. */
  43889. export class GenericController extends WebVRController {
  43890. /**
  43891. * Base Url for the controller model.
  43892. */
  43893. static readonly MODEL_BASE_URL: string;
  43894. /**
  43895. * File name for the controller model.
  43896. */
  43897. static readonly MODEL_FILENAME: string;
  43898. /**
  43899. * Creates a new GenericController from a gamepad
  43900. * @param vrGamepad the gamepad that the controller should be created from
  43901. */
  43902. constructor(vrGamepad: any);
  43903. /**
  43904. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43905. * @param scene scene in which to add meshes
  43906. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43907. */
  43908. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43909. /**
  43910. * Called once for each button that changed state since the last frame
  43911. * @param buttonIdx Which button index changed
  43912. * @param state New state of the button
  43913. * @param changes Which properties on the state changed since last frame
  43914. */
  43915. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43916. }
  43917. }
  43918. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43919. import { Observable } from "babylonjs/Misc/observable";
  43920. import { Scene } from "babylonjs/scene";
  43921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43922. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43923. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43924. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43925. /**
  43926. * Oculus Touch Controller
  43927. */
  43928. export class OculusTouchController extends WebVRController {
  43929. /**
  43930. * Base Url for the controller model.
  43931. */
  43932. static MODEL_BASE_URL: string;
  43933. /**
  43934. * File name for the left controller model.
  43935. */
  43936. static MODEL_LEFT_FILENAME: string;
  43937. /**
  43938. * File name for the right controller model.
  43939. */
  43940. static MODEL_RIGHT_FILENAME: string;
  43941. /**
  43942. * Fired when the secondary trigger on this controller is modified
  43943. */
  43944. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43945. /**
  43946. * Fired when the thumb rest on this controller is modified
  43947. */
  43948. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43949. /**
  43950. * Creates a new OculusTouchController from a gamepad
  43951. * @param vrGamepad the gamepad that the controller should be created from
  43952. */
  43953. constructor(vrGamepad: any);
  43954. /**
  43955. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43956. * @param scene scene in which to add meshes
  43957. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43958. */
  43959. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43960. /**
  43961. * Fired when the A button on this controller is modified
  43962. */
  43963. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43964. /**
  43965. * Fired when the B button on this controller is modified
  43966. */
  43967. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43968. /**
  43969. * Fired when the X button on this controller is modified
  43970. */
  43971. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43972. /**
  43973. * Fired when the Y button on this controller is modified
  43974. */
  43975. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43976. /**
  43977. * Called once for each button that changed state since the last frame
  43978. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43979. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43980. * 2) secondary trigger (same)
  43981. * 3) A (right) X (left), touch, pressed = value
  43982. * 4) B / Y
  43983. * 5) thumb rest
  43984. * @param buttonIdx Which button index changed
  43985. * @param state New state of the button
  43986. * @param changes Which properties on the state changed since last frame
  43987. */
  43988. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43989. }
  43990. }
  43991. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43992. import { Scene } from "babylonjs/scene";
  43993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43994. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43995. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43996. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43997. import { Observable } from "babylonjs/Misc/observable";
  43998. /**
  43999. * Vive Controller
  44000. */
  44001. export class ViveController extends WebVRController {
  44002. /**
  44003. * Base Url for the controller model.
  44004. */
  44005. static MODEL_BASE_URL: string;
  44006. /**
  44007. * File name for the controller model.
  44008. */
  44009. static MODEL_FILENAME: string;
  44010. /**
  44011. * Creates a new ViveController from a gamepad
  44012. * @param vrGamepad the gamepad that the controller should be created from
  44013. */
  44014. constructor(vrGamepad: any);
  44015. /**
  44016. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44017. * @param scene scene in which to add meshes
  44018. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44019. */
  44020. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44021. /**
  44022. * Fired when the left button on this controller is modified
  44023. */
  44024. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44025. /**
  44026. * Fired when the right button on this controller is modified
  44027. */
  44028. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44029. /**
  44030. * Fired when the menu button on this controller is modified
  44031. */
  44032. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44033. /**
  44034. * Called once for each button that changed state since the last frame
  44035. * Vive mapping:
  44036. * 0: touchpad
  44037. * 1: trigger
  44038. * 2: left AND right buttons
  44039. * 3: menu button
  44040. * @param buttonIdx Which button index changed
  44041. * @param state New state of the button
  44042. * @param changes Which properties on the state changed since last frame
  44043. */
  44044. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44045. }
  44046. }
  44047. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44048. import { Observable } from "babylonjs/Misc/observable";
  44049. import { Scene } from "babylonjs/scene";
  44050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44051. import { Ray } from "babylonjs/Culling/ray";
  44052. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44053. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44054. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44055. /**
  44056. * Defines the WindowsMotionController object that the state of the windows motion controller
  44057. */
  44058. export class WindowsMotionController extends WebVRController {
  44059. /**
  44060. * The base url used to load the left and right controller models
  44061. */
  44062. static MODEL_BASE_URL: string;
  44063. /**
  44064. * The name of the left controller model file
  44065. */
  44066. static MODEL_LEFT_FILENAME: string;
  44067. /**
  44068. * The name of the right controller model file
  44069. */
  44070. static MODEL_RIGHT_FILENAME: string;
  44071. /**
  44072. * The controller name prefix for this controller type
  44073. */
  44074. static readonly GAMEPAD_ID_PREFIX: string;
  44075. /**
  44076. * The controller id pattern for this controller type
  44077. */
  44078. private static readonly GAMEPAD_ID_PATTERN;
  44079. private _loadedMeshInfo;
  44080. private readonly _mapping;
  44081. /**
  44082. * Fired when the trackpad on this controller is clicked
  44083. */
  44084. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44085. /**
  44086. * Fired when the trackpad on this controller is modified
  44087. */
  44088. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44089. /**
  44090. * The current x and y values of this controller's trackpad
  44091. */
  44092. trackpad: StickValues;
  44093. /**
  44094. * Creates a new WindowsMotionController from a gamepad
  44095. * @param vrGamepad the gamepad that the controller should be created from
  44096. */
  44097. constructor(vrGamepad: any);
  44098. /**
  44099. * Fired when the trigger on this controller is modified
  44100. */
  44101. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44102. /**
  44103. * Fired when the menu button on this controller is modified
  44104. */
  44105. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44106. /**
  44107. * Fired when the grip button on this controller is modified
  44108. */
  44109. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44110. /**
  44111. * Fired when the thumbstick button on this controller is modified
  44112. */
  44113. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44114. /**
  44115. * Fired when the touchpad button on this controller is modified
  44116. */
  44117. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44118. /**
  44119. * Fired when the touchpad values on this controller are modified
  44120. */
  44121. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44122. private _updateTrackpad;
  44123. /**
  44124. * Called once per frame by the engine.
  44125. */
  44126. update(): void;
  44127. /**
  44128. * Called once for each button that changed state since the last frame
  44129. * @param buttonIdx Which button index changed
  44130. * @param state New state of the button
  44131. * @param changes Which properties on the state changed since last frame
  44132. */
  44133. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44134. /**
  44135. * Moves the buttons on the controller mesh based on their current state
  44136. * @param buttonName the name of the button to move
  44137. * @param buttonValue the value of the button which determines the buttons new position
  44138. */
  44139. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44140. /**
  44141. * Moves the axis on the controller mesh based on its current state
  44142. * @param axis the index of the axis
  44143. * @param axisValue the value of the axis which determines the meshes new position
  44144. * @hidden
  44145. */
  44146. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44147. /**
  44148. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44149. * @param scene scene in which to add meshes
  44150. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44151. */
  44152. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44153. /**
  44154. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44155. * can be transformed by button presses and axes values, based on this._mapping.
  44156. *
  44157. * @param scene scene in which the meshes exist
  44158. * @param meshes list of meshes that make up the controller model to process
  44159. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44160. */
  44161. private processModel;
  44162. private createMeshInfo;
  44163. /**
  44164. * Gets the ray of the controller in the direction the controller is pointing
  44165. * @param length the length the resulting ray should be
  44166. * @returns a ray in the direction the controller is pointing
  44167. */
  44168. getForwardRay(length?: number): Ray;
  44169. /**
  44170. * Disposes of the controller
  44171. */
  44172. dispose(): void;
  44173. }
  44174. }
  44175. declare module "babylonjs/Gamepads/Controllers/index" {
  44176. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44177. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44178. export * from "babylonjs/Gamepads/Controllers/genericController";
  44179. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44180. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44181. export * from "babylonjs/Gamepads/Controllers/viveController";
  44182. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44183. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44184. }
  44185. declare module "babylonjs/Gamepads/index" {
  44186. export * from "babylonjs/Gamepads/Controllers/index";
  44187. export * from "babylonjs/Gamepads/gamepad";
  44188. export * from "babylonjs/Gamepads/gamepadManager";
  44189. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44190. export * from "babylonjs/Gamepads/xboxGamepad";
  44191. }
  44192. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44193. import { Observable } from "babylonjs/Misc/observable";
  44194. import { Nullable } from "babylonjs/types";
  44195. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44197. import { Mesh } from "babylonjs/Meshes/mesh";
  44198. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44199. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44200. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44201. /**
  44202. * Single axis scale gizmo
  44203. */
  44204. export class AxisScaleGizmo extends Gizmo {
  44205. private _coloredMaterial;
  44206. /**
  44207. * Drag behavior responsible for the gizmos dragging interactions
  44208. */
  44209. dragBehavior: PointerDragBehavior;
  44210. private _pointerObserver;
  44211. /**
  44212. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44213. */
  44214. snapDistance: number;
  44215. /**
  44216. * Event that fires each time the gizmo snaps to a new location.
  44217. * * snapDistance is the the change in distance
  44218. */
  44219. onSnapObservable: Observable<{
  44220. snapDistance: number;
  44221. }>;
  44222. /**
  44223. * If the scaling operation should be done on all axis (default: false)
  44224. */
  44225. uniformScaling: boolean;
  44226. /**
  44227. * Creates an AxisScaleGizmo
  44228. * @param gizmoLayer The utility layer the gizmo will be added to
  44229. * @param dragAxis The axis which the gizmo will be able to scale on
  44230. * @param color The color of the gizmo
  44231. */
  44232. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44233. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44234. /**
  44235. * Disposes of the gizmo
  44236. */
  44237. dispose(): void;
  44238. /**
  44239. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44240. * @param mesh The mesh to replace the default mesh of the gizmo
  44241. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44242. */
  44243. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44244. }
  44245. }
  44246. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44247. import { Observable } from "babylonjs/Misc/observable";
  44248. import { Nullable } from "babylonjs/types";
  44249. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44251. import { Mesh } from "babylonjs/Meshes/mesh";
  44252. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44253. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44254. import "babylonjs/Meshes/Builders/boxBuilder";
  44255. /**
  44256. * Bounding box gizmo
  44257. */
  44258. export class BoundingBoxGizmo extends Gizmo {
  44259. private _lineBoundingBox;
  44260. private _rotateSpheresParent;
  44261. private _scaleBoxesParent;
  44262. private _boundingDimensions;
  44263. private _renderObserver;
  44264. private _pointerObserver;
  44265. private _scaleDragSpeed;
  44266. private _tmpQuaternion;
  44267. private _tmpVector;
  44268. private _tmpRotationMatrix;
  44269. /**
  44270. * 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)
  44271. */
  44272. ignoreChildren: boolean;
  44273. /**
  44274. * 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)
  44275. */
  44276. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44277. /**
  44278. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44279. */
  44280. rotationSphereSize: number;
  44281. /**
  44282. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44283. */
  44284. scaleBoxSize: number;
  44285. /**
  44286. * 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)
  44287. */
  44288. fixedDragMeshScreenSize: boolean;
  44289. /**
  44290. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44291. */
  44292. fixedDragMeshScreenSizeDistanceFactor: number;
  44293. /**
  44294. * Fired when a rotation sphere or scale box is dragged
  44295. */
  44296. onDragStartObservable: Observable<{}>;
  44297. /**
  44298. * Fired when a scale box is dragged
  44299. */
  44300. onScaleBoxDragObservable: Observable<{}>;
  44301. /**
  44302. * Fired when a scale box drag is ended
  44303. */
  44304. onScaleBoxDragEndObservable: Observable<{}>;
  44305. /**
  44306. * Fired when a rotation sphere is dragged
  44307. */
  44308. onRotationSphereDragObservable: Observable<{}>;
  44309. /**
  44310. * Fired when a rotation sphere drag is ended
  44311. */
  44312. onRotationSphereDragEndObservable: Observable<{}>;
  44313. /**
  44314. * 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)
  44315. */
  44316. scalePivot: Nullable<Vector3>;
  44317. /**
  44318. * Mesh used as a pivot to rotate the attached mesh
  44319. */
  44320. private _anchorMesh;
  44321. private _existingMeshScale;
  44322. private _dragMesh;
  44323. private pointerDragBehavior;
  44324. private coloredMaterial;
  44325. private hoverColoredMaterial;
  44326. /**
  44327. * Sets the color of the bounding box gizmo
  44328. * @param color the color to set
  44329. */
  44330. setColor(color: Color3): void;
  44331. /**
  44332. * Creates an BoundingBoxGizmo
  44333. * @param gizmoLayer The utility layer the gizmo will be added to
  44334. * @param color The color of the gizmo
  44335. */
  44336. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44337. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44338. private _selectNode;
  44339. /**
  44340. * Updates the bounding box information for the Gizmo
  44341. */
  44342. updateBoundingBox(): void;
  44343. private _updateRotationSpheres;
  44344. private _updateScaleBoxes;
  44345. /**
  44346. * Enables rotation on the specified axis and disables rotation on the others
  44347. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44348. */
  44349. setEnabledRotationAxis(axis: string): void;
  44350. /**
  44351. * Enables/disables scaling
  44352. * @param enable if scaling should be enabled
  44353. */
  44354. setEnabledScaling(enable: boolean): void;
  44355. private _updateDummy;
  44356. /**
  44357. * Enables a pointer drag behavior on the bounding box of the gizmo
  44358. */
  44359. enableDragBehavior(): void;
  44360. /**
  44361. * Disposes of the gizmo
  44362. */
  44363. dispose(): void;
  44364. /**
  44365. * 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)
  44366. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44367. * @returns the bounding box mesh with the passed in mesh as a child
  44368. */
  44369. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44370. /**
  44371. * CustomMeshes are not supported by this gizmo
  44372. * @param mesh The mesh to replace the default mesh of the gizmo
  44373. */
  44374. setCustomMesh(mesh: Mesh): void;
  44375. }
  44376. }
  44377. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44378. import { Observable } from "babylonjs/Misc/observable";
  44379. import { Nullable } from "babylonjs/types";
  44380. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44382. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44383. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44384. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44385. import "babylonjs/Meshes/Builders/linesBuilder";
  44386. /**
  44387. * Single plane rotation gizmo
  44388. */
  44389. export class PlaneRotationGizmo extends Gizmo {
  44390. /**
  44391. * Drag behavior responsible for the gizmos dragging interactions
  44392. */
  44393. dragBehavior: PointerDragBehavior;
  44394. private _pointerObserver;
  44395. /**
  44396. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44397. */
  44398. snapDistance: number;
  44399. /**
  44400. * Event that fires each time the gizmo snaps to a new location.
  44401. * * snapDistance is the the change in distance
  44402. */
  44403. onSnapObservable: Observable<{
  44404. snapDistance: number;
  44405. }>;
  44406. /**
  44407. * Creates a PlaneRotationGizmo
  44408. * @param gizmoLayer The utility layer the gizmo will be added to
  44409. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44410. * @param color The color of the gizmo
  44411. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44412. */
  44413. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44414. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44415. /**
  44416. * Disposes of the gizmo
  44417. */
  44418. dispose(): void;
  44419. }
  44420. }
  44421. declare module "babylonjs/Gizmos/rotationGizmo" {
  44422. import { Observable } from "babylonjs/Misc/observable";
  44423. import { Nullable } from "babylonjs/types";
  44424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44425. import { Mesh } from "babylonjs/Meshes/mesh";
  44426. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44427. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44428. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44429. /**
  44430. * Gizmo that enables rotating a mesh along 3 axis
  44431. */
  44432. export class RotationGizmo extends Gizmo {
  44433. /**
  44434. * Internal gizmo used for interactions on the x axis
  44435. */
  44436. xGizmo: PlaneRotationGizmo;
  44437. /**
  44438. * Internal gizmo used for interactions on the y axis
  44439. */
  44440. yGizmo: PlaneRotationGizmo;
  44441. /**
  44442. * Internal gizmo used for interactions on the z axis
  44443. */
  44444. zGizmo: PlaneRotationGizmo;
  44445. /** Fires an event when any of it's sub gizmos are dragged */
  44446. onDragStartObservable: Observable<{}>;
  44447. /** Fires an event when any of it's sub gizmos are released from dragging */
  44448. onDragEndObservable: Observable<{}>;
  44449. attachedMesh: Nullable<AbstractMesh>;
  44450. /**
  44451. * Creates a RotationGizmo
  44452. * @param gizmoLayer The utility layer the gizmo will be added to
  44453. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44454. */
  44455. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44456. updateGizmoRotationToMatchAttachedMesh: boolean;
  44457. /**
  44458. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44459. */
  44460. snapDistance: number;
  44461. /**
  44462. * Ratio for the scale of the gizmo (Default: 1)
  44463. */
  44464. scaleRatio: number;
  44465. /**
  44466. * Disposes of the gizmo
  44467. */
  44468. dispose(): void;
  44469. /**
  44470. * CustomMeshes are not supported by this gizmo
  44471. * @param mesh The mesh to replace the default mesh of the gizmo
  44472. */
  44473. setCustomMesh(mesh: Mesh): void;
  44474. }
  44475. }
  44476. declare module "babylonjs/Gizmos/positionGizmo" {
  44477. import { Observable } from "babylonjs/Misc/observable";
  44478. import { Nullable } from "babylonjs/types";
  44479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44480. import { Mesh } from "babylonjs/Meshes/mesh";
  44481. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44482. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44483. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44484. /**
  44485. * Gizmo that enables dragging a mesh along 3 axis
  44486. */
  44487. export class PositionGizmo extends Gizmo {
  44488. /**
  44489. * Internal gizmo used for interactions on the x axis
  44490. */
  44491. xGizmo: AxisDragGizmo;
  44492. /**
  44493. * Internal gizmo used for interactions on the y axis
  44494. */
  44495. yGizmo: AxisDragGizmo;
  44496. /**
  44497. * Internal gizmo used for interactions on the z axis
  44498. */
  44499. zGizmo: AxisDragGizmo;
  44500. /** Fires an event when any of it's sub gizmos are dragged */
  44501. onDragStartObservable: Observable<{}>;
  44502. /** Fires an event when any of it's sub gizmos are released from dragging */
  44503. onDragEndObservable: Observable<{}>;
  44504. attachedMesh: Nullable<AbstractMesh>;
  44505. /**
  44506. * Creates a PositionGizmo
  44507. * @param gizmoLayer The utility layer the gizmo will be added to
  44508. */
  44509. constructor(gizmoLayer?: UtilityLayerRenderer);
  44510. updateGizmoRotationToMatchAttachedMesh: boolean;
  44511. /**
  44512. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44513. */
  44514. snapDistance: number;
  44515. /**
  44516. * Ratio for the scale of the gizmo (Default: 1)
  44517. */
  44518. scaleRatio: number;
  44519. /**
  44520. * Disposes of the gizmo
  44521. */
  44522. dispose(): void;
  44523. /**
  44524. * CustomMeshes are not supported by this gizmo
  44525. * @param mesh The mesh to replace the default mesh of the gizmo
  44526. */
  44527. setCustomMesh(mesh: Mesh): void;
  44528. }
  44529. }
  44530. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44531. import { Scene } from "babylonjs/scene";
  44532. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44533. import { Mesh } from "babylonjs/Meshes/mesh";
  44534. import { Nullable } from "babylonjs/types";
  44535. /**
  44536. * Class containing static functions to help procedurally build meshes
  44537. */
  44538. export class PolyhedronBuilder {
  44539. /**
  44540. * Creates a polyhedron mesh
  44541. * * 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
  44542. * * The parameter `size` (positive float, default 1) sets the polygon size
  44543. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44544. * * 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`
  44545. * * 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
  44546. * * 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)`)
  44547. * * 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
  44548. * * 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
  44549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44552. * @param name defines the name of the mesh
  44553. * @param options defines the options used to create the mesh
  44554. * @param scene defines the hosting scene
  44555. * @returns the polyhedron mesh
  44556. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44557. */
  44558. static CreatePolyhedron(name: string, options: {
  44559. type?: number;
  44560. size?: number;
  44561. sizeX?: number;
  44562. sizeY?: number;
  44563. sizeZ?: number;
  44564. custom?: any;
  44565. faceUV?: Vector4[];
  44566. faceColors?: Color4[];
  44567. flat?: boolean;
  44568. updatable?: boolean;
  44569. sideOrientation?: number;
  44570. frontUVs?: Vector4;
  44571. backUVs?: Vector4;
  44572. }, scene?: Nullable<Scene>): Mesh;
  44573. }
  44574. }
  44575. declare module "babylonjs/Gizmos/scaleGizmo" {
  44576. import { Observable } from "babylonjs/Misc/observable";
  44577. import { Nullable } from "babylonjs/types";
  44578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44579. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44580. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44581. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44582. /**
  44583. * Gizmo that enables scaling a mesh along 3 axis
  44584. */
  44585. export class ScaleGizmo extends Gizmo {
  44586. /**
  44587. * Internal gizmo used for interactions on the x axis
  44588. */
  44589. xGizmo: AxisScaleGizmo;
  44590. /**
  44591. * Internal gizmo used for interactions on the y axis
  44592. */
  44593. yGizmo: AxisScaleGizmo;
  44594. /**
  44595. * Internal gizmo used for interactions on the z axis
  44596. */
  44597. zGizmo: AxisScaleGizmo;
  44598. /**
  44599. * Internal gizmo used to scale all axis equally
  44600. */
  44601. uniformScaleGizmo: AxisScaleGizmo;
  44602. /** Fires an event when any of it's sub gizmos are dragged */
  44603. onDragStartObservable: Observable<{}>;
  44604. /** Fires an event when any of it's sub gizmos are released from dragging */
  44605. onDragEndObservable: Observable<{}>;
  44606. attachedMesh: Nullable<AbstractMesh>;
  44607. /**
  44608. * Creates a ScaleGizmo
  44609. * @param gizmoLayer The utility layer the gizmo will be added to
  44610. */
  44611. constructor(gizmoLayer?: UtilityLayerRenderer);
  44612. updateGizmoRotationToMatchAttachedMesh: boolean;
  44613. /**
  44614. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44615. */
  44616. snapDistance: number;
  44617. /**
  44618. * Ratio for the scale of the gizmo (Default: 1)
  44619. */
  44620. scaleRatio: number;
  44621. /**
  44622. * Disposes of the gizmo
  44623. */
  44624. dispose(): void;
  44625. }
  44626. }
  44627. declare module "babylonjs/Gizmos/gizmoManager" {
  44628. import { Observable } from "babylonjs/Misc/observable";
  44629. import { Nullable } from "babylonjs/types";
  44630. import { Scene, IDisposable } from "babylonjs/scene";
  44631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44632. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44633. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44634. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44635. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44636. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44637. /**
  44638. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44639. */
  44640. export class GizmoManager implements IDisposable {
  44641. private scene;
  44642. /**
  44643. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44644. */
  44645. gizmos: {
  44646. positionGizmo: Nullable<PositionGizmo>;
  44647. rotationGizmo: Nullable<RotationGizmo>;
  44648. scaleGizmo: Nullable<ScaleGizmo>;
  44649. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44650. };
  44651. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44652. clearGizmoOnEmptyPointerEvent: boolean;
  44653. /** Fires an event when the manager is attached to a mesh */
  44654. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44655. private _gizmosEnabled;
  44656. private _pointerObserver;
  44657. private _attachedMesh;
  44658. private _boundingBoxColor;
  44659. private _defaultUtilityLayer;
  44660. private _defaultKeepDepthUtilityLayer;
  44661. /**
  44662. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44663. */
  44664. boundingBoxDragBehavior: SixDofDragBehavior;
  44665. /**
  44666. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44667. */
  44668. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44669. /**
  44670. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44671. */
  44672. usePointerToAttachGizmos: boolean;
  44673. /**
  44674. * Instatiates a gizmo manager
  44675. * @param scene the scene to overlay the gizmos on top of
  44676. */
  44677. constructor(scene: Scene);
  44678. /**
  44679. * Attaches a set of gizmos to the specified mesh
  44680. * @param mesh The mesh the gizmo's should be attached to
  44681. */
  44682. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44683. /**
  44684. * If the position gizmo is enabled
  44685. */
  44686. positionGizmoEnabled: boolean;
  44687. /**
  44688. * If the rotation gizmo is enabled
  44689. */
  44690. rotationGizmoEnabled: boolean;
  44691. /**
  44692. * If the scale gizmo is enabled
  44693. */
  44694. scaleGizmoEnabled: boolean;
  44695. /**
  44696. * If the boundingBox gizmo is enabled
  44697. */
  44698. boundingBoxGizmoEnabled: boolean;
  44699. /**
  44700. * Disposes of the gizmo manager
  44701. */
  44702. dispose(): void;
  44703. }
  44704. }
  44705. declare module "babylonjs/Lights/directionalLight" {
  44706. import { Camera } from "babylonjs/Cameras/camera";
  44707. import { Scene } from "babylonjs/scene";
  44708. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44710. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44711. import { Effect } from "babylonjs/Materials/effect";
  44712. /**
  44713. * A directional light is defined by a direction (what a surprise!).
  44714. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44715. * 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.
  44716. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44717. */
  44718. export class DirectionalLight extends ShadowLight {
  44719. private _shadowFrustumSize;
  44720. /**
  44721. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44722. */
  44723. /**
  44724. * Specifies a fix frustum size for the shadow generation.
  44725. */
  44726. shadowFrustumSize: number;
  44727. private _shadowOrthoScale;
  44728. /**
  44729. * Gets the shadow projection scale against the optimal computed one.
  44730. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44731. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44732. */
  44733. /**
  44734. * Sets the shadow projection scale against the optimal computed one.
  44735. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44736. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44737. */
  44738. shadowOrthoScale: number;
  44739. /**
  44740. * Automatically compute the projection matrix to best fit (including all the casters)
  44741. * on each frame.
  44742. */
  44743. autoUpdateExtends: boolean;
  44744. private _orthoLeft;
  44745. private _orthoRight;
  44746. private _orthoTop;
  44747. private _orthoBottom;
  44748. /**
  44749. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44750. * The directional light is emitted from everywhere in the given direction.
  44751. * It can cast shadows.
  44752. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44753. * @param name The friendly name of the light
  44754. * @param direction The direction of the light
  44755. * @param scene The scene the light belongs to
  44756. */
  44757. constructor(name: string, direction: Vector3, scene: Scene);
  44758. /**
  44759. * Returns the string "DirectionalLight".
  44760. * @return The class name
  44761. */
  44762. getClassName(): string;
  44763. /**
  44764. * Returns the integer 1.
  44765. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44766. */
  44767. getTypeID(): number;
  44768. /**
  44769. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44770. * Returns the DirectionalLight Shadow projection matrix.
  44771. */
  44772. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44773. /**
  44774. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44775. * Returns the DirectionalLight Shadow projection matrix.
  44776. */
  44777. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44778. /**
  44779. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44780. * Returns the DirectionalLight Shadow projection matrix.
  44781. */
  44782. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44783. protected _buildUniformLayout(): void;
  44784. /**
  44785. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44786. * @param effect The effect to update
  44787. * @param lightIndex The index of the light in the effect to update
  44788. * @returns The directional light
  44789. */
  44790. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44791. /**
  44792. * Gets the minZ used for shadow according to both the scene and the light.
  44793. *
  44794. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44795. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44796. * @param activeCamera The camera we are returning the min for
  44797. * @returns the depth min z
  44798. */
  44799. getDepthMinZ(activeCamera: Camera): number;
  44800. /**
  44801. * Gets the maxZ used for shadow according to both the scene and the light.
  44802. *
  44803. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44804. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44805. * @param activeCamera The camera we are returning the max for
  44806. * @returns the depth max z
  44807. */
  44808. getDepthMaxZ(activeCamera: Camera): number;
  44809. /**
  44810. * Prepares the list of defines specific to the light type.
  44811. * @param defines the list of defines
  44812. * @param lightIndex defines the index of the light for the effect
  44813. */
  44814. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44815. }
  44816. }
  44817. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44818. import { Mesh } from "babylonjs/Meshes/mesh";
  44819. /**
  44820. * Class containing static functions to help procedurally build meshes
  44821. */
  44822. export class HemisphereBuilder {
  44823. /**
  44824. * Creates a hemisphere mesh
  44825. * @param name defines the name of the mesh
  44826. * @param options defines the options used to create the mesh
  44827. * @param scene defines the hosting scene
  44828. * @returns the hemisphere mesh
  44829. */
  44830. static CreateHemisphere(name: string, options: {
  44831. segments?: number;
  44832. diameter?: number;
  44833. sideOrientation?: number;
  44834. }, scene: any): Mesh;
  44835. }
  44836. }
  44837. declare module "babylonjs/Lights/spotLight" {
  44838. import { Nullable } from "babylonjs/types";
  44839. import { Scene } from "babylonjs/scene";
  44840. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44842. import { Effect } from "babylonjs/Materials/effect";
  44843. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44844. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44845. /**
  44846. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44847. * These values define a cone of light starting from the position, emitting toward the direction.
  44848. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44849. * and the exponent defines the speed of the decay of the light with distance (reach).
  44850. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44851. */
  44852. export class SpotLight extends ShadowLight {
  44853. private _angle;
  44854. private _innerAngle;
  44855. private _cosHalfAngle;
  44856. private _lightAngleScale;
  44857. private _lightAngleOffset;
  44858. /**
  44859. * Gets the cone angle of the spot light in Radians.
  44860. */
  44861. /**
  44862. * Sets the cone angle of the spot light in Radians.
  44863. */
  44864. angle: number;
  44865. /**
  44866. * Only used in gltf falloff mode, this defines the angle where
  44867. * the directional falloff will start before cutting at angle which could be seen
  44868. * as outer angle.
  44869. */
  44870. /**
  44871. * Only used in gltf falloff mode, this defines the angle where
  44872. * the directional falloff will start before cutting at angle which could be seen
  44873. * as outer angle.
  44874. */
  44875. innerAngle: number;
  44876. private _shadowAngleScale;
  44877. /**
  44878. * Allows scaling the angle of the light for shadow generation only.
  44879. */
  44880. /**
  44881. * Allows scaling the angle of the light for shadow generation only.
  44882. */
  44883. shadowAngleScale: number;
  44884. /**
  44885. * The light decay speed with the distance from the emission spot.
  44886. */
  44887. exponent: number;
  44888. private _projectionTextureMatrix;
  44889. /**
  44890. * Allows reading the projecton texture
  44891. */
  44892. readonly projectionTextureMatrix: Matrix;
  44893. protected _projectionTextureLightNear: number;
  44894. /**
  44895. * Gets the near clip of the Spotlight for texture projection.
  44896. */
  44897. /**
  44898. * Sets the near clip of the Spotlight for texture projection.
  44899. */
  44900. projectionTextureLightNear: number;
  44901. protected _projectionTextureLightFar: number;
  44902. /**
  44903. * Gets the far clip of the Spotlight for texture projection.
  44904. */
  44905. /**
  44906. * Sets the far clip of the Spotlight for texture projection.
  44907. */
  44908. projectionTextureLightFar: number;
  44909. protected _projectionTextureUpDirection: Vector3;
  44910. /**
  44911. * Gets the Up vector of the Spotlight for texture projection.
  44912. */
  44913. /**
  44914. * Sets the Up vector of the Spotlight for texture projection.
  44915. */
  44916. projectionTextureUpDirection: Vector3;
  44917. private _projectionTexture;
  44918. /**
  44919. * Gets the projection texture of the light.
  44920. */
  44921. /**
  44922. * Sets the projection texture of the light.
  44923. */
  44924. projectionTexture: Nullable<BaseTexture>;
  44925. private _projectionTextureViewLightDirty;
  44926. private _projectionTextureProjectionLightDirty;
  44927. private _projectionTextureDirty;
  44928. private _projectionTextureViewTargetVector;
  44929. private _projectionTextureViewLightMatrix;
  44930. private _projectionTextureProjectionLightMatrix;
  44931. private _projectionTextureScalingMatrix;
  44932. /**
  44933. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44934. * It can cast shadows.
  44935. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44936. * @param name The light friendly name
  44937. * @param position The position of the spot light in the scene
  44938. * @param direction The direction of the light in the scene
  44939. * @param angle The cone angle of the light in Radians
  44940. * @param exponent The light decay speed with the distance from the emission spot
  44941. * @param scene The scene the lights belongs to
  44942. */
  44943. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44944. /**
  44945. * Returns the string "SpotLight".
  44946. * @returns the class name
  44947. */
  44948. getClassName(): string;
  44949. /**
  44950. * Returns the integer 2.
  44951. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44952. */
  44953. getTypeID(): number;
  44954. /**
  44955. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44956. */
  44957. protected _setDirection(value: Vector3): void;
  44958. /**
  44959. * Overrides the position setter to recompute the projection texture view light Matrix.
  44960. */
  44961. protected _setPosition(value: Vector3): void;
  44962. /**
  44963. * 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.
  44964. * Returns the SpotLight.
  44965. */
  44966. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44967. protected _computeProjectionTextureViewLightMatrix(): void;
  44968. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44969. /**
  44970. * Main function for light texture projection matrix computing.
  44971. */
  44972. protected _computeProjectionTextureMatrix(): void;
  44973. protected _buildUniformLayout(): void;
  44974. private _computeAngleValues;
  44975. /**
  44976. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44977. * @param effect The effect to update
  44978. * @param lightIndex The index of the light in the effect to update
  44979. * @returns The spot light
  44980. */
  44981. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44982. /**
  44983. * Disposes the light and the associated resources.
  44984. */
  44985. dispose(): void;
  44986. /**
  44987. * Prepares the list of defines specific to the light type.
  44988. * @param defines the list of defines
  44989. * @param lightIndex defines the index of the light for the effect
  44990. */
  44991. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44992. }
  44993. }
  44994. declare module "babylonjs/Gizmos/lightGizmo" {
  44995. import { Nullable } from "babylonjs/types";
  44996. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44997. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44998. import { Light } from "babylonjs/Lights/light";
  44999. /**
  45000. * Gizmo that enables viewing a light
  45001. */
  45002. export class LightGizmo extends Gizmo {
  45003. private _lightMesh;
  45004. private _material;
  45005. private cachedPosition;
  45006. private cachedForward;
  45007. /**
  45008. * Creates a LightGizmo
  45009. * @param gizmoLayer The utility layer the gizmo will be added to
  45010. */
  45011. constructor(gizmoLayer?: UtilityLayerRenderer);
  45012. private _light;
  45013. /**
  45014. * The light that the gizmo is attached to
  45015. */
  45016. light: Nullable<Light>;
  45017. /**
  45018. * @hidden
  45019. * Updates the gizmo to match the attached mesh's position/rotation
  45020. */
  45021. protected _update(): void;
  45022. private static _Scale;
  45023. /**
  45024. * Creates the lines for a light mesh
  45025. */
  45026. private static _createLightLines;
  45027. /**
  45028. * Disposes of the light gizmo
  45029. */
  45030. dispose(): void;
  45031. private static _CreateHemisphericLightMesh;
  45032. private static _CreatePointLightMesh;
  45033. private static _CreateSpotLightMesh;
  45034. private static _CreateDirectionalLightMesh;
  45035. }
  45036. }
  45037. declare module "babylonjs/Gizmos/index" {
  45038. export * from "babylonjs/Gizmos/axisDragGizmo";
  45039. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45040. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45041. export * from "babylonjs/Gizmos/gizmo";
  45042. export * from "babylonjs/Gizmos/gizmoManager";
  45043. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45044. export * from "babylonjs/Gizmos/positionGizmo";
  45045. export * from "babylonjs/Gizmos/rotationGizmo";
  45046. export * from "babylonjs/Gizmos/scaleGizmo";
  45047. export * from "babylonjs/Gizmos/lightGizmo";
  45048. }
  45049. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45050. /** @hidden */
  45051. export var backgroundFragmentDeclaration: {
  45052. name: string;
  45053. shader: string;
  45054. };
  45055. }
  45056. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45057. /** @hidden */
  45058. export var backgroundUboDeclaration: {
  45059. name: string;
  45060. shader: string;
  45061. };
  45062. }
  45063. declare module "babylonjs/Shaders/background.fragment" {
  45064. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45065. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45066. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45067. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45068. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45069. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45070. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45071. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45072. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45073. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45074. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45075. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45076. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45077. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45078. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45079. /** @hidden */
  45080. export var backgroundPixelShader: {
  45081. name: string;
  45082. shader: string;
  45083. };
  45084. }
  45085. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45086. /** @hidden */
  45087. export var backgroundVertexDeclaration: {
  45088. name: string;
  45089. shader: string;
  45090. };
  45091. }
  45092. declare module "babylonjs/Shaders/background.vertex" {
  45093. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45094. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45095. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45096. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45097. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45098. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45099. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45100. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45101. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45102. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45103. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45104. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45105. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45106. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45107. /** @hidden */
  45108. export var backgroundVertexShader: {
  45109. name: string;
  45110. shader: string;
  45111. };
  45112. }
  45113. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45114. import { Nullable, int, float } from "babylonjs/types";
  45115. import { Scene } from "babylonjs/scene";
  45116. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45117. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45119. import { Mesh } from "babylonjs/Meshes/mesh";
  45120. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45121. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45122. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45123. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45124. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45125. import "babylonjs/Shaders/background.fragment";
  45126. import "babylonjs/Shaders/background.vertex";
  45127. /**
  45128. * Background material used to create an efficient environement around your scene.
  45129. */
  45130. export class BackgroundMaterial extends PushMaterial {
  45131. /**
  45132. * Standard reflectance value at parallel view angle.
  45133. */
  45134. static StandardReflectance0: number;
  45135. /**
  45136. * Standard reflectance value at grazing angle.
  45137. */
  45138. static StandardReflectance90: number;
  45139. protected _primaryColor: Color3;
  45140. /**
  45141. * Key light Color (multiply against the environement texture)
  45142. */
  45143. primaryColor: Color3;
  45144. protected __perceptualColor: Nullable<Color3>;
  45145. /**
  45146. * Experimental Internal Use Only.
  45147. *
  45148. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45149. * This acts as a helper to set the primary color to a more "human friendly" value.
  45150. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45151. * output color as close as possible from the chosen value.
  45152. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45153. * part of lighting setup.)
  45154. */
  45155. _perceptualColor: Nullable<Color3>;
  45156. protected _primaryColorShadowLevel: float;
  45157. /**
  45158. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45159. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45160. */
  45161. primaryColorShadowLevel: float;
  45162. protected _primaryColorHighlightLevel: float;
  45163. /**
  45164. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45165. * The primary color is used at the level chosen to define what the white area would look.
  45166. */
  45167. primaryColorHighlightLevel: float;
  45168. protected _reflectionTexture: Nullable<BaseTexture>;
  45169. /**
  45170. * Reflection Texture used in the material.
  45171. * Should be author in a specific way for the best result (refer to the documentation).
  45172. */
  45173. reflectionTexture: Nullable<BaseTexture>;
  45174. protected _reflectionBlur: float;
  45175. /**
  45176. * Reflection Texture level of blur.
  45177. *
  45178. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45179. * texture twice.
  45180. */
  45181. reflectionBlur: float;
  45182. protected _diffuseTexture: Nullable<BaseTexture>;
  45183. /**
  45184. * Diffuse Texture used in the material.
  45185. * Should be author in a specific way for the best result (refer to the documentation).
  45186. */
  45187. diffuseTexture: Nullable<BaseTexture>;
  45188. protected _shadowLights: Nullable<IShadowLight[]>;
  45189. /**
  45190. * Specify the list of lights casting shadow on the material.
  45191. * All scene shadow lights will be included if null.
  45192. */
  45193. shadowLights: Nullable<IShadowLight[]>;
  45194. protected _shadowLevel: float;
  45195. /**
  45196. * Helps adjusting the shadow to a softer level if required.
  45197. * 0 means black shadows and 1 means no shadows.
  45198. */
  45199. shadowLevel: float;
  45200. protected _sceneCenter: Vector3;
  45201. /**
  45202. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45203. * It is usually zero but might be interesting to modify according to your setup.
  45204. */
  45205. sceneCenter: Vector3;
  45206. protected _opacityFresnel: boolean;
  45207. /**
  45208. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45209. * This helps ensuring a nice transition when the camera goes under the ground.
  45210. */
  45211. opacityFresnel: boolean;
  45212. protected _reflectionFresnel: boolean;
  45213. /**
  45214. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45215. * This helps adding a mirror texture on the ground.
  45216. */
  45217. reflectionFresnel: boolean;
  45218. protected _reflectionFalloffDistance: number;
  45219. /**
  45220. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45221. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45222. */
  45223. reflectionFalloffDistance: number;
  45224. protected _reflectionAmount: number;
  45225. /**
  45226. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45227. */
  45228. reflectionAmount: number;
  45229. protected _reflectionReflectance0: number;
  45230. /**
  45231. * This specifies the weight of the reflection at grazing angle.
  45232. */
  45233. reflectionReflectance0: number;
  45234. protected _reflectionReflectance90: number;
  45235. /**
  45236. * This specifies the weight of the reflection at a perpendicular point of view.
  45237. */
  45238. reflectionReflectance90: number;
  45239. /**
  45240. * Sets the reflection reflectance fresnel values according to the default standard
  45241. * empirically know to work well :-)
  45242. */
  45243. reflectionStandardFresnelWeight: number;
  45244. protected _useRGBColor: boolean;
  45245. /**
  45246. * Helps to directly use the maps channels instead of their level.
  45247. */
  45248. useRGBColor: boolean;
  45249. protected _enableNoise: boolean;
  45250. /**
  45251. * This helps reducing the banding effect that could occur on the background.
  45252. */
  45253. enableNoise: boolean;
  45254. /**
  45255. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45256. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45257. * Recommended to be keep at 1.0 except for special cases.
  45258. */
  45259. fovMultiplier: number;
  45260. private _fovMultiplier;
  45261. /**
  45262. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45263. */
  45264. useEquirectangularFOV: boolean;
  45265. private _maxSimultaneousLights;
  45266. /**
  45267. * Number of Simultaneous lights allowed on the material.
  45268. */
  45269. maxSimultaneousLights: int;
  45270. /**
  45271. * Default configuration related to image processing available in the Background Material.
  45272. */
  45273. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45274. /**
  45275. * Keep track of the image processing observer to allow dispose and replace.
  45276. */
  45277. private _imageProcessingObserver;
  45278. /**
  45279. * Attaches a new image processing configuration to the PBR Material.
  45280. * @param configuration (if null the scene configuration will be use)
  45281. */
  45282. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45283. /**
  45284. * Gets the image processing configuration used either in this material.
  45285. */
  45286. /**
  45287. * Sets the Default image processing configuration used either in the this material.
  45288. *
  45289. * If sets to null, the scene one is in use.
  45290. */
  45291. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45292. /**
  45293. * Gets wether the color curves effect is enabled.
  45294. */
  45295. /**
  45296. * Sets wether the color curves effect is enabled.
  45297. */
  45298. cameraColorCurvesEnabled: boolean;
  45299. /**
  45300. * Gets wether the color grading effect is enabled.
  45301. */
  45302. /**
  45303. * Gets wether the color grading effect is enabled.
  45304. */
  45305. cameraColorGradingEnabled: boolean;
  45306. /**
  45307. * Gets wether tonemapping is enabled or not.
  45308. */
  45309. /**
  45310. * Sets wether tonemapping is enabled or not
  45311. */
  45312. cameraToneMappingEnabled: boolean;
  45313. /**
  45314. * The camera exposure used on this material.
  45315. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45316. * This corresponds to a photographic exposure.
  45317. */
  45318. /**
  45319. * The camera exposure used on this material.
  45320. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45321. * This corresponds to a photographic exposure.
  45322. */
  45323. cameraExposure: float;
  45324. /**
  45325. * Gets The camera contrast used on this material.
  45326. */
  45327. /**
  45328. * Sets The camera contrast used on this material.
  45329. */
  45330. cameraContrast: float;
  45331. /**
  45332. * Gets the Color Grading 2D Lookup Texture.
  45333. */
  45334. /**
  45335. * Sets the Color Grading 2D Lookup Texture.
  45336. */
  45337. cameraColorGradingTexture: Nullable<BaseTexture>;
  45338. /**
  45339. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45340. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45341. * 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;
  45342. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45343. */
  45344. /**
  45345. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45346. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45347. * 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;
  45348. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45349. */
  45350. cameraColorCurves: Nullable<ColorCurves>;
  45351. /**
  45352. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45353. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45354. */
  45355. switchToBGR: boolean;
  45356. private _renderTargets;
  45357. private _reflectionControls;
  45358. private _white;
  45359. private _primaryShadowColor;
  45360. private _primaryHighlightColor;
  45361. /**
  45362. * Instantiates a Background Material in the given scene
  45363. * @param name The friendly name of the material
  45364. * @param scene The scene to add the material to
  45365. */
  45366. constructor(name: string, scene: Scene);
  45367. /**
  45368. * Gets a boolean indicating that current material needs to register RTT
  45369. */
  45370. readonly hasRenderTargetTextures: boolean;
  45371. /**
  45372. * The entire material has been created in order to prevent overdraw.
  45373. * @returns false
  45374. */
  45375. needAlphaTesting(): boolean;
  45376. /**
  45377. * The entire material has been created in order to prevent overdraw.
  45378. * @returns true if blending is enable
  45379. */
  45380. needAlphaBlending(): boolean;
  45381. /**
  45382. * Checks wether the material is ready to be rendered for a given mesh.
  45383. * @param mesh The mesh to render
  45384. * @param subMesh The submesh to check against
  45385. * @param useInstances Specify wether or not the material is used with instances
  45386. * @returns true if all the dependencies are ready (Textures, Effects...)
  45387. */
  45388. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45389. /**
  45390. * Compute the primary color according to the chosen perceptual color.
  45391. */
  45392. private _computePrimaryColorFromPerceptualColor;
  45393. /**
  45394. * Compute the highlights and shadow colors according to their chosen levels.
  45395. */
  45396. private _computePrimaryColors;
  45397. /**
  45398. * Build the uniform buffer used in the material.
  45399. */
  45400. buildUniformLayout(): void;
  45401. /**
  45402. * Unbind the material.
  45403. */
  45404. unbind(): void;
  45405. /**
  45406. * Bind only the world matrix to the material.
  45407. * @param world The world matrix to bind.
  45408. */
  45409. bindOnlyWorldMatrix(world: Matrix): void;
  45410. /**
  45411. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45412. * @param world The world matrix to bind.
  45413. * @param subMesh The submesh to bind for.
  45414. */
  45415. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45416. /**
  45417. * Dispose the material.
  45418. * @param forceDisposeEffect Force disposal of the associated effect.
  45419. * @param forceDisposeTextures Force disposal of the associated textures.
  45420. */
  45421. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45422. /**
  45423. * Clones the material.
  45424. * @param name The cloned name.
  45425. * @returns The cloned material.
  45426. */
  45427. clone(name: string): BackgroundMaterial;
  45428. /**
  45429. * Serializes the current material to its JSON representation.
  45430. * @returns The JSON representation.
  45431. */
  45432. serialize(): any;
  45433. /**
  45434. * Gets the class name of the material
  45435. * @returns "BackgroundMaterial"
  45436. */
  45437. getClassName(): string;
  45438. /**
  45439. * Parse a JSON input to create back a background material.
  45440. * @param source The JSON data to parse
  45441. * @param scene The scene to create the parsed material in
  45442. * @param rootUrl The root url of the assets the material depends upon
  45443. * @returns the instantiated BackgroundMaterial.
  45444. */
  45445. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45446. }
  45447. }
  45448. declare module "babylonjs/Helpers/environmentHelper" {
  45449. import { Observable } from "babylonjs/Misc/observable";
  45450. import { Nullable } from "babylonjs/types";
  45451. import { Scene } from "babylonjs/scene";
  45452. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45454. import { Mesh } from "babylonjs/Meshes/mesh";
  45455. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45456. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45457. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45458. import "babylonjs/Meshes/Builders/planeBuilder";
  45459. import "babylonjs/Meshes/Builders/boxBuilder";
  45460. /**
  45461. * Represents the different options available during the creation of
  45462. * a Environment helper.
  45463. *
  45464. * This can control the default ground, skybox and image processing setup of your scene.
  45465. */
  45466. export interface IEnvironmentHelperOptions {
  45467. /**
  45468. * Specifies wether or not to create a ground.
  45469. * True by default.
  45470. */
  45471. createGround: boolean;
  45472. /**
  45473. * Specifies the ground size.
  45474. * 15 by default.
  45475. */
  45476. groundSize: number;
  45477. /**
  45478. * The texture used on the ground for the main color.
  45479. * Comes from the BabylonJS CDN by default.
  45480. *
  45481. * Remarks: Can be either a texture or a url.
  45482. */
  45483. groundTexture: string | BaseTexture;
  45484. /**
  45485. * The color mixed in the ground texture by default.
  45486. * BabylonJS clearColor by default.
  45487. */
  45488. groundColor: Color3;
  45489. /**
  45490. * Specifies the ground opacity.
  45491. * 1 by default.
  45492. */
  45493. groundOpacity: number;
  45494. /**
  45495. * Enables the ground to receive shadows.
  45496. * True by default.
  45497. */
  45498. enableGroundShadow: boolean;
  45499. /**
  45500. * Helps preventing the shadow to be fully black on the ground.
  45501. * 0.5 by default.
  45502. */
  45503. groundShadowLevel: number;
  45504. /**
  45505. * Creates a mirror texture attach to the ground.
  45506. * false by default.
  45507. */
  45508. enableGroundMirror: boolean;
  45509. /**
  45510. * Specifies the ground mirror size ratio.
  45511. * 0.3 by default as the default kernel is 64.
  45512. */
  45513. groundMirrorSizeRatio: number;
  45514. /**
  45515. * Specifies the ground mirror blur kernel size.
  45516. * 64 by default.
  45517. */
  45518. groundMirrorBlurKernel: number;
  45519. /**
  45520. * Specifies the ground mirror visibility amount.
  45521. * 1 by default
  45522. */
  45523. groundMirrorAmount: number;
  45524. /**
  45525. * Specifies the ground mirror reflectance weight.
  45526. * This uses the standard weight of the background material to setup the fresnel effect
  45527. * of the mirror.
  45528. * 1 by default.
  45529. */
  45530. groundMirrorFresnelWeight: number;
  45531. /**
  45532. * Specifies the ground mirror Falloff distance.
  45533. * This can helps reducing the size of the reflection.
  45534. * 0 by Default.
  45535. */
  45536. groundMirrorFallOffDistance: number;
  45537. /**
  45538. * Specifies the ground mirror texture type.
  45539. * Unsigned Int by Default.
  45540. */
  45541. groundMirrorTextureType: number;
  45542. /**
  45543. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45544. * the shown objects.
  45545. */
  45546. groundYBias: number;
  45547. /**
  45548. * Specifies wether or not to create a skybox.
  45549. * True by default.
  45550. */
  45551. createSkybox: boolean;
  45552. /**
  45553. * Specifies the skybox size.
  45554. * 20 by default.
  45555. */
  45556. skyboxSize: number;
  45557. /**
  45558. * The texture used on the skybox for the main color.
  45559. * Comes from the BabylonJS CDN by default.
  45560. *
  45561. * Remarks: Can be either a texture or a url.
  45562. */
  45563. skyboxTexture: string | BaseTexture;
  45564. /**
  45565. * The color mixed in the skybox texture by default.
  45566. * BabylonJS clearColor by default.
  45567. */
  45568. skyboxColor: Color3;
  45569. /**
  45570. * The background rotation around the Y axis of the scene.
  45571. * This helps aligning the key lights of your scene with the background.
  45572. * 0 by default.
  45573. */
  45574. backgroundYRotation: number;
  45575. /**
  45576. * Compute automatically the size of the elements to best fit with the scene.
  45577. */
  45578. sizeAuto: boolean;
  45579. /**
  45580. * Default position of the rootMesh if autoSize is not true.
  45581. */
  45582. rootPosition: Vector3;
  45583. /**
  45584. * Sets up the image processing in the scene.
  45585. * true by default.
  45586. */
  45587. setupImageProcessing: boolean;
  45588. /**
  45589. * The texture used as your environment texture in the scene.
  45590. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45591. *
  45592. * Remarks: Can be either a texture or a url.
  45593. */
  45594. environmentTexture: string | BaseTexture;
  45595. /**
  45596. * The value of the exposure to apply to the scene.
  45597. * 0.6 by default if setupImageProcessing is true.
  45598. */
  45599. cameraExposure: number;
  45600. /**
  45601. * The value of the contrast to apply to the scene.
  45602. * 1.6 by default if setupImageProcessing is true.
  45603. */
  45604. cameraContrast: number;
  45605. /**
  45606. * Specifies wether or not tonemapping should be enabled in the scene.
  45607. * true by default if setupImageProcessing is true.
  45608. */
  45609. toneMappingEnabled: boolean;
  45610. }
  45611. /**
  45612. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45613. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45614. * It also helps with the default setup of your imageProcessing configuration.
  45615. */
  45616. export class EnvironmentHelper {
  45617. /**
  45618. * Default ground texture URL.
  45619. */
  45620. private static _groundTextureCDNUrl;
  45621. /**
  45622. * Default skybox texture URL.
  45623. */
  45624. private static _skyboxTextureCDNUrl;
  45625. /**
  45626. * Default environment texture URL.
  45627. */
  45628. private static _environmentTextureCDNUrl;
  45629. /**
  45630. * Creates the default options for the helper.
  45631. */
  45632. private static _getDefaultOptions;
  45633. private _rootMesh;
  45634. /**
  45635. * Gets the root mesh created by the helper.
  45636. */
  45637. readonly rootMesh: Mesh;
  45638. private _skybox;
  45639. /**
  45640. * Gets the skybox created by the helper.
  45641. */
  45642. readonly skybox: Nullable<Mesh>;
  45643. private _skyboxTexture;
  45644. /**
  45645. * Gets the skybox texture created by the helper.
  45646. */
  45647. readonly skyboxTexture: Nullable<BaseTexture>;
  45648. private _skyboxMaterial;
  45649. /**
  45650. * Gets the skybox material created by the helper.
  45651. */
  45652. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45653. private _ground;
  45654. /**
  45655. * Gets the ground mesh created by the helper.
  45656. */
  45657. readonly ground: Nullable<Mesh>;
  45658. private _groundTexture;
  45659. /**
  45660. * Gets the ground texture created by the helper.
  45661. */
  45662. readonly groundTexture: Nullable<BaseTexture>;
  45663. private _groundMirror;
  45664. /**
  45665. * Gets the ground mirror created by the helper.
  45666. */
  45667. readonly groundMirror: Nullable<MirrorTexture>;
  45668. /**
  45669. * Gets the ground mirror render list to helps pushing the meshes
  45670. * you wish in the ground reflection.
  45671. */
  45672. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45673. private _groundMaterial;
  45674. /**
  45675. * Gets the ground material created by the helper.
  45676. */
  45677. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45678. /**
  45679. * Stores the creation options.
  45680. */
  45681. private readonly _scene;
  45682. private _options;
  45683. /**
  45684. * This observable will be notified with any error during the creation of the environment,
  45685. * mainly texture creation errors.
  45686. */
  45687. onErrorObservable: Observable<{
  45688. message?: string;
  45689. exception?: any;
  45690. }>;
  45691. /**
  45692. * constructor
  45693. * @param options Defines the options we want to customize the helper
  45694. * @param scene The scene to add the material to
  45695. */
  45696. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45697. /**
  45698. * Updates the background according to the new options
  45699. * @param options
  45700. */
  45701. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45702. /**
  45703. * Sets the primary color of all the available elements.
  45704. * @param color the main color to affect to the ground and the background
  45705. */
  45706. setMainColor(color: Color3): void;
  45707. /**
  45708. * Setup the image processing according to the specified options.
  45709. */
  45710. private _setupImageProcessing;
  45711. /**
  45712. * Setup the environment texture according to the specified options.
  45713. */
  45714. private _setupEnvironmentTexture;
  45715. /**
  45716. * Setup the background according to the specified options.
  45717. */
  45718. private _setupBackground;
  45719. /**
  45720. * Get the scene sizes according to the setup.
  45721. */
  45722. private _getSceneSize;
  45723. /**
  45724. * Setup the ground according to the specified options.
  45725. */
  45726. private _setupGround;
  45727. /**
  45728. * Setup the ground material according to the specified options.
  45729. */
  45730. private _setupGroundMaterial;
  45731. /**
  45732. * Setup the ground diffuse texture according to the specified options.
  45733. */
  45734. private _setupGroundDiffuseTexture;
  45735. /**
  45736. * Setup the ground mirror texture according to the specified options.
  45737. */
  45738. private _setupGroundMirrorTexture;
  45739. /**
  45740. * Setup the ground to receive the mirror texture.
  45741. */
  45742. private _setupMirrorInGroundMaterial;
  45743. /**
  45744. * Setup the skybox according to the specified options.
  45745. */
  45746. private _setupSkybox;
  45747. /**
  45748. * Setup the skybox material according to the specified options.
  45749. */
  45750. private _setupSkyboxMaterial;
  45751. /**
  45752. * Setup the skybox reflection texture according to the specified options.
  45753. */
  45754. private _setupSkyboxReflectionTexture;
  45755. private _errorHandler;
  45756. /**
  45757. * Dispose all the elements created by the Helper.
  45758. */
  45759. dispose(): void;
  45760. }
  45761. }
  45762. declare module "babylonjs/Helpers/photoDome" {
  45763. import { Observable } from "babylonjs/Misc/observable";
  45764. import { Nullable } from "babylonjs/types";
  45765. import { Scene } from "babylonjs/scene";
  45766. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45767. import { Mesh } from "babylonjs/Meshes/mesh";
  45768. import { Texture } from "babylonjs/Materials/Textures/texture";
  45769. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45770. import "babylonjs/Meshes/Builders/sphereBuilder";
  45771. /**
  45772. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45773. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45774. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45775. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45776. */
  45777. export class PhotoDome extends TransformNode {
  45778. private _useDirectMapping;
  45779. /**
  45780. * The texture being displayed on the sphere
  45781. */
  45782. protected _photoTexture: Texture;
  45783. /**
  45784. * Gets or sets the texture being displayed on the sphere
  45785. */
  45786. photoTexture: Texture;
  45787. /**
  45788. * Observable raised when an error occured while loading the 360 image
  45789. */
  45790. onLoadErrorObservable: Observable<string>;
  45791. /**
  45792. * The skybox material
  45793. */
  45794. protected _material: BackgroundMaterial;
  45795. /**
  45796. * The surface used for the skybox
  45797. */
  45798. protected _mesh: Mesh;
  45799. /**
  45800. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45801. * Also see the options.resolution property.
  45802. */
  45803. fovMultiplier: number;
  45804. /**
  45805. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45806. * @param name Element's name, child elements will append suffixes for their own names.
  45807. * @param urlsOfPhoto defines the url of the photo to display
  45808. * @param options defines an object containing optional or exposed sub element properties
  45809. * @param onError defines a callback called when an error occured while loading the texture
  45810. */
  45811. constructor(name: string, urlOfPhoto: string, options: {
  45812. resolution?: number;
  45813. size?: number;
  45814. useDirectMapping?: boolean;
  45815. faceForward?: boolean;
  45816. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45817. /**
  45818. * Releases resources associated with this node.
  45819. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45820. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45821. */
  45822. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45823. }
  45824. }
  45825. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45826. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45827. /** @hidden */
  45828. export var rgbdDecodePixelShader: {
  45829. name: string;
  45830. shader: string;
  45831. };
  45832. }
  45833. declare module "babylonjs/Misc/brdfTextureTools" {
  45834. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45835. import { Scene } from "babylonjs/scene";
  45836. import "babylonjs/Shaders/rgbdDecode.fragment";
  45837. /**
  45838. * Class used to host texture specific utilities
  45839. */
  45840. export class BRDFTextureTools {
  45841. /**
  45842. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45843. * @param texture the texture to expand.
  45844. */
  45845. private static _ExpandDefaultBRDFTexture;
  45846. /**
  45847. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45848. * @param scene defines the hosting scene
  45849. * @returns the environment BRDF texture
  45850. */
  45851. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45852. private static _environmentBRDFBase64Texture;
  45853. }
  45854. }
  45855. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45856. import { Nullable } from "babylonjs/types";
  45857. import { IAnimatable } from "babylonjs/Misc/tools";
  45858. import { Color3 } from "babylonjs/Maths/math";
  45859. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45860. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45861. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45862. import { Engine } from "babylonjs/Engines/engine";
  45863. import { Scene } from "babylonjs/scene";
  45864. /**
  45865. * @hidden
  45866. */
  45867. export interface IMaterialClearCoatDefines {
  45868. CLEARCOAT: boolean;
  45869. CLEARCOAT_DEFAULTIOR: boolean;
  45870. CLEARCOAT_TEXTURE: boolean;
  45871. CLEARCOAT_TEXTUREDIRECTUV: number;
  45872. CLEARCOAT_BUMP: boolean;
  45873. CLEARCOAT_BUMPDIRECTUV: number;
  45874. CLEARCOAT_TINT: boolean;
  45875. CLEARCOAT_TINT_TEXTURE: boolean;
  45876. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45877. /** @hidden */
  45878. _areTexturesDirty: boolean;
  45879. }
  45880. /**
  45881. * Define the code related to the clear coat parameters of the pbr material.
  45882. */
  45883. export class PBRClearCoatConfiguration {
  45884. /**
  45885. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45886. * The default fits with a polyurethane material.
  45887. */
  45888. private static readonly _DefaultIndiceOfRefraction;
  45889. private _isEnabled;
  45890. /**
  45891. * Defines if the clear coat is enabled in the material.
  45892. */
  45893. isEnabled: boolean;
  45894. /**
  45895. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45896. */
  45897. intensity: number;
  45898. /**
  45899. * Defines the clear coat layer roughness.
  45900. */
  45901. roughness: number;
  45902. private _indiceOfRefraction;
  45903. /**
  45904. * Defines the indice of refraction of the clear coat.
  45905. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45906. * The default fits with a polyurethane material.
  45907. * Changing the default value is more performance intensive.
  45908. */
  45909. indiceOfRefraction: number;
  45910. private _texture;
  45911. /**
  45912. * Stores the clear coat values in a texture.
  45913. */
  45914. texture: Nullable<BaseTexture>;
  45915. private _bumpTexture;
  45916. /**
  45917. * Define the clear coat specific bump texture.
  45918. */
  45919. bumpTexture: Nullable<BaseTexture>;
  45920. private _isTintEnabled;
  45921. /**
  45922. * Defines if the clear coat tint is enabled in the material.
  45923. */
  45924. isTintEnabled: boolean;
  45925. /**
  45926. * Defines the clear coat tint of the material.
  45927. * This is only use if tint is enabled
  45928. */
  45929. tintColor: Color3;
  45930. /**
  45931. * Defines the distance at which the tint color should be found in the
  45932. * clear coat media.
  45933. * This is only use if tint is enabled
  45934. */
  45935. tintColorAtDistance: number;
  45936. /**
  45937. * Defines the clear coat layer thickness.
  45938. * This is only use if tint is enabled
  45939. */
  45940. tintThickness: number;
  45941. private _tintTexture;
  45942. /**
  45943. * Stores the clear tint values in a texture.
  45944. * rgb is tint
  45945. * a is a thickness factor
  45946. */
  45947. tintTexture: Nullable<BaseTexture>;
  45948. /** @hidden */
  45949. private _internalMarkAllSubMeshesAsTexturesDirty;
  45950. /** @hidden */
  45951. _markAllSubMeshesAsTexturesDirty(): void;
  45952. /**
  45953. * Instantiate a new istance of clear coat configuration.
  45954. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45955. */
  45956. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45957. /**
  45958. * Gets wehter the submesh is ready to be used or not.
  45959. * @param defines the list of "defines" to update.
  45960. * @param scene defines the scene the material belongs to.
  45961. * @param engine defines the engine the material belongs to.
  45962. * @param disableBumpMap defines wether the material disables bump or not.
  45963. * @returns - boolean indicating that the submesh is ready or not.
  45964. */
  45965. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45966. /**
  45967. * Checks to see if a texture is used in the material.
  45968. * @param defines the list of "defines" to update.
  45969. * @param scene defines the scene to the material belongs to.
  45970. */
  45971. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45972. /**
  45973. * Binds the material data.
  45974. * @param uniformBuffer defines the Uniform buffer to fill in.
  45975. * @param scene defines the scene the material belongs to.
  45976. * @param engine defines the engine the material belongs to.
  45977. * @param disableBumpMap defines wether the material disables bump or not.
  45978. * @param isFrozen defines wether the material is frozen or not.
  45979. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45980. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45981. */
  45982. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45983. /**
  45984. * Checks to see if a texture is used in the material.
  45985. * @param texture - Base texture to use.
  45986. * @returns - Boolean specifying if a texture is used in the material.
  45987. */
  45988. hasTexture(texture: BaseTexture): boolean;
  45989. /**
  45990. * Returns an array of the actively used textures.
  45991. * @param activeTextures Array of BaseTextures
  45992. */
  45993. getActiveTextures(activeTextures: BaseTexture[]): void;
  45994. /**
  45995. * Returns the animatable textures.
  45996. * @param animatables Array of animatable textures.
  45997. */
  45998. getAnimatables(animatables: IAnimatable[]): void;
  45999. /**
  46000. * Disposes the resources of the material.
  46001. * @param forceDisposeTextures - Forces the disposal of all textures.
  46002. */
  46003. dispose(forceDisposeTextures?: boolean): void;
  46004. /**
  46005. * Get the current class name of the texture useful for serialization or dynamic coding.
  46006. * @returns "PBRClearCoatConfiguration"
  46007. */
  46008. getClassName(): string;
  46009. /**
  46010. * Add fallbacks to the effect fallbacks list.
  46011. * @param defines defines the Base texture to use.
  46012. * @param fallbacks defines the current fallback list.
  46013. * @param currentRank defines the current fallback rank.
  46014. * @returns the new fallback rank.
  46015. */
  46016. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46017. /**
  46018. * Add the required uniforms to the current list.
  46019. * @param uniforms defines the current uniform list.
  46020. */
  46021. static AddUniforms(uniforms: string[]): void;
  46022. /**
  46023. * Add the required samplers to the current list.
  46024. * @param samplers defines the current sampler list.
  46025. */
  46026. static AddSamplers(samplers: string[]): void;
  46027. /**
  46028. * Add the required uniforms to the current buffer.
  46029. * @param uniformBuffer defines the current uniform buffer.
  46030. */
  46031. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46032. /**
  46033. * Makes a duplicate of the current configuration into another one.
  46034. * @param clearCoatConfiguration define the config where to copy the info
  46035. */
  46036. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46037. /**
  46038. * Serializes this clear coat configuration.
  46039. * @returns - An object with the serialized config.
  46040. */
  46041. serialize(): any;
  46042. /**
  46043. * Parses a Clear Coat Configuration from a serialized object.
  46044. * @param source - Serialized object.
  46045. */
  46046. parse(source: any): void;
  46047. }
  46048. }
  46049. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46050. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46051. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46053. import { Vector2 } from "babylonjs/Maths/math";
  46054. import { Scene } from "babylonjs/scene";
  46055. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46056. import { IAnimatable } from "babylonjs/Misc/tools";
  46057. import { Nullable } from "babylonjs/types";
  46058. /**
  46059. * @hidden
  46060. */
  46061. export interface IMaterialAnisotropicDefines {
  46062. ANISOTROPIC: boolean;
  46063. ANISOTROPIC_TEXTURE: boolean;
  46064. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46065. MAINUV1: boolean;
  46066. _areTexturesDirty: boolean;
  46067. _needUVs: boolean;
  46068. }
  46069. /**
  46070. * Define the code related to the anisotropic parameters of the pbr material.
  46071. */
  46072. export class PBRAnisotropicConfiguration {
  46073. private _isEnabled;
  46074. /**
  46075. * Defines if the anisotropy is enabled in the material.
  46076. */
  46077. isEnabled: boolean;
  46078. /**
  46079. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46080. */
  46081. intensity: number;
  46082. /**
  46083. * Defines if the effect is along the tangents, bitangents or in between.
  46084. * By default, the effect is "strectching" the highlights along the tangents.
  46085. */
  46086. direction: Vector2;
  46087. private _texture;
  46088. /**
  46089. * Stores the anisotropy values in a texture.
  46090. * rg is direction (like normal from -1 to 1)
  46091. * b is a intensity
  46092. */
  46093. texture: Nullable<BaseTexture>;
  46094. /** @hidden */
  46095. private _internalMarkAllSubMeshesAsTexturesDirty;
  46096. /** @hidden */
  46097. _markAllSubMeshesAsTexturesDirty(): void;
  46098. /**
  46099. * Instantiate a new istance of anisotropy configuration.
  46100. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46101. */
  46102. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46103. /**
  46104. * Specifies that the submesh is ready to be used.
  46105. * @param defines the list of "defines" to update.
  46106. * @param scene defines the scene the material belongs to.
  46107. * @returns - boolean indicating that the submesh is ready or not.
  46108. */
  46109. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46110. /**
  46111. * Checks to see if a texture is used in the material.
  46112. * @param defines the list of "defines" to update.
  46113. * @param mesh the mesh we are preparing the defines for.
  46114. * @param scene defines the scene the material belongs to.
  46115. */
  46116. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46117. /**
  46118. * Binds the material data.
  46119. * @param uniformBuffer defines the Uniform buffer to fill in.
  46120. * @param scene defines the scene the material belongs to.
  46121. * @param isFrozen defines wether the material is frozen or not.
  46122. */
  46123. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46124. /**
  46125. * Checks to see if a texture is used in the material.
  46126. * @param texture - Base texture to use.
  46127. * @returns - Boolean specifying if a texture is used in the material.
  46128. */
  46129. hasTexture(texture: BaseTexture): boolean;
  46130. /**
  46131. * Returns an array of the actively used textures.
  46132. * @param activeTextures Array of BaseTextures
  46133. */
  46134. getActiveTextures(activeTextures: BaseTexture[]): void;
  46135. /**
  46136. * Returns the animatable textures.
  46137. * @param animatables Array of animatable textures.
  46138. */
  46139. getAnimatables(animatables: IAnimatable[]): void;
  46140. /**
  46141. * Disposes the resources of the material.
  46142. * @param forceDisposeTextures - Forces the disposal of all textures.
  46143. */
  46144. dispose(forceDisposeTextures?: boolean): void;
  46145. /**
  46146. * Get the current class name of the texture useful for serialization or dynamic coding.
  46147. * @returns "PBRAnisotropicConfiguration"
  46148. */
  46149. getClassName(): string;
  46150. /**
  46151. * Add fallbacks to the effect fallbacks list.
  46152. * @param defines defines the Base texture to use.
  46153. * @param fallbacks defines the current fallback list.
  46154. * @param currentRank defines the current fallback rank.
  46155. * @returns the new fallback rank.
  46156. */
  46157. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46158. /**
  46159. * Add the required uniforms to the current list.
  46160. * @param uniforms defines the current uniform list.
  46161. */
  46162. static AddUniforms(uniforms: string[]): void;
  46163. /**
  46164. * Add the required uniforms to the current buffer.
  46165. * @param uniformBuffer defines the current uniform buffer.
  46166. */
  46167. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46168. /**
  46169. * Add the required samplers to the current list.
  46170. * @param samplers defines the current sampler list.
  46171. */
  46172. static AddSamplers(samplers: string[]): void;
  46173. /**
  46174. * Makes a duplicate of the current configuration into another one.
  46175. * @param anisotropicConfiguration define the config where to copy the info
  46176. */
  46177. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46178. /**
  46179. * Serializes this anisotropy configuration.
  46180. * @returns - An object with the serialized config.
  46181. */
  46182. serialize(): any;
  46183. /**
  46184. * Parses a anisotropy Configuration from a serialized object.
  46185. * @param source - Serialized object.
  46186. */
  46187. parse(source: any): void;
  46188. }
  46189. }
  46190. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46191. /**
  46192. * @hidden
  46193. */
  46194. export interface IMaterialBRDFDefines {
  46195. BRDF_V_HEIGHT_CORRELATED: boolean;
  46196. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46197. SPHERICAL_HARMONICS: boolean;
  46198. /** @hidden */
  46199. _areMiscDirty: boolean;
  46200. }
  46201. /**
  46202. * Define the code related to the BRDF parameters of the pbr material.
  46203. */
  46204. export class PBRBRDFConfiguration {
  46205. /**
  46206. * Default value used for the energy conservation.
  46207. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46208. */
  46209. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46210. /**
  46211. * Default value used for the Smith Visibility Height Correlated mode.
  46212. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46213. */
  46214. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46215. /**
  46216. * Default value used for the IBL diffuse part.
  46217. * This can help switching back to the polynomials mode globally which is a tiny bit
  46218. * less GPU intensive at the drawback of a lower quality.
  46219. */
  46220. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46221. private _useEnergyConservation;
  46222. /**
  46223. * Defines if the material uses energy conservation.
  46224. */
  46225. useEnergyConservation: boolean;
  46226. private _useSmithVisibilityHeightCorrelated;
  46227. /**
  46228. * LEGACY Mode set to false
  46229. * Defines if the material uses height smith correlated visibility term.
  46230. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46231. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46232. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46233. * Not relying on height correlated will also disable energy conservation.
  46234. */
  46235. useSmithVisibilityHeightCorrelated: boolean;
  46236. private _useSphericalHarmonics;
  46237. /**
  46238. * LEGACY Mode set to false
  46239. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46240. * diffuse part of the IBL.
  46241. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46242. * to the ground truth.
  46243. */
  46244. useSphericalHarmonics: boolean;
  46245. /** @hidden */
  46246. private _internalMarkAllSubMeshesAsMiscDirty;
  46247. /** @hidden */
  46248. _markAllSubMeshesAsMiscDirty(): void;
  46249. /**
  46250. * Instantiate a new istance of clear coat configuration.
  46251. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46252. */
  46253. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46254. /**
  46255. * Checks to see if a texture is used in the material.
  46256. * @param defines the list of "defines" to update.
  46257. */
  46258. prepareDefines(defines: IMaterialBRDFDefines): void;
  46259. /**
  46260. * Get the current class name of the texture useful for serialization or dynamic coding.
  46261. * @returns "PBRClearCoatConfiguration"
  46262. */
  46263. getClassName(): string;
  46264. /**
  46265. * Makes a duplicate of the current configuration into another one.
  46266. * @param brdfConfiguration define the config where to copy the info
  46267. */
  46268. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46269. /**
  46270. * Serializes this BRDF configuration.
  46271. * @returns - An object with the serialized config.
  46272. */
  46273. serialize(): any;
  46274. /**
  46275. * Parses a BRDF Configuration from a serialized object.
  46276. * @param source - Serialized object.
  46277. */
  46278. parse(source: any): void;
  46279. }
  46280. }
  46281. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46282. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46283. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46284. import { Color3 } from "babylonjs/Maths/math";
  46285. import { Scene } from "babylonjs/scene";
  46286. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46287. import { IAnimatable } from "babylonjs/Misc/tools";
  46288. import { Nullable } from "babylonjs/types";
  46289. /**
  46290. * @hidden
  46291. */
  46292. export interface IMaterialSheenDefines {
  46293. SHEEN: boolean;
  46294. SHEEN_TEXTURE: boolean;
  46295. SHEEN_TEXTUREDIRECTUV: number;
  46296. SHEEN_LINKWITHALBEDO: boolean;
  46297. /** @hidden */
  46298. _areTexturesDirty: boolean;
  46299. }
  46300. /**
  46301. * Define the code related to the Sheen parameters of the pbr material.
  46302. */
  46303. export class PBRSheenConfiguration {
  46304. private _isEnabled;
  46305. /**
  46306. * Defines if the material uses sheen.
  46307. */
  46308. isEnabled: boolean;
  46309. private _linkSheenWithAlbedo;
  46310. /**
  46311. * Defines if the sheen is linked to the sheen color.
  46312. */
  46313. linkSheenWithAlbedo: boolean;
  46314. /**
  46315. * Defines the sheen intensity.
  46316. */
  46317. intensity: number;
  46318. /**
  46319. * Defines the sheen color.
  46320. */
  46321. color: Color3;
  46322. private _texture;
  46323. /**
  46324. * Stores the sheen tint values in a texture.
  46325. * rgb is tint
  46326. * a is a intensity
  46327. */
  46328. texture: Nullable<BaseTexture>;
  46329. /** @hidden */
  46330. private _internalMarkAllSubMeshesAsTexturesDirty;
  46331. /** @hidden */
  46332. _markAllSubMeshesAsTexturesDirty(): void;
  46333. /**
  46334. * Instantiate a new istance of clear coat configuration.
  46335. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46336. */
  46337. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46338. /**
  46339. * Specifies that the submesh is ready to be used.
  46340. * @param defines the list of "defines" to update.
  46341. * @param scene defines the scene the material belongs to.
  46342. * @returns - boolean indicating that the submesh is ready or not.
  46343. */
  46344. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46345. /**
  46346. * Checks to see if a texture is used in the material.
  46347. * @param defines the list of "defines" to update.
  46348. * @param scene defines the scene the material belongs to.
  46349. */
  46350. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46351. /**
  46352. * Binds the material data.
  46353. * @param uniformBuffer defines the Uniform buffer to fill in.
  46354. * @param scene defines the scene the material belongs to.
  46355. * @param isFrozen defines wether the material is frozen or not.
  46356. */
  46357. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46358. /**
  46359. * Checks to see if a texture is used in the material.
  46360. * @param texture - Base texture to use.
  46361. * @returns - Boolean specifying if a texture is used in the material.
  46362. */
  46363. hasTexture(texture: BaseTexture): boolean;
  46364. /**
  46365. * Returns an array of the actively used textures.
  46366. * @param activeTextures Array of BaseTextures
  46367. */
  46368. getActiveTextures(activeTextures: BaseTexture[]): void;
  46369. /**
  46370. * Returns the animatable textures.
  46371. * @param animatables Array of animatable textures.
  46372. */
  46373. getAnimatables(animatables: IAnimatable[]): void;
  46374. /**
  46375. * Disposes the resources of the material.
  46376. * @param forceDisposeTextures - Forces the disposal of all textures.
  46377. */
  46378. dispose(forceDisposeTextures?: boolean): void;
  46379. /**
  46380. * Get the current class name of the texture useful for serialization or dynamic coding.
  46381. * @returns "PBRSheenConfiguration"
  46382. */
  46383. getClassName(): string;
  46384. /**
  46385. * Add fallbacks to the effect fallbacks list.
  46386. * @param defines defines the Base texture to use.
  46387. * @param fallbacks defines the current fallback list.
  46388. * @param currentRank defines the current fallback rank.
  46389. * @returns the new fallback rank.
  46390. */
  46391. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46392. /**
  46393. * Add the required uniforms to the current list.
  46394. * @param uniforms defines the current uniform list.
  46395. */
  46396. static AddUniforms(uniforms: string[]): void;
  46397. /**
  46398. * Add the required uniforms to the current buffer.
  46399. * @param uniformBuffer defines the current uniform buffer.
  46400. */
  46401. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46402. /**
  46403. * Add the required samplers to the current list.
  46404. * @param samplers defines the current sampler list.
  46405. */
  46406. static AddSamplers(samplers: string[]): void;
  46407. /**
  46408. * Makes a duplicate of the current configuration into another one.
  46409. * @param sheenConfiguration define the config where to copy the info
  46410. */
  46411. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46412. /**
  46413. * Serializes this BRDF configuration.
  46414. * @returns - An object with the serialized config.
  46415. */
  46416. serialize(): any;
  46417. /**
  46418. * Parses a Sheen Configuration from a serialized object.
  46419. * @param source - Serialized object.
  46420. */
  46421. parse(source: any): void;
  46422. }
  46423. }
  46424. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46425. import { Nullable } from "babylonjs/types";
  46426. import { IAnimatable } from "babylonjs/Misc/tools";
  46427. import { Color3 } from "babylonjs/Maths/math";
  46428. import { SmartArray } from "babylonjs/Misc/smartArray";
  46429. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46430. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46431. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46432. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46433. import { Engine } from "babylonjs/Engines/engine";
  46434. import { Scene } from "babylonjs/scene";
  46435. /**
  46436. * @hidden
  46437. */
  46438. export interface IMaterialSubSurfaceDefines {
  46439. SUBSURFACE: boolean;
  46440. SS_REFRACTION: boolean;
  46441. SS_TRANSLUCENCY: boolean;
  46442. SS_SCATERRING: boolean;
  46443. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46444. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46445. SS_REFRACTIONMAP_3D: boolean;
  46446. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46447. SS_LODINREFRACTIONALPHA: boolean;
  46448. SS_GAMMAREFRACTION: boolean;
  46449. SS_RGBDREFRACTION: boolean;
  46450. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46451. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46452. /** @hidden */
  46453. _areTexturesDirty: boolean;
  46454. }
  46455. /**
  46456. * Define the code related to the sub surface parameters of the pbr material.
  46457. */
  46458. export class PBRSubSurfaceConfiguration {
  46459. private _isRefractionEnabled;
  46460. /**
  46461. * Defines if the refraction is enabled in the material.
  46462. */
  46463. isRefractionEnabled: boolean;
  46464. private _isTranslucencyEnabled;
  46465. /**
  46466. * Defines if the translucency is enabled in the material.
  46467. */
  46468. isTranslucencyEnabled: boolean;
  46469. private _isScatteringEnabled;
  46470. /**
  46471. * Defines the refraction intensity of the material.
  46472. * The refraction when enabled replaces the Diffuse part of the material.
  46473. * The intensity helps transitionning between diffuse and refraction.
  46474. */
  46475. refractionIntensity: number;
  46476. /**
  46477. * Defines the translucency intensity of the material.
  46478. * When translucency has been enabled, this defines how much of the "translucency"
  46479. * is addded to the diffuse part of the material.
  46480. */
  46481. translucencyIntensity: number;
  46482. /**
  46483. * Defines the scattering intensity of the material.
  46484. * When scattering has been enabled, this defines how much of the "scattered light"
  46485. * is addded to the diffuse part of the material.
  46486. */
  46487. scatteringIntensity: number;
  46488. private _thicknessTexture;
  46489. /**
  46490. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46491. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46492. * 0 would mean minimumThickness
  46493. * 1 would mean maximumThickness
  46494. * The other channels might be use as a mask to vary the different effects intensity.
  46495. */
  46496. thicknessTexture: Nullable<BaseTexture>;
  46497. private _refractionTexture;
  46498. /**
  46499. * Defines the texture to use for refraction.
  46500. */
  46501. refractionTexture: Nullable<BaseTexture>;
  46502. private _indexOfRefraction;
  46503. /**
  46504. * Defines the indice of refraction used in the material.
  46505. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46506. */
  46507. indexOfRefraction: number;
  46508. private _invertRefractionY;
  46509. /**
  46510. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46511. */
  46512. invertRefractionY: boolean;
  46513. private _linkRefractionWithTransparency;
  46514. /**
  46515. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46516. * Materials half opaque for instance using refraction could benefit from this control.
  46517. */
  46518. linkRefractionWithTransparency: boolean;
  46519. /**
  46520. * Defines the minimum thickness stored in the thickness map.
  46521. * If no thickness map is defined, this value will be used to simulate thickness.
  46522. */
  46523. minimumThickness: number;
  46524. /**
  46525. * Defines the maximum thickness stored in the thickness map.
  46526. */
  46527. maximumThickness: number;
  46528. /**
  46529. * Defines the volume tint of the material.
  46530. * This is used for both translucency and scattering.
  46531. */
  46532. tintColor: Color3;
  46533. /**
  46534. * Defines the distance at which the tint color should be found in the media.
  46535. * This is used for refraction only.
  46536. */
  46537. tintColorAtDistance: number;
  46538. /**
  46539. * Defines how far each channel transmit through the media.
  46540. * It is defined as a color to simplify it selection.
  46541. */
  46542. diffusionDistance: Color3;
  46543. private _useMaskFromThicknessTexture;
  46544. /**
  46545. * Stores the intensity of the different subsurface effects in the thickness texture.
  46546. * * the green channel is the translucency intensity.
  46547. * * the blue channel is the scattering intensity.
  46548. * * the alpha channel is the refraction intensity.
  46549. */
  46550. useMaskFromThicknessTexture: boolean;
  46551. /** @hidden */
  46552. private _internalMarkAllSubMeshesAsTexturesDirty;
  46553. /** @hidden */
  46554. _markAllSubMeshesAsTexturesDirty(): void;
  46555. /**
  46556. * Instantiate a new istance of sub surface configuration.
  46557. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46558. */
  46559. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46560. /**
  46561. * Gets wehter the submesh is ready to be used or not.
  46562. * @param defines the list of "defines" to update.
  46563. * @param scene defines the scene the material belongs to.
  46564. * @returns - boolean indicating that the submesh is ready or not.
  46565. */
  46566. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46567. /**
  46568. * Checks to see if a texture is used in the material.
  46569. * @param defines the list of "defines" to update.
  46570. * @param scene defines the scene to the material belongs to.
  46571. */
  46572. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46573. /**
  46574. * Binds the material data.
  46575. * @param uniformBuffer defines the Uniform buffer to fill in.
  46576. * @param scene defines the scene the material belongs to.
  46577. * @param engine defines the engine the material belongs to.
  46578. * @param isFrozen defines wether the material is frozen or not.
  46579. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46580. */
  46581. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46582. /**
  46583. * Unbinds the material from the mesh.
  46584. * @param activeEffect defines the effect that should be unbound from.
  46585. * @returns true if unbound, otherwise false
  46586. */
  46587. unbind(activeEffect: Effect): boolean;
  46588. /**
  46589. * Returns the texture used for refraction or null if none is used.
  46590. * @param scene defines the scene the material belongs to.
  46591. * @returns - Refraction texture if present. If no refraction texture and refraction
  46592. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46593. */
  46594. private _getRefractionTexture;
  46595. /**
  46596. * Returns true if alpha blending should be disabled.
  46597. */
  46598. readonly disableAlphaBlending: boolean;
  46599. /**
  46600. * Fills the list of render target textures.
  46601. * @param renderTargets the list of render targets to update
  46602. */
  46603. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46604. /**
  46605. * Checks to see if a texture is used in the material.
  46606. * @param texture - Base texture to use.
  46607. * @returns - Boolean specifying if a texture is used in the material.
  46608. */
  46609. hasTexture(texture: BaseTexture): boolean;
  46610. /**
  46611. * Gets a boolean indicating that current material needs to register RTT
  46612. * @returns true if this uses a render target otherwise false.
  46613. */
  46614. hasRenderTargetTextures(): boolean;
  46615. /**
  46616. * Returns an array of the actively used textures.
  46617. * @param activeTextures Array of BaseTextures
  46618. */
  46619. getActiveTextures(activeTextures: BaseTexture[]): void;
  46620. /**
  46621. * Returns the animatable textures.
  46622. * @param animatables Array of animatable textures.
  46623. */
  46624. getAnimatables(animatables: IAnimatable[]): void;
  46625. /**
  46626. * Disposes the resources of the material.
  46627. * @param forceDisposeTextures - Forces the disposal of all textures.
  46628. */
  46629. dispose(forceDisposeTextures?: boolean): void;
  46630. /**
  46631. * Get the current class name of the texture useful for serialization or dynamic coding.
  46632. * @returns "PBRSubSurfaceConfiguration"
  46633. */
  46634. getClassName(): string;
  46635. /**
  46636. * Add fallbacks to the effect fallbacks list.
  46637. * @param defines defines the Base texture to use.
  46638. * @param fallbacks defines the current fallback list.
  46639. * @param currentRank defines the current fallback rank.
  46640. * @returns the new fallback rank.
  46641. */
  46642. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46643. /**
  46644. * Add the required uniforms to the current list.
  46645. * @param uniforms defines the current uniform list.
  46646. */
  46647. static AddUniforms(uniforms: string[]): void;
  46648. /**
  46649. * Add the required samplers to the current list.
  46650. * @param samplers defines the current sampler list.
  46651. */
  46652. static AddSamplers(samplers: string[]): void;
  46653. /**
  46654. * Add the required uniforms to the current buffer.
  46655. * @param uniformBuffer defines the current uniform buffer.
  46656. */
  46657. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46658. /**
  46659. * Makes a duplicate of the current configuration into another one.
  46660. * @param configuration define the config where to copy the info
  46661. */
  46662. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46663. /**
  46664. * Serializes this Sub Surface configuration.
  46665. * @returns - An object with the serialized config.
  46666. */
  46667. serialize(): any;
  46668. /**
  46669. * Parses a Sub Surface Configuration from a serialized object.
  46670. * @param source - Serialized object.
  46671. */
  46672. parse(source: any): void;
  46673. }
  46674. }
  46675. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46676. /** @hidden */
  46677. export var pbrFragmentDeclaration: {
  46678. name: string;
  46679. shader: string;
  46680. };
  46681. }
  46682. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46683. /** @hidden */
  46684. export var pbrUboDeclaration: {
  46685. name: string;
  46686. shader: string;
  46687. };
  46688. }
  46689. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46690. /** @hidden */
  46691. export var pbrFragmentExtraDeclaration: {
  46692. name: string;
  46693. shader: string;
  46694. };
  46695. }
  46696. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46697. /** @hidden */
  46698. export var pbrFragmentSamplersDeclaration: {
  46699. name: string;
  46700. shader: string;
  46701. };
  46702. }
  46703. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46704. /** @hidden */
  46705. export var pbrHelperFunctions: {
  46706. name: string;
  46707. shader: string;
  46708. };
  46709. }
  46710. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46711. /** @hidden */
  46712. export var harmonicsFunctions: {
  46713. name: string;
  46714. shader: string;
  46715. };
  46716. }
  46717. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46718. /** @hidden */
  46719. export var pbrDirectLightingSetupFunctions: {
  46720. name: string;
  46721. shader: string;
  46722. };
  46723. }
  46724. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46725. /** @hidden */
  46726. export var pbrDirectLightingFalloffFunctions: {
  46727. name: string;
  46728. shader: string;
  46729. };
  46730. }
  46731. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46732. /** @hidden */
  46733. export var pbrBRDFFunctions: {
  46734. name: string;
  46735. shader: string;
  46736. };
  46737. }
  46738. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46739. /** @hidden */
  46740. export var pbrDirectLightingFunctions: {
  46741. name: string;
  46742. shader: string;
  46743. };
  46744. }
  46745. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46746. /** @hidden */
  46747. export var pbrIBLFunctions: {
  46748. name: string;
  46749. shader: string;
  46750. };
  46751. }
  46752. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46753. /** @hidden */
  46754. export var pbrDebug: {
  46755. name: string;
  46756. shader: string;
  46757. };
  46758. }
  46759. declare module "babylonjs/Shaders/pbr.fragment" {
  46760. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46761. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46762. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46763. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46764. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46765. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46766. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46767. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46768. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46769. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46770. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46771. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46772. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46773. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46774. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46775. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46776. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46777. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46778. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46779. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46780. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46781. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46782. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46783. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46784. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46785. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46786. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46787. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46788. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46789. /** @hidden */
  46790. export var pbrPixelShader: {
  46791. name: string;
  46792. shader: string;
  46793. };
  46794. }
  46795. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46796. /** @hidden */
  46797. export var pbrVertexDeclaration: {
  46798. name: string;
  46799. shader: string;
  46800. };
  46801. }
  46802. declare module "babylonjs/Shaders/pbr.vertex" {
  46803. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46804. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46805. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46806. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46807. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46808. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46809. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46810. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46811. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46812. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46813. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46814. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46815. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46816. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46817. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46818. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46819. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46820. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46821. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46822. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46823. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46824. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46825. /** @hidden */
  46826. export var pbrVertexShader: {
  46827. name: string;
  46828. shader: string;
  46829. };
  46830. }
  46831. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46832. import { IAnimatable } from "babylonjs/Misc/tools";
  46833. import { Nullable } from "babylonjs/types";
  46834. import { Scene } from "babylonjs/scene";
  46835. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46836. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46838. import { Mesh } from "babylonjs/Meshes/mesh";
  46839. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46840. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46841. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46842. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46843. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46844. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46845. import { Material } from "babylonjs/Materials/material";
  46846. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46847. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46848. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46849. import "babylonjs/Shaders/pbr.fragment";
  46850. import "babylonjs/Shaders/pbr.vertex";
  46851. /**
  46852. * Manages the defines for the PBR Material.
  46853. * @hidden
  46854. */
  46855. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46856. PBR: boolean;
  46857. MAINUV1: boolean;
  46858. MAINUV2: boolean;
  46859. UV1: boolean;
  46860. UV2: boolean;
  46861. ALBEDO: boolean;
  46862. ALBEDODIRECTUV: number;
  46863. VERTEXCOLOR: boolean;
  46864. AMBIENT: boolean;
  46865. AMBIENTDIRECTUV: number;
  46866. AMBIENTINGRAYSCALE: boolean;
  46867. OPACITY: boolean;
  46868. VERTEXALPHA: boolean;
  46869. OPACITYDIRECTUV: number;
  46870. OPACITYRGB: boolean;
  46871. ALPHATEST: boolean;
  46872. DEPTHPREPASS: boolean;
  46873. ALPHABLEND: boolean;
  46874. ALPHAFROMALBEDO: boolean;
  46875. ALPHATESTVALUE: string;
  46876. SPECULAROVERALPHA: boolean;
  46877. RADIANCEOVERALPHA: boolean;
  46878. ALPHAFRESNEL: boolean;
  46879. LINEARALPHAFRESNEL: boolean;
  46880. PREMULTIPLYALPHA: boolean;
  46881. EMISSIVE: boolean;
  46882. EMISSIVEDIRECTUV: number;
  46883. REFLECTIVITY: boolean;
  46884. REFLECTIVITYDIRECTUV: number;
  46885. SPECULARTERM: boolean;
  46886. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46887. MICROSURFACEAUTOMATIC: boolean;
  46888. LODBASEDMICROSFURACE: boolean;
  46889. MICROSURFACEMAP: boolean;
  46890. MICROSURFACEMAPDIRECTUV: number;
  46891. METALLICWORKFLOW: boolean;
  46892. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46893. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46894. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46895. AOSTOREINMETALMAPRED: boolean;
  46896. ENVIRONMENTBRDF: boolean;
  46897. ENVIRONMENTBRDF_RGBD: boolean;
  46898. NORMAL: boolean;
  46899. TANGENT: boolean;
  46900. BUMP: boolean;
  46901. BUMPDIRECTUV: number;
  46902. OBJECTSPACE_NORMALMAP: boolean;
  46903. PARALLAX: boolean;
  46904. PARALLAXOCCLUSION: boolean;
  46905. NORMALXYSCALE: boolean;
  46906. LIGHTMAP: boolean;
  46907. LIGHTMAPDIRECTUV: number;
  46908. USELIGHTMAPASSHADOWMAP: boolean;
  46909. GAMMALIGHTMAP: boolean;
  46910. REFLECTION: boolean;
  46911. REFLECTIONMAP_3D: boolean;
  46912. REFLECTIONMAP_SPHERICAL: boolean;
  46913. REFLECTIONMAP_PLANAR: boolean;
  46914. REFLECTIONMAP_CUBIC: boolean;
  46915. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46916. REFLECTIONMAP_PROJECTION: boolean;
  46917. REFLECTIONMAP_SKYBOX: boolean;
  46918. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46919. REFLECTIONMAP_EXPLICIT: boolean;
  46920. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46921. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46922. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46923. INVERTCUBICMAP: boolean;
  46924. USESPHERICALFROMREFLECTIONMAP: boolean;
  46925. SPHERICAL_HARMONICS: boolean;
  46926. USESPHERICALINVERTEX: boolean;
  46927. REFLECTIONMAP_OPPOSITEZ: boolean;
  46928. LODINREFLECTIONALPHA: boolean;
  46929. GAMMAREFLECTION: boolean;
  46930. RGBDREFLECTION: boolean;
  46931. RADIANCEOCCLUSION: boolean;
  46932. HORIZONOCCLUSION: boolean;
  46933. INSTANCES: boolean;
  46934. NUM_BONE_INFLUENCERS: number;
  46935. BonesPerMesh: number;
  46936. BONETEXTURE: boolean;
  46937. NONUNIFORMSCALING: boolean;
  46938. MORPHTARGETS: boolean;
  46939. MORPHTARGETS_NORMAL: boolean;
  46940. MORPHTARGETS_TANGENT: boolean;
  46941. NUM_MORPH_INFLUENCERS: number;
  46942. IMAGEPROCESSING: boolean;
  46943. VIGNETTE: boolean;
  46944. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46945. VIGNETTEBLENDMODEOPAQUE: boolean;
  46946. TONEMAPPING: boolean;
  46947. TONEMAPPING_ACES: boolean;
  46948. CONTRAST: boolean;
  46949. COLORCURVES: boolean;
  46950. COLORGRADING: boolean;
  46951. COLORGRADING3D: boolean;
  46952. SAMPLER3DGREENDEPTH: boolean;
  46953. SAMPLER3DBGRMAP: boolean;
  46954. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46955. EXPOSURE: boolean;
  46956. MULTIVIEW: boolean;
  46957. USEPHYSICALLIGHTFALLOFF: boolean;
  46958. USEGLTFLIGHTFALLOFF: boolean;
  46959. TWOSIDEDLIGHTING: boolean;
  46960. SHADOWFLOAT: boolean;
  46961. CLIPPLANE: boolean;
  46962. CLIPPLANE2: boolean;
  46963. CLIPPLANE3: boolean;
  46964. CLIPPLANE4: boolean;
  46965. POINTSIZE: boolean;
  46966. FOG: boolean;
  46967. LOGARITHMICDEPTH: boolean;
  46968. FORCENORMALFORWARD: boolean;
  46969. SPECULARAA: boolean;
  46970. CLEARCOAT: boolean;
  46971. CLEARCOAT_DEFAULTIOR: boolean;
  46972. CLEARCOAT_TEXTURE: boolean;
  46973. CLEARCOAT_TEXTUREDIRECTUV: number;
  46974. CLEARCOAT_BUMP: boolean;
  46975. CLEARCOAT_BUMPDIRECTUV: number;
  46976. CLEARCOAT_TINT: boolean;
  46977. CLEARCOAT_TINT_TEXTURE: boolean;
  46978. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46979. ANISOTROPIC: boolean;
  46980. ANISOTROPIC_TEXTURE: boolean;
  46981. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46982. BRDF_V_HEIGHT_CORRELATED: boolean;
  46983. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46984. SHEEN: boolean;
  46985. SHEEN_TEXTURE: boolean;
  46986. SHEEN_TEXTUREDIRECTUV: number;
  46987. SHEEN_LINKWITHALBEDO: boolean;
  46988. SUBSURFACE: boolean;
  46989. SS_REFRACTION: boolean;
  46990. SS_TRANSLUCENCY: boolean;
  46991. SS_SCATERRING: boolean;
  46992. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46993. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46994. SS_REFRACTIONMAP_3D: boolean;
  46995. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46996. SS_LODINREFRACTIONALPHA: boolean;
  46997. SS_GAMMAREFRACTION: boolean;
  46998. SS_RGBDREFRACTION: boolean;
  46999. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47000. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47001. UNLIT: boolean;
  47002. DEBUGMODE: number;
  47003. /**
  47004. * Initializes the PBR Material defines.
  47005. */
  47006. constructor();
  47007. /**
  47008. * Resets the PBR Material defines.
  47009. */
  47010. reset(): void;
  47011. }
  47012. /**
  47013. * The Physically based material base class of BJS.
  47014. *
  47015. * This offers the main features of a standard PBR material.
  47016. * For more information, please refer to the documentation :
  47017. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47018. */
  47019. export abstract class PBRBaseMaterial extends PushMaterial {
  47020. /**
  47021. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47022. */
  47023. static readonly PBRMATERIAL_OPAQUE: number;
  47024. /**
  47025. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47026. */
  47027. static readonly PBRMATERIAL_ALPHATEST: number;
  47028. /**
  47029. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47030. */
  47031. static readonly PBRMATERIAL_ALPHABLEND: number;
  47032. /**
  47033. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47034. * They are also discarded below the alpha cutoff threshold to improve performances.
  47035. */
  47036. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47037. /**
  47038. * Defines the default value of how much AO map is occluding the analytical lights
  47039. * (point spot...).
  47040. */
  47041. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47042. /**
  47043. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47044. */
  47045. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47046. /**
  47047. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47048. * to enhance interoperability with other engines.
  47049. */
  47050. static readonly LIGHTFALLOFF_GLTF: number;
  47051. /**
  47052. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47053. * to enhance interoperability with other materials.
  47054. */
  47055. static readonly LIGHTFALLOFF_STANDARD: number;
  47056. /**
  47057. * Intensity of the direct lights e.g. the four lights available in your scene.
  47058. * This impacts both the direct diffuse and specular highlights.
  47059. */
  47060. protected _directIntensity: number;
  47061. /**
  47062. * Intensity of the emissive part of the material.
  47063. * This helps controlling the emissive effect without modifying the emissive color.
  47064. */
  47065. protected _emissiveIntensity: number;
  47066. /**
  47067. * Intensity of the environment e.g. how much the environment will light the object
  47068. * either through harmonics for rough material or through the refelction for shiny ones.
  47069. */
  47070. protected _environmentIntensity: number;
  47071. /**
  47072. * This is a special control allowing the reduction of the specular highlights coming from the
  47073. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47074. */
  47075. protected _specularIntensity: number;
  47076. /**
  47077. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47078. */
  47079. private _lightingInfos;
  47080. /**
  47081. * Debug Control allowing disabling the bump map on this material.
  47082. */
  47083. protected _disableBumpMap: boolean;
  47084. /**
  47085. * AKA Diffuse Texture in standard nomenclature.
  47086. */
  47087. protected _albedoTexture: Nullable<BaseTexture>;
  47088. /**
  47089. * AKA Occlusion Texture in other nomenclature.
  47090. */
  47091. protected _ambientTexture: Nullable<BaseTexture>;
  47092. /**
  47093. * AKA Occlusion Texture Intensity in other nomenclature.
  47094. */
  47095. protected _ambientTextureStrength: number;
  47096. /**
  47097. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47098. * 1 means it completely occludes it
  47099. * 0 mean it has no impact
  47100. */
  47101. protected _ambientTextureImpactOnAnalyticalLights: number;
  47102. /**
  47103. * Stores the alpha values in a texture.
  47104. */
  47105. protected _opacityTexture: Nullable<BaseTexture>;
  47106. /**
  47107. * Stores the reflection values in a texture.
  47108. */
  47109. protected _reflectionTexture: Nullable<BaseTexture>;
  47110. /**
  47111. * Stores the emissive values in a texture.
  47112. */
  47113. protected _emissiveTexture: Nullable<BaseTexture>;
  47114. /**
  47115. * AKA Specular texture in other nomenclature.
  47116. */
  47117. protected _reflectivityTexture: Nullable<BaseTexture>;
  47118. /**
  47119. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47120. */
  47121. protected _metallicTexture: Nullable<BaseTexture>;
  47122. /**
  47123. * Specifies the metallic scalar of the metallic/roughness workflow.
  47124. * Can also be used to scale the metalness values of the metallic texture.
  47125. */
  47126. protected _metallic: Nullable<number>;
  47127. /**
  47128. * Specifies the roughness scalar of the metallic/roughness workflow.
  47129. * Can also be used to scale the roughness values of the metallic texture.
  47130. */
  47131. protected _roughness: Nullable<number>;
  47132. /**
  47133. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47134. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47135. */
  47136. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47137. /**
  47138. * Stores surface normal data used to displace a mesh in a texture.
  47139. */
  47140. protected _bumpTexture: Nullable<BaseTexture>;
  47141. /**
  47142. * Stores the pre-calculated light information of a mesh in a texture.
  47143. */
  47144. protected _lightmapTexture: Nullable<BaseTexture>;
  47145. /**
  47146. * The color of a material in ambient lighting.
  47147. */
  47148. protected _ambientColor: Color3;
  47149. /**
  47150. * AKA Diffuse Color in other nomenclature.
  47151. */
  47152. protected _albedoColor: Color3;
  47153. /**
  47154. * AKA Specular Color in other nomenclature.
  47155. */
  47156. protected _reflectivityColor: Color3;
  47157. /**
  47158. * The color applied when light is reflected from a material.
  47159. */
  47160. protected _reflectionColor: Color3;
  47161. /**
  47162. * The color applied when light is emitted from a material.
  47163. */
  47164. protected _emissiveColor: Color3;
  47165. /**
  47166. * AKA Glossiness in other nomenclature.
  47167. */
  47168. protected _microSurface: number;
  47169. /**
  47170. * Specifies that the material will use the light map as a show map.
  47171. */
  47172. protected _useLightmapAsShadowmap: boolean;
  47173. /**
  47174. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47175. * makes the reflect vector face the model (under horizon).
  47176. */
  47177. protected _useHorizonOcclusion: boolean;
  47178. /**
  47179. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47180. * too much the area relying on ambient texture to define their ambient occlusion.
  47181. */
  47182. protected _useRadianceOcclusion: boolean;
  47183. /**
  47184. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47185. */
  47186. protected _useAlphaFromAlbedoTexture: boolean;
  47187. /**
  47188. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47189. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47190. */
  47191. protected _useSpecularOverAlpha: boolean;
  47192. /**
  47193. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47194. */
  47195. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47196. /**
  47197. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47198. */
  47199. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47200. /**
  47201. * Specifies if the metallic texture contains the roughness information in its green channel.
  47202. */
  47203. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47204. /**
  47205. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47206. */
  47207. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47208. /**
  47209. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47210. */
  47211. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47212. /**
  47213. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47214. */
  47215. protected _useAmbientInGrayScale: boolean;
  47216. /**
  47217. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47218. * The material will try to infer what glossiness each pixel should be.
  47219. */
  47220. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47221. /**
  47222. * Defines the falloff type used in this material.
  47223. * It by default is Physical.
  47224. */
  47225. protected _lightFalloff: number;
  47226. /**
  47227. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47228. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47229. */
  47230. protected _useRadianceOverAlpha: boolean;
  47231. /**
  47232. * Allows using an object space normal map (instead of tangent space).
  47233. */
  47234. protected _useObjectSpaceNormalMap: boolean;
  47235. /**
  47236. * Allows using the bump map in parallax mode.
  47237. */
  47238. protected _useParallax: boolean;
  47239. /**
  47240. * Allows using the bump map in parallax occlusion mode.
  47241. */
  47242. protected _useParallaxOcclusion: boolean;
  47243. /**
  47244. * Controls the scale bias of the parallax mode.
  47245. */
  47246. protected _parallaxScaleBias: number;
  47247. /**
  47248. * If sets to true, disables all the lights affecting the material.
  47249. */
  47250. protected _disableLighting: boolean;
  47251. /**
  47252. * Number of Simultaneous lights allowed on the material.
  47253. */
  47254. protected _maxSimultaneousLights: number;
  47255. /**
  47256. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47257. */
  47258. protected _invertNormalMapX: boolean;
  47259. /**
  47260. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47261. */
  47262. protected _invertNormalMapY: boolean;
  47263. /**
  47264. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47265. */
  47266. protected _twoSidedLighting: boolean;
  47267. /**
  47268. * Defines the alpha limits in alpha test mode.
  47269. */
  47270. protected _alphaCutOff: number;
  47271. /**
  47272. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47273. */
  47274. protected _forceAlphaTest: boolean;
  47275. /**
  47276. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47277. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47278. */
  47279. protected _useAlphaFresnel: boolean;
  47280. /**
  47281. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47282. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47283. */
  47284. protected _useLinearAlphaFresnel: boolean;
  47285. /**
  47286. * The transparency mode of the material.
  47287. */
  47288. protected _transparencyMode: Nullable<number>;
  47289. /**
  47290. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47291. * from cos thetav and roughness:
  47292. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47293. */
  47294. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47295. /**
  47296. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47297. */
  47298. protected _forceIrradianceInFragment: boolean;
  47299. /**
  47300. * Force normal to face away from face.
  47301. */
  47302. protected _forceNormalForward: boolean;
  47303. /**
  47304. * Enables specular anti aliasing in the PBR shader.
  47305. * It will both interacts on the Geometry for analytical and IBL lighting.
  47306. * It also prefilter the roughness map based on the bump values.
  47307. */
  47308. protected _enableSpecularAntiAliasing: boolean;
  47309. /**
  47310. * Default configuration related to image processing available in the PBR Material.
  47311. */
  47312. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47313. /**
  47314. * Keep track of the image processing observer to allow dispose and replace.
  47315. */
  47316. private _imageProcessingObserver;
  47317. /**
  47318. * Attaches a new image processing configuration to the PBR Material.
  47319. * @param configuration
  47320. */
  47321. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47322. /**
  47323. * Stores the available render targets.
  47324. */
  47325. private _renderTargets;
  47326. /**
  47327. * Sets the global ambient color for the material used in lighting calculations.
  47328. */
  47329. private _globalAmbientColor;
  47330. /**
  47331. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47332. */
  47333. private _useLogarithmicDepth;
  47334. /**
  47335. * If set to true, no lighting calculations will be applied.
  47336. */
  47337. private _unlit;
  47338. private _debugMode;
  47339. /**
  47340. * @hidden
  47341. * This is reserved for the inspector.
  47342. * Defines the material debug mode.
  47343. * It helps seeing only some components of the material while troubleshooting.
  47344. */
  47345. debugMode: number;
  47346. /**
  47347. * @hidden
  47348. * This is reserved for the inspector.
  47349. * Specify from where on screen the debug mode should start.
  47350. * The value goes from -1 (full screen) to 1 (not visible)
  47351. * It helps with side by side comparison against the final render
  47352. * This defaults to -1
  47353. */
  47354. private debugLimit;
  47355. /**
  47356. * @hidden
  47357. * This is reserved for the inspector.
  47358. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47359. * You can use the factor to better multiply the final value.
  47360. */
  47361. private debugFactor;
  47362. /**
  47363. * Defines the clear coat layer parameters for the material.
  47364. */
  47365. readonly clearCoat: PBRClearCoatConfiguration;
  47366. /**
  47367. * Defines the anisotropic parameters for the material.
  47368. */
  47369. readonly anisotropy: PBRAnisotropicConfiguration;
  47370. /**
  47371. * Defines the BRDF parameters for the material.
  47372. */
  47373. readonly brdf: PBRBRDFConfiguration;
  47374. /**
  47375. * Defines the Sheen parameters for the material.
  47376. */
  47377. readonly sheen: PBRSheenConfiguration;
  47378. /**
  47379. * Defines the SubSurface parameters for the material.
  47380. */
  47381. readonly subSurface: PBRSubSurfaceConfiguration;
  47382. /**
  47383. * Custom callback helping to override the default shader used in the material.
  47384. */
  47385. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47386. /**
  47387. * Instantiates a new PBRMaterial instance.
  47388. *
  47389. * @param name The material name
  47390. * @param scene The scene the material will be use in.
  47391. */
  47392. constructor(name: string, scene: Scene);
  47393. /**
  47394. * Gets a boolean indicating that current material needs to register RTT
  47395. */
  47396. readonly hasRenderTargetTextures: boolean;
  47397. /**
  47398. * Gets the name of the material class.
  47399. */
  47400. getClassName(): string;
  47401. /**
  47402. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47403. */
  47404. /**
  47405. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47406. */
  47407. useLogarithmicDepth: boolean;
  47408. /**
  47409. * Gets the current transparency mode.
  47410. */
  47411. /**
  47412. * Sets the transparency mode of the material.
  47413. *
  47414. * | Value | Type | Description |
  47415. * | ----- | ----------------------------------- | ----------- |
  47416. * | 0 | OPAQUE | |
  47417. * | 1 | ALPHATEST | |
  47418. * | 2 | ALPHABLEND | |
  47419. * | 3 | ALPHATESTANDBLEND | |
  47420. *
  47421. */
  47422. transparencyMode: Nullable<number>;
  47423. /**
  47424. * Returns true if alpha blending should be disabled.
  47425. */
  47426. private readonly _disableAlphaBlending;
  47427. /**
  47428. * Specifies whether or not this material should be rendered in alpha blend mode.
  47429. */
  47430. needAlphaBlending(): boolean;
  47431. /**
  47432. * Specifies if the mesh will require alpha blending.
  47433. * @param mesh - BJS mesh.
  47434. */
  47435. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47436. /**
  47437. * Specifies whether or not this material should be rendered in alpha test mode.
  47438. */
  47439. needAlphaTesting(): boolean;
  47440. /**
  47441. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47442. */
  47443. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47444. /**
  47445. * Gets the texture used for the alpha test.
  47446. */
  47447. getAlphaTestTexture(): Nullable<BaseTexture>;
  47448. /**
  47449. * Specifies that the submesh is ready to be used.
  47450. * @param mesh - BJS mesh.
  47451. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47452. * @param useInstances - Specifies that instances should be used.
  47453. * @returns - boolean indicating that the submesh is ready or not.
  47454. */
  47455. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47456. /**
  47457. * Specifies if the material uses metallic roughness workflow.
  47458. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47459. */
  47460. isMetallicWorkflow(): boolean;
  47461. private _prepareEffect;
  47462. private _prepareDefines;
  47463. /**
  47464. * Force shader compilation
  47465. */
  47466. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47467. clipPlane: boolean;
  47468. }>): void;
  47469. /**
  47470. * Initializes the uniform buffer layout for the shader.
  47471. */
  47472. buildUniformLayout(): void;
  47473. /**
  47474. * Unbinds the material from the mesh
  47475. */
  47476. unbind(): void;
  47477. /**
  47478. * Binds the submesh data.
  47479. * @param world - The world matrix.
  47480. * @param mesh - The BJS mesh.
  47481. * @param subMesh - A submesh of the BJS mesh.
  47482. */
  47483. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47484. /**
  47485. * Returns the animatable textures.
  47486. * @returns - Array of animatable textures.
  47487. */
  47488. getAnimatables(): IAnimatable[];
  47489. /**
  47490. * Returns the texture used for reflections.
  47491. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47492. */
  47493. private _getReflectionTexture;
  47494. /**
  47495. * Returns an array of the actively used textures.
  47496. * @returns - Array of BaseTextures
  47497. */
  47498. getActiveTextures(): BaseTexture[];
  47499. /**
  47500. * Checks to see if a texture is used in the material.
  47501. * @param texture - Base texture to use.
  47502. * @returns - Boolean specifying if a texture is used in the material.
  47503. */
  47504. hasTexture(texture: BaseTexture): boolean;
  47505. /**
  47506. * Disposes the resources of the material.
  47507. * @param forceDisposeEffect - Forces the disposal of effects.
  47508. * @param forceDisposeTextures - Forces the disposal of all textures.
  47509. */
  47510. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47511. }
  47512. }
  47513. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47514. import { Nullable } from "babylonjs/types";
  47515. import { Scene } from "babylonjs/scene";
  47516. import { Color3 } from "babylonjs/Maths/math";
  47517. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47518. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47519. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47520. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47521. /**
  47522. * The Physically based material of BJS.
  47523. *
  47524. * This offers the main features of a standard PBR material.
  47525. * For more information, please refer to the documentation :
  47526. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47527. */
  47528. export class PBRMaterial extends PBRBaseMaterial {
  47529. /**
  47530. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47531. */
  47532. static readonly PBRMATERIAL_OPAQUE: number;
  47533. /**
  47534. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47535. */
  47536. static readonly PBRMATERIAL_ALPHATEST: number;
  47537. /**
  47538. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47539. */
  47540. static readonly PBRMATERIAL_ALPHABLEND: number;
  47541. /**
  47542. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47543. * They are also discarded below the alpha cutoff threshold to improve performances.
  47544. */
  47545. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47546. /**
  47547. * Defines the default value of how much AO map is occluding the analytical lights
  47548. * (point spot...).
  47549. */
  47550. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47551. /**
  47552. * Intensity of the direct lights e.g. the four lights available in your scene.
  47553. * This impacts both the direct diffuse and specular highlights.
  47554. */
  47555. directIntensity: number;
  47556. /**
  47557. * Intensity of the emissive part of the material.
  47558. * This helps controlling the emissive effect without modifying the emissive color.
  47559. */
  47560. emissiveIntensity: number;
  47561. /**
  47562. * Intensity of the environment e.g. how much the environment will light the object
  47563. * either through harmonics for rough material or through the refelction for shiny ones.
  47564. */
  47565. environmentIntensity: number;
  47566. /**
  47567. * This is a special control allowing the reduction of the specular highlights coming from the
  47568. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47569. */
  47570. specularIntensity: number;
  47571. /**
  47572. * Debug Control allowing disabling the bump map on this material.
  47573. */
  47574. disableBumpMap: boolean;
  47575. /**
  47576. * AKA Diffuse Texture in standard nomenclature.
  47577. */
  47578. albedoTexture: BaseTexture;
  47579. /**
  47580. * AKA Occlusion Texture in other nomenclature.
  47581. */
  47582. ambientTexture: BaseTexture;
  47583. /**
  47584. * AKA Occlusion Texture Intensity in other nomenclature.
  47585. */
  47586. ambientTextureStrength: number;
  47587. /**
  47588. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47589. * 1 means it completely occludes it
  47590. * 0 mean it has no impact
  47591. */
  47592. ambientTextureImpactOnAnalyticalLights: number;
  47593. /**
  47594. * Stores the alpha values in a texture.
  47595. */
  47596. opacityTexture: BaseTexture;
  47597. /**
  47598. * Stores the reflection values in a texture.
  47599. */
  47600. reflectionTexture: Nullable<BaseTexture>;
  47601. /**
  47602. * Stores the emissive values in a texture.
  47603. */
  47604. emissiveTexture: BaseTexture;
  47605. /**
  47606. * AKA Specular texture in other nomenclature.
  47607. */
  47608. reflectivityTexture: BaseTexture;
  47609. /**
  47610. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47611. */
  47612. metallicTexture: BaseTexture;
  47613. /**
  47614. * Specifies the metallic scalar of the metallic/roughness workflow.
  47615. * Can also be used to scale the metalness values of the metallic texture.
  47616. */
  47617. metallic: Nullable<number>;
  47618. /**
  47619. * Specifies the roughness scalar of the metallic/roughness workflow.
  47620. * Can also be used to scale the roughness values of the metallic texture.
  47621. */
  47622. roughness: Nullable<number>;
  47623. /**
  47624. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47625. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47626. */
  47627. microSurfaceTexture: BaseTexture;
  47628. /**
  47629. * Stores surface normal data used to displace a mesh in a texture.
  47630. */
  47631. bumpTexture: BaseTexture;
  47632. /**
  47633. * Stores the pre-calculated light information of a mesh in a texture.
  47634. */
  47635. lightmapTexture: BaseTexture;
  47636. /**
  47637. * Stores the refracted light information in a texture.
  47638. */
  47639. refractionTexture: Nullable<BaseTexture>;
  47640. /**
  47641. * The color of a material in ambient lighting.
  47642. */
  47643. ambientColor: Color3;
  47644. /**
  47645. * AKA Diffuse Color in other nomenclature.
  47646. */
  47647. albedoColor: Color3;
  47648. /**
  47649. * AKA Specular Color in other nomenclature.
  47650. */
  47651. reflectivityColor: Color3;
  47652. /**
  47653. * The color reflected from the material.
  47654. */
  47655. reflectionColor: Color3;
  47656. /**
  47657. * The color emitted from the material.
  47658. */
  47659. emissiveColor: Color3;
  47660. /**
  47661. * AKA Glossiness in other nomenclature.
  47662. */
  47663. microSurface: number;
  47664. /**
  47665. * source material index of refraction (IOR)' / 'destination material IOR.
  47666. */
  47667. indexOfRefraction: number;
  47668. /**
  47669. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47670. */
  47671. invertRefractionY: boolean;
  47672. /**
  47673. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47674. * Materials half opaque for instance using refraction could benefit from this control.
  47675. */
  47676. linkRefractionWithTransparency: boolean;
  47677. /**
  47678. * If true, the light map contains occlusion information instead of lighting info.
  47679. */
  47680. useLightmapAsShadowmap: boolean;
  47681. /**
  47682. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47683. */
  47684. useAlphaFromAlbedoTexture: boolean;
  47685. /**
  47686. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47687. */
  47688. forceAlphaTest: boolean;
  47689. /**
  47690. * Defines the alpha limits in alpha test mode.
  47691. */
  47692. alphaCutOff: number;
  47693. /**
  47694. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47695. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47696. */
  47697. useSpecularOverAlpha: boolean;
  47698. /**
  47699. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47700. */
  47701. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47702. /**
  47703. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47704. */
  47705. useRoughnessFromMetallicTextureAlpha: boolean;
  47706. /**
  47707. * Specifies if the metallic texture contains the roughness information in its green channel.
  47708. */
  47709. useRoughnessFromMetallicTextureGreen: boolean;
  47710. /**
  47711. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47712. */
  47713. useMetallnessFromMetallicTextureBlue: boolean;
  47714. /**
  47715. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47716. */
  47717. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47718. /**
  47719. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47720. */
  47721. useAmbientInGrayScale: boolean;
  47722. /**
  47723. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47724. * The material will try to infer what glossiness each pixel should be.
  47725. */
  47726. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47727. /**
  47728. * BJS is using an harcoded light falloff based on a manually sets up range.
  47729. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47730. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47731. */
  47732. /**
  47733. * BJS is using an harcoded light falloff based on a manually sets up range.
  47734. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47735. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47736. */
  47737. usePhysicalLightFalloff: boolean;
  47738. /**
  47739. * In order to support the falloff compatibility with gltf, a special mode has been added
  47740. * to reproduce the gltf light falloff.
  47741. */
  47742. /**
  47743. * In order to support the falloff compatibility with gltf, a special mode has been added
  47744. * to reproduce the gltf light falloff.
  47745. */
  47746. useGLTFLightFalloff: boolean;
  47747. /**
  47748. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47749. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47750. */
  47751. useRadianceOverAlpha: boolean;
  47752. /**
  47753. * Allows using an object space normal map (instead of tangent space).
  47754. */
  47755. useObjectSpaceNormalMap: boolean;
  47756. /**
  47757. * Allows using the bump map in parallax mode.
  47758. */
  47759. useParallax: boolean;
  47760. /**
  47761. * Allows using the bump map in parallax occlusion mode.
  47762. */
  47763. useParallaxOcclusion: boolean;
  47764. /**
  47765. * Controls the scale bias of the parallax mode.
  47766. */
  47767. parallaxScaleBias: number;
  47768. /**
  47769. * If sets to true, disables all the lights affecting the material.
  47770. */
  47771. disableLighting: boolean;
  47772. /**
  47773. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47774. */
  47775. forceIrradianceInFragment: boolean;
  47776. /**
  47777. * Number of Simultaneous lights allowed on the material.
  47778. */
  47779. maxSimultaneousLights: number;
  47780. /**
  47781. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47782. */
  47783. invertNormalMapX: boolean;
  47784. /**
  47785. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47786. */
  47787. invertNormalMapY: boolean;
  47788. /**
  47789. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47790. */
  47791. twoSidedLighting: boolean;
  47792. /**
  47793. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47794. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47795. */
  47796. useAlphaFresnel: boolean;
  47797. /**
  47798. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47799. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47800. */
  47801. useLinearAlphaFresnel: boolean;
  47802. /**
  47803. * Let user defines the brdf lookup texture used for IBL.
  47804. * A default 8bit version is embedded but you could point at :
  47805. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47806. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47807. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47808. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47809. */
  47810. environmentBRDFTexture: Nullable<BaseTexture>;
  47811. /**
  47812. * Force normal to face away from face.
  47813. */
  47814. forceNormalForward: boolean;
  47815. /**
  47816. * Enables specular anti aliasing in the PBR shader.
  47817. * It will both interacts on the Geometry for analytical and IBL lighting.
  47818. * It also prefilter the roughness map based on the bump values.
  47819. */
  47820. enableSpecularAntiAliasing: boolean;
  47821. /**
  47822. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47823. * makes the reflect vector face the model (under horizon).
  47824. */
  47825. useHorizonOcclusion: boolean;
  47826. /**
  47827. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47828. * too much the area relying on ambient texture to define their ambient occlusion.
  47829. */
  47830. useRadianceOcclusion: boolean;
  47831. /**
  47832. * If set to true, no lighting calculations will be applied.
  47833. */
  47834. unlit: boolean;
  47835. /**
  47836. * Gets the image processing configuration used either in this material.
  47837. */
  47838. /**
  47839. * Sets the Default image processing configuration used either in the this material.
  47840. *
  47841. * If sets to null, the scene one is in use.
  47842. */
  47843. imageProcessingConfiguration: ImageProcessingConfiguration;
  47844. /**
  47845. * Gets wether the color curves effect is enabled.
  47846. */
  47847. /**
  47848. * Sets wether the color curves effect is enabled.
  47849. */
  47850. cameraColorCurvesEnabled: boolean;
  47851. /**
  47852. * Gets wether the color grading effect is enabled.
  47853. */
  47854. /**
  47855. * Gets wether the color grading effect is enabled.
  47856. */
  47857. cameraColorGradingEnabled: boolean;
  47858. /**
  47859. * Gets wether tonemapping is enabled or not.
  47860. */
  47861. /**
  47862. * Sets wether tonemapping is enabled or not
  47863. */
  47864. cameraToneMappingEnabled: boolean;
  47865. /**
  47866. * The camera exposure used on this material.
  47867. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47868. * This corresponds to a photographic exposure.
  47869. */
  47870. /**
  47871. * The camera exposure used on this material.
  47872. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47873. * This corresponds to a photographic exposure.
  47874. */
  47875. cameraExposure: number;
  47876. /**
  47877. * Gets The camera contrast used on this material.
  47878. */
  47879. /**
  47880. * Sets The camera contrast used on this material.
  47881. */
  47882. cameraContrast: number;
  47883. /**
  47884. * Gets the Color Grading 2D Lookup Texture.
  47885. */
  47886. /**
  47887. * Sets the Color Grading 2D Lookup Texture.
  47888. */
  47889. cameraColorGradingTexture: Nullable<BaseTexture>;
  47890. /**
  47891. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47892. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47893. * 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;
  47894. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47895. */
  47896. /**
  47897. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47898. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47899. * 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;
  47900. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47901. */
  47902. cameraColorCurves: Nullable<ColorCurves>;
  47903. /**
  47904. * Instantiates a new PBRMaterial instance.
  47905. *
  47906. * @param name The material name
  47907. * @param scene The scene the material will be use in.
  47908. */
  47909. constructor(name: string, scene: Scene);
  47910. /**
  47911. * Returns the name of this material class.
  47912. */
  47913. getClassName(): string;
  47914. /**
  47915. * Makes a duplicate of the current material.
  47916. * @param name - name to use for the new material.
  47917. */
  47918. clone(name: string): PBRMaterial;
  47919. /**
  47920. * Serializes this PBR Material.
  47921. * @returns - An object with the serialized material.
  47922. */
  47923. serialize(): any;
  47924. /**
  47925. * Parses a PBR Material from a serialized object.
  47926. * @param source - Serialized object.
  47927. * @param scene - BJS scene instance.
  47928. * @param rootUrl - url for the scene object
  47929. * @returns - PBRMaterial
  47930. */
  47931. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47932. }
  47933. }
  47934. declare module "babylonjs/Misc/dds" {
  47935. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47936. import { Engine } from "babylonjs/Engines/engine";
  47937. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47938. import { Nullable } from "babylonjs/types";
  47939. import { Scene } from "babylonjs/scene";
  47940. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  47941. /**
  47942. * Direct draw surface info
  47943. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47944. */
  47945. export interface DDSInfo {
  47946. /**
  47947. * Width of the texture
  47948. */
  47949. width: number;
  47950. /**
  47951. * Width of the texture
  47952. */
  47953. height: number;
  47954. /**
  47955. * Number of Mipmaps for the texture
  47956. * @see https://en.wikipedia.org/wiki/Mipmap
  47957. */
  47958. mipmapCount: number;
  47959. /**
  47960. * If the textures format is a known fourCC format
  47961. * @see https://www.fourcc.org/
  47962. */
  47963. isFourCC: boolean;
  47964. /**
  47965. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47966. */
  47967. isRGB: boolean;
  47968. /**
  47969. * If the texture is a lumincance format
  47970. */
  47971. isLuminance: boolean;
  47972. /**
  47973. * If this is a cube texture
  47974. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47975. */
  47976. isCube: boolean;
  47977. /**
  47978. * If the texture is a compressed format eg. FOURCC_DXT1
  47979. */
  47980. isCompressed: boolean;
  47981. /**
  47982. * The dxgiFormat of the texture
  47983. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47984. */
  47985. dxgiFormat: number;
  47986. /**
  47987. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47988. */
  47989. textureType: number;
  47990. /**
  47991. * Sphericle polynomial created for the dds texture
  47992. */
  47993. sphericalPolynomial?: SphericalPolynomial;
  47994. }
  47995. /**
  47996. * Class used to provide DDS decompression tools
  47997. */
  47998. export class DDSTools {
  47999. /**
  48000. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48001. */
  48002. static StoreLODInAlphaChannel: boolean;
  48003. /**
  48004. * Gets DDS information from an array buffer
  48005. * @param arrayBuffer defines the array buffer to read data from
  48006. * @returns the DDS information
  48007. */
  48008. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48009. private static _FloatView;
  48010. private static _Int32View;
  48011. private static _ToHalfFloat;
  48012. private static _FromHalfFloat;
  48013. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48014. private static _GetHalfFloatRGBAArrayBuffer;
  48015. private static _GetFloatRGBAArrayBuffer;
  48016. private static _GetFloatAsUIntRGBAArrayBuffer;
  48017. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48018. private static _GetRGBAArrayBuffer;
  48019. private static _ExtractLongWordOrder;
  48020. private static _GetRGBArrayBuffer;
  48021. private static _GetLuminanceArrayBuffer;
  48022. /**
  48023. * Uploads DDS Levels to a Babylon Texture
  48024. * @hidden
  48025. */
  48026. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48027. }
  48028. module "babylonjs/Engines/engine" {
  48029. interface Engine {
  48030. /**
  48031. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48032. * @param rootUrl defines the url where the file to load is located
  48033. * @param scene defines the current scene
  48034. * @param lodScale defines scale to apply to the mip map selection
  48035. * @param lodOffset defines offset to apply to the mip map selection
  48036. * @param onLoad defines an optional callback raised when the texture is loaded
  48037. * @param onError defines an optional callback raised if there is an issue to load the texture
  48038. * @param format defines the format of the data
  48039. * @param forcedExtension defines the extension to use to pick the right loader
  48040. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48041. * @returns the cube texture as an InternalTexture
  48042. */
  48043. 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;
  48044. }
  48045. }
  48046. }
  48047. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48048. import { Nullable } from "babylonjs/types";
  48049. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48050. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48051. /**
  48052. * Implementation of the DDS Texture Loader.
  48053. * @hidden
  48054. */
  48055. export class _DDSTextureLoader implements IInternalTextureLoader {
  48056. /**
  48057. * Defines wether the loader supports cascade loading the different faces.
  48058. */
  48059. readonly supportCascades: boolean;
  48060. /**
  48061. * This returns if the loader support the current file information.
  48062. * @param extension defines the file extension of the file being loaded
  48063. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48064. * @param fallback defines the fallback internal texture if any
  48065. * @param isBase64 defines whether the texture is encoded as a base64
  48066. * @param isBuffer defines whether the texture data are stored as a buffer
  48067. * @returns true if the loader can load the specified file
  48068. */
  48069. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48070. /**
  48071. * Transform the url before loading if required.
  48072. * @param rootUrl the url of the texture
  48073. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48074. * @returns the transformed texture
  48075. */
  48076. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48077. /**
  48078. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48079. * @param rootUrl the url of the texture
  48080. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48081. * @returns the fallback texture
  48082. */
  48083. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48084. /**
  48085. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48086. * @param data contains the texture data
  48087. * @param texture defines the BabylonJS internal texture
  48088. * @param createPolynomials will be true if polynomials have been requested
  48089. * @param onLoad defines the callback to trigger once the texture is ready
  48090. * @param onError defines the callback to trigger in case of error
  48091. */
  48092. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48093. /**
  48094. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48095. * @param data contains the texture data
  48096. * @param texture defines the BabylonJS internal texture
  48097. * @param callback defines the method to call once ready to upload
  48098. */
  48099. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48100. }
  48101. }
  48102. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48103. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48104. /** @hidden */
  48105. export var rgbdEncodePixelShader: {
  48106. name: string;
  48107. shader: string;
  48108. };
  48109. }
  48110. declare module "babylonjs/Misc/environmentTextureTools" {
  48111. import { Nullable } from "babylonjs/types";
  48112. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48113. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48114. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48115. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48116. import "babylonjs/Shaders/rgbdEncode.fragment";
  48117. import "babylonjs/Shaders/rgbdDecode.fragment";
  48118. /**
  48119. * Raw texture data and descriptor sufficient for WebGL texture upload
  48120. */
  48121. export interface EnvironmentTextureInfo {
  48122. /**
  48123. * Version of the environment map
  48124. */
  48125. version: number;
  48126. /**
  48127. * Width of image
  48128. */
  48129. width: number;
  48130. /**
  48131. * Irradiance information stored in the file.
  48132. */
  48133. irradiance: any;
  48134. /**
  48135. * Specular information stored in the file.
  48136. */
  48137. specular: any;
  48138. }
  48139. /**
  48140. * Sets of helpers addressing the serialization and deserialization of environment texture
  48141. * stored in a BabylonJS env file.
  48142. * Those files are usually stored as .env files.
  48143. */
  48144. export class EnvironmentTextureTools {
  48145. /**
  48146. * Magic number identifying the env file.
  48147. */
  48148. private static _MagicBytes;
  48149. /**
  48150. * Gets the environment info from an env file.
  48151. * @param data The array buffer containing the .env bytes.
  48152. * @returns the environment file info (the json header) if successfully parsed.
  48153. */
  48154. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48155. /**
  48156. * Creates an environment texture from a loaded cube texture.
  48157. * @param texture defines the cube texture to convert in env file
  48158. * @return a promise containing the environment data if succesfull.
  48159. */
  48160. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48161. /**
  48162. * Creates a JSON representation of the spherical data.
  48163. * @param texture defines the texture containing the polynomials
  48164. * @return the JSON representation of the spherical info
  48165. */
  48166. private static _CreateEnvTextureIrradiance;
  48167. /**
  48168. * Uploads the texture info contained in the env file to the GPU.
  48169. * @param texture defines the internal texture to upload to
  48170. * @param arrayBuffer defines the buffer cotaining the data to load
  48171. * @param info defines the texture info retrieved through the GetEnvInfo method
  48172. * @returns a promise
  48173. */
  48174. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48175. /**
  48176. * Uploads the levels of image data to the GPU.
  48177. * @param texture defines the internal texture to upload to
  48178. * @param imageData defines the array buffer views of image data [mipmap][face]
  48179. * @returns a promise
  48180. */
  48181. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48182. /**
  48183. * Uploads spherical polynomials information to the texture.
  48184. * @param texture defines the texture we are trying to upload the information to
  48185. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48186. */
  48187. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48188. /** @hidden */
  48189. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48190. }
  48191. }
  48192. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48193. import { Nullable } from "babylonjs/types";
  48194. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48195. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48196. /**
  48197. * Implementation of the ENV Texture Loader.
  48198. * @hidden
  48199. */
  48200. export class _ENVTextureLoader implements IInternalTextureLoader {
  48201. /**
  48202. * Defines wether the loader supports cascade loading the different faces.
  48203. */
  48204. readonly supportCascades: boolean;
  48205. /**
  48206. * This returns if the loader support the current file information.
  48207. * @param extension defines the file extension of the file being loaded
  48208. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48209. * @param fallback defines the fallback internal texture if any
  48210. * @param isBase64 defines whether the texture is encoded as a base64
  48211. * @param isBuffer defines whether the texture data are stored as a buffer
  48212. * @returns true if the loader can load the specified file
  48213. */
  48214. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48215. /**
  48216. * Transform the url before loading if required.
  48217. * @param rootUrl the url of the texture
  48218. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48219. * @returns the transformed texture
  48220. */
  48221. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48222. /**
  48223. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48224. * @param rootUrl the url of the texture
  48225. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48226. * @returns the fallback texture
  48227. */
  48228. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48229. /**
  48230. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48231. * @param data contains the texture data
  48232. * @param texture defines the BabylonJS internal texture
  48233. * @param createPolynomials will be true if polynomials have been requested
  48234. * @param onLoad defines the callback to trigger once the texture is ready
  48235. * @param onError defines the callback to trigger in case of error
  48236. */
  48237. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48238. /**
  48239. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48240. * @param data contains the texture data
  48241. * @param texture defines the BabylonJS internal texture
  48242. * @param callback defines the method to call once ready to upload
  48243. */
  48244. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48245. }
  48246. }
  48247. declare module "babylonjs/Misc/khronosTextureContainer" {
  48248. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48249. /**
  48250. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48251. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48252. */
  48253. export class KhronosTextureContainer {
  48254. /** contents of the KTX container file */
  48255. arrayBuffer: any;
  48256. private static HEADER_LEN;
  48257. private static COMPRESSED_2D;
  48258. private static COMPRESSED_3D;
  48259. private static TEX_2D;
  48260. private static TEX_3D;
  48261. /**
  48262. * Gets the openGL type
  48263. */
  48264. glType: number;
  48265. /**
  48266. * Gets the openGL type size
  48267. */
  48268. glTypeSize: number;
  48269. /**
  48270. * Gets the openGL format
  48271. */
  48272. glFormat: number;
  48273. /**
  48274. * Gets the openGL internal format
  48275. */
  48276. glInternalFormat: number;
  48277. /**
  48278. * Gets the base internal format
  48279. */
  48280. glBaseInternalFormat: number;
  48281. /**
  48282. * Gets image width in pixel
  48283. */
  48284. pixelWidth: number;
  48285. /**
  48286. * Gets image height in pixel
  48287. */
  48288. pixelHeight: number;
  48289. /**
  48290. * Gets image depth in pixels
  48291. */
  48292. pixelDepth: number;
  48293. /**
  48294. * Gets the number of array elements
  48295. */
  48296. numberOfArrayElements: number;
  48297. /**
  48298. * Gets the number of faces
  48299. */
  48300. numberOfFaces: number;
  48301. /**
  48302. * Gets the number of mipmap levels
  48303. */
  48304. numberOfMipmapLevels: number;
  48305. /**
  48306. * Gets the bytes of key value data
  48307. */
  48308. bytesOfKeyValueData: number;
  48309. /**
  48310. * Gets the load type
  48311. */
  48312. loadType: number;
  48313. /**
  48314. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48315. */
  48316. isInvalid: boolean;
  48317. /**
  48318. * Creates a new KhronosTextureContainer
  48319. * @param arrayBuffer contents of the KTX container file
  48320. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48321. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48322. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48323. */
  48324. constructor(
  48325. /** contents of the KTX container file */
  48326. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48327. /**
  48328. * Uploads KTX content to a Babylon Texture.
  48329. * It is assumed that the texture has already been created & is currently bound
  48330. * @hidden
  48331. */
  48332. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48333. private _upload2DCompressedLevels;
  48334. }
  48335. }
  48336. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48337. import { Nullable } from "babylonjs/types";
  48338. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48339. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48340. /**
  48341. * Implementation of the KTX Texture Loader.
  48342. * @hidden
  48343. */
  48344. export class _KTXTextureLoader implements IInternalTextureLoader {
  48345. /**
  48346. * Defines wether the loader supports cascade loading the different faces.
  48347. */
  48348. readonly supportCascades: boolean;
  48349. /**
  48350. * This returns if the loader support the current file information.
  48351. * @param extension defines the file extension of the file being loaded
  48352. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48353. * @param fallback defines the fallback internal texture if any
  48354. * @param isBase64 defines whether the texture is encoded as a base64
  48355. * @param isBuffer defines whether the texture data are stored as a buffer
  48356. * @returns true if the loader can load the specified file
  48357. */
  48358. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48359. /**
  48360. * Transform the url before loading if required.
  48361. * @param rootUrl the url of the texture
  48362. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48363. * @returns the transformed texture
  48364. */
  48365. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48366. /**
  48367. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48368. * @param rootUrl the url of the texture
  48369. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48370. * @returns the fallback texture
  48371. */
  48372. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48373. /**
  48374. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48375. * @param data contains the texture data
  48376. * @param texture defines the BabylonJS internal texture
  48377. * @param createPolynomials will be true if polynomials have been requested
  48378. * @param onLoad defines the callback to trigger once the texture is ready
  48379. * @param onError defines the callback to trigger in case of error
  48380. */
  48381. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48382. /**
  48383. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48384. * @param data contains the texture data
  48385. * @param texture defines the BabylonJS internal texture
  48386. * @param callback defines the method to call once ready to upload
  48387. */
  48388. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48389. }
  48390. }
  48391. declare module "babylonjs/Helpers/sceneHelpers" {
  48392. import { Nullable } from "babylonjs/types";
  48393. import { Mesh } from "babylonjs/Meshes/mesh";
  48394. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48395. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48396. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48397. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48398. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48399. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48400. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48401. import "babylonjs/Meshes/Builders/boxBuilder";
  48402. /** @hidden */
  48403. export var _forceSceneHelpersToBundle: boolean;
  48404. module "babylonjs/scene" {
  48405. interface Scene {
  48406. /**
  48407. * Creates a default light for the scene.
  48408. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48409. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48410. */
  48411. createDefaultLight(replace?: boolean): void;
  48412. /**
  48413. * Creates a default camera for the scene.
  48414. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48415. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48416. * @param replace has default false, when true replaces the active camera in the scene
  48417. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48418. */
  48419. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48420. /**
  48421. * Creates a default camera and a default light.
  48422. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48423. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48424. * @param replace has the default false, when true replaces the active camera/light in the scene
  48425. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48426. */
  48427. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48428. /**
  48429. * Creates a new sky box
  48430. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48431. * @param environmentTexture defines the texture to use as environment texture
  48432. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48433. * @param scale defines the overall scale of the skybox
  48434. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48435. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48436. * @returns a new mesh holding the sky box
  48437. */
  48438. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48439. /**
  48440. * Creates a new environment
  48441. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48442. * @param options defines the options you can use to configure the environment
  48443. * @returns the new EnvironmentHelper
  48444. */
  48445. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48446. /**
  48447. * Creates a new VREXperienceHelper
  48448. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48449. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48450. * @returns a new VREXperienceHelper
  48451. */
  48452. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48453. /**
  48454. * Creates a new XREXperienceHelper
  48455. * @see http://doc.babylonjs.com/how_to/webxr
  48456. * @returns a promise for a new XREXperienceHelper
  48457. */
  48458. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48459. }
  48460. }
  48461. }
  48462. declare module "babylonjs/Helpers/videoDome" {
  48463. import { Scene } from "babylonjs/scene";
  48464. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48465. import { Mesh } from "babylonjs/Meshes/mesh";
  48466. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48467. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48468. import "babylonjs/Meshes/Builders/sphereBuilder";
  48469. /**
  48470. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48471. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48472. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48473. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48474. */
  48475. export class VideoDome extends TransformNode {
  48476. /**
  48477. * Define the video source as a Monoscopic panoramic 360 video.
  48478. */
  48479. static readonly MODE_MONOSCOPIC: number;
  48480. /**
  48481. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48482. */
  48483. static readonly MODE_TOPBOTTOM: number;
  48484. /**
  48485. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48486. */
  48487. static readonly MODE_SIDEBYSIDE: number;
  48488. private _useDirectMapping;
  48489. /**
  48490. * The video texture being displayed on the sphere
  48491. */
  48492. protected _videoTexture: VideoTexture;
  48493. /**
  48494. * Gets the video texture being displayed on the sphere
  48495. */
  48496. readonly videoTexture: VideoTexture;
  48497. /**
  48498. * The skybox material
  48499. */
  48500. protected _material: BackgroundMaterial;
  48501. /**
  48502. * The surface used for the skybox
  48503. */
  48504. protected _mesh: Mesh;
  48505. /**
  48506. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48507. * Also see the options.resolution property.
  48508. */
  48509. fovMultiplier: number;
  48510. private _videoMode;
  48511. /**
  48512. * Gets or set the current video mode for the video. It can be:
  48513. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48514. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48515. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48516. */
  48517. videoMode: number;
  48518. /**
  48519. * Oberserver used in Stereoscopic VR Mode.
  48520. */
  48521. private _onBeforeCameraRenderObserver;
  48522. /**
  48523. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48524. * @param name Element's name, child elements will append suffixes for their own names.
  48525. * @param urlsOrVideo defines the url(s) or the video element to use
  48526. * @param options An object containing optional or exposed sub element properties
  48527. */
  48528. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48529. resolution?: number;
  48530. clickToPlay?: boolean;
  48531. autoPlay?: boolean;
  48532. loop?: boolean;
  48533. size?: number;
  48534. poster?: string;
  48535. faceForward?: boolean;
  48536. useDirectMapping?: boolean;
  48537. }, scene: Scene);
  48538. private _changeVideoMode;
  48539. /**
  48540. * Releases resources associated with this node.
  48541. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48542. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48543. */
  48544. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48545. }
  48546. }
  48547. declare module "babylonjs/Helpers/index" {
  48548. export * from "babylonjs/Helpers/environmentHelper";
  48549. export * from "babylonjs/Helpers/photoDome";
  48550. export * from "babylonjs/Helpers/sceneHelpers";
  48551. export * from "babylonjs/Helpers/videoDome";
  48552. }
  48553. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48554. import { PerfCounter } from "babylonjs/Misc/tools";
  48555. import { IDisposable } from "babylonjs/scene";
  48556. import { Engine } from "babylonjs/Engines/engine";
  48557. /**
  48558. * This class can be used to get instrumentation data from a Babylon engine
  48559. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48560. */
  48561. export class EngineInstrumentation implements IDisposable {
  48562. /**
  48563. * Define the instrumented engine.
  48564. */
  48565. engine: Engine;
  48566. private _captureGPUFrameTime;
  48567. private _gpuFrameTimeToken;
  48568. private _gpuFrameTime;
  48569. private _captureShaderCompilationTime;
  48570. private _shaderCompilationTime;
  48571. private _onBeginFrameObserver;
  48572. private _onEndFrameObserver;
  48573. private _onBeforeShaderCompilationObserver;
  48574. private _onAfterShaderCompilationObserver;
  48575. /**
  48576. * Gets the perf counter used for GPU frame time
  48577. */
  48578. readonly gpuFrameTimeCounter: PerfCounter;
  48579. /**
  48580. * Gets the GPU frame time capture status
  48581. */
  48582. /**
  48583. * Enable or disable the GPU frame time capture
  48584. */
  48585. captureGPUFrameTime: boolean;
  48586. /**
  48587. * Gets the perf counter used for shader compilation time
  48588. */
  48589. readonly shaderCompilationTimeCounter: PerfCounter;
  48590. /**
  48591. * Gets the shader compilation time capture status
  48592. */
  48593. /**
  48594. * Enable or disable the shader compilation time capture
  48595. */
  48596. captureShaderCompilationTime: boolean;
  48597. /**
  48598. * Instantiates a new engine instrumentation.
  48599. * This class can be used to get instrumentation data from a Babylon engine
  48600. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48601. * @param engine Defines the engine to instrument
  48602. */
  48603. constructor(
  48604. /**
  48605. * Define the instrumented engine.
  48606. */
  48607. engine: Engine);
  48608. /**
  48609. * Dispose and release associated resources.
  48610. */
  48611. dispose(): void;
  48612. }
  48613. }
  48614. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48615. import { PerfCounter } from "babylonjs/Misc/tools";
  48616. import { Scene, IDisposable } from "babylonjs/scene";
  48617. /**
  48618. * This class can be used to get instrumentation data from a Babylon engine
  48619. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48620. */
  48621. export class SceneInstrumentation implements IDisposable {
  48622. /**
  48623. * Defines the scene to instrument
  48624. */
  48625. scene: Scene;
  48626. private _captureActiveMeshesEvaluationTime;
  48627. private _activeMeshesEvaluationTime;
  48628. private _captureRenderTargetsRenderTime;
  48629. private _renderTargetsRenderTime;
  48630. private _captureFrameTime;
  48631. private _frameTime;
  48632. private _captureRenderTime;
  48633. private _renderTime;
  48634. private _captureInterFrameTime;
  48635. private _interFrameTime;
  48636. private _captureParticlesRenderTime;
  48637. private _particlesRenderTime;
  48638. private _captureSpritesRenderTime;
  48639. private _spritesRenderTime;
  48640. private _capturePhysicsTime;
  48641. private _physicsTime;
  48642. private _captureAnimationsTime;
  48643. private _animationsTime;
  48644. private _captureCameraRenderTime;
  48645. private _cameraRenderTime;
  48646. private _onBeforeActiveMeshesEvaluationObserver;
  48647. private _onAfterActiveMeshesEvaluationObserver;
  48648. private _onBeforeRenderTargetsRenderObserver;
  48649. private _onAfterRenderTargetsRenderObserver;
  48650. private _onAfterRenderObserver;
  48651. private _onBeforeDrawPhaseObserver;
  48652. private _onAfterDrawPhaseObserver;
  48653. private _onBeforeAnimationsObserver;
  48654. private _onBeforeParticlesRenderingObserver;
  48655. private _onAfterParticlesRenderingObserver;
  48656. private _onBeforeSpritesRenderingObserver;
  48657. private _onAfterSpritesRenderingObserver;
  48658. private _onBeforePhysicsObserver;
  48659. private _onAfterPhysicsObserver;
  48660. private _onAfterAnimationsObserver;
  48661. private _onBeforeCameraRenderObserver;
  48662. private _onAfterCameraRenderObserver;
  48663. /**
  48664. * Gets the perf counter used for active meshes evaluation time
  48665. */
  48666. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48667. /**
  48668. * Gets the active meshes evaluation time capture status
  48669. */
  48670. /**
  48671. * Enable or disable the active meshes evaluation time capture
  48672. */
  48673. captureActiveMeshesEvaluationTime: boolean;
  48674. /**
  48675. * Gets the perf counter used for render targets render time
  48676. */
  48677. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48678. /**
  48679. * Gets the render targets render time capture status
  48680. */
  48681. /**
  48682. * Enable or disable the render targets render time capture
  48683. */
  48684. captureRenderTargetsRenderTime: boolean;
  48685. /**
  48686. * Gets the perf counter used for particles render time
  48687. */
  48688. readonly particlesRenderTimeCounter: PerfCounter;
  48689. /**
  48690. * Gets the particles render time capture status
  48691. */
  48692. /**
  48693. * Enable or disable the particles render time capture
  48694. */
  48695. captureParticlesRenderTime: boolean;
  48696. /**
  48697. * Gets the perf counter used for sprites render time
  48698. */
  48699. readonly spritesRenderTimeCounter: PerfCounter;
  48700. /**
  48701. * Gets the sprites render time capture status
  48702. */
  48703. /**
  48704. * Enable or disable the sprites render time capture
  48705. */
  48706. captureSpritesRenderTime: boolean;
  48707. /**
  48708. * Gets the perf counter used for physics time
  48709. */
  48710. readonly physicsTimeCounter: PerfCounter;
  48711. /**
  48712. * Gets the physics time capture status
  48713. */
  48714. /**
  48715. * Enable or disable the physics time capture
  48716. */
  48717. capturePhysicsTime: boolean;
  48718. /**
  48719. * Gets the perf counter used for animations time
  48720. */
  48721. readonly animationsTimeCounter: PerfCounter;
  48722. /**
  48723. * Gets the animations time capture status
  48724. */
  48725. /**
  48726. * Enable or disable the animations time capture
  48727. */
  48728. captureAnimationsTime: boolean;
  48729. /**
  48730. * Gets the perf counter used for frame time capture
  48731. */
  48732. readonly frameTimeCounter: PerfCounter;
  48733. /**
  48734. * Gets the frame time capture status
  48735. */
  48736. /**
  48737. * Enable or disable the frame time capture
  48738. */
  48739. captureFrameTime: boolean;
  48740. /**
  48741. * Gets the perf counter used for inter-frames time capture
  48742. */
  48743. readonly interFrameTimeCounter: PerfCounter;
  48744. /**
  48745. * Gets the inter-frames time capture status
  48746. */
  48747. /**
  48748. * Enable or disable the inter-frames time capture
  48749. */
  48750. captureInterFrameTime: boolean;
  48751. /**
  48752. * Gets the perf counter used for render time capture
  48753. */
  48754. readonly renderTimeCounter: PerfCounter;
  48755. /**
  48756. * Gets the render time capture status
  48757. */
  48758. /**
  48759. * Enable or disable the render time capture
  48760. */
  48761. captureRenderTime: boolean;
  48762. /**
  48763. * Gets the perf counter used for camera render time capture
  48764. */
  48765. readonly cameraRenderTimeCounter: PerfCounter;
  48766. /**
  48767. * Gets the camera render time capture status
  48768. */
  48769. /**
  48770. * Enable or disable the camera render time capture
  48771. */
  48772. captureCameraRenderTime: boolean;
  48773. /**
  48774. * Gets the perf counter used for draw calls
  48775. */
  48776. readonly drawCallsCounter: PerfCounter;
  48777. /**
  48778. * Instantiates a new scene instrumentation.
  48779. * This class can be used to get instrumentation data from a Babylon engine
  48780. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48781. * @param scene Defines the scene to instrument
  48782. */
  48783. constructor(
  48784. /**
  48785. * Defines the scene to instrument
  48786. */
  48787. scene: Scene);
  48788. /**
  48789. * Dispose and release associated resources.
  48790. */
  48791. dispose(): void;
  48792. }
  48793. }
  48794. declare module "babylonjs/Instrumentation/index" {
  48795. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48796. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48797. export * from "babylonjs/Instrumentation/timeToken";
  48798. }
  48799. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48800. /** @hidden */
  48801. export var glowMapGenerationPixelShader: {
  48802. name: string;
  48803. shader: string;
  48804. };
  48805. }
  48806. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48807. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48808. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48809. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48810. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48811. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48812. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48813. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48814. /** @hidden */
  48815. export var glowMapGenerationVertexShader: {
  48816. name: string;
  48817. shader: string;
  48818. };
  48819. }
  48820. declare module "babylonjs/Layers/effectLayer" {
  48821. import { Observable } from "babylonjs/Misc/observable";
  48822. import { Nullable } from "babylonjs/types";
  48823. import { Camera } from "babylonjs/Cameras/camera";
  48824. import { Scene } from "babylonjs/scene";
  48825. import { Color4, ISize } from "babylonjs/Maths/math";
  48826. import { Engine } from "babylonjs/Engines/engine";
  48827. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48829. import { Mesh } from "babylonjs/Meshes/mesh";
  48830. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48831. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48832. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48833. import { Effect } from "babylonjs/Materials/effect";
  48834. import { Material } from "babylonjs/Materials/material";
  48835. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48836. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48837. /**
  48838. * Effect layer options. This helps customizing the behaviour
  48839. * of the effect layer.
  48840. */
  48841. export interface IEffectLayerOptions {
  48842. /**
  48843. * Multiplication factor apply to the canvas size to compute the render target size
  48844. * used to generated the objects (the smaller the faster).
  48845. */
  48846. mainTextureRatio: number;
  48847. /**
  48848. * Enforces a fixed size texture to ensure effect stability across devices.
  48849. */
  48850. mainTextureFixedSize?: number;
  48851. /**
  48852. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48853. */
  48854. alphaBlendingMode: number;
  48855. /**
  48856. * The camera attached to the layer.
  48857. */
  48858. camera: Nullable<Camera>;
  48859. /**
  48860. * The rendering group to draw the layer in.
  48861. */
  48862. renderingGroupId: number;
  48863. }
  48864. /**
  48865. * The effect layer Helps adding post process effect blended with the main pass.
  48866. *
  48867. * This can be for instance use to generate glow or higlight effects on the scene.
  48868. *
  48869. * The effect layer class can not be used directly and is intented to inherited from to be
  48870. * customized per effects.
  48871. */
  48872. export abstract class EffectLayer {
  48873. private _vertexBuffers;
  48874. private _indexBuffer;
  48875. private _cachedDefines;
  48876. private _effectLayerMapGenerationEffect;
  48877. private _effectLayerOptions;
  48878. private _mergeEffect;
  48879. protected _scene: Scene;
  48880. protected _engine: Engine;
  48881. protected _maxSize: number;
  48882. protected _mainTextureDesiredSize: ISize;
  48883. protected _mainTexture: RenderTargetTexture;
  48884. protected _shouldRender: boolean;
  48885. protected _postProcesses: PostProcess[];
  48886. protected _textures: BaseTexture[];
  48887. protected _emissiveTextureAndColor: {
  48888. texture: Nullable<BaseTexture>;
  48889. color: Color4;
  48890. };
  48891. /**
  48892. * The name of the layer
  48893. */
  48894. name: string;
  48895. /**
  48896. * The clear color of the texture used to generate the glow map.
  48897. */
  48898. neutralColor: Color4;
  48899. /**
  48900. * Specifies wether the highlight layer is enabled or not.
  48901. */
  48902. isEnabled: boolean;
  48903. /**
  48904. * Gets the camera attached to the layer.
  48905. */
  48906. readonly camera: Nullable<Camera>;
  48907. /**
  48908. * Gets the rendering group id the layer should render in.
  48909. */
  48910. readonly renderingGroupId: number;
  48911. /**
  48912. * An event triggered when the effect layer has been disposed.
  48913. */
  48914. onDisposeObservable: Observable<EffectLayer>;
  48915. /**
  48916. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48917. */
  48918. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48919. /**
  48920. * An event triggered when the generated texture is being merged in the scene.
  48921. */
  48922. onBeforeComposeObservable: Observable<EffectLayer>;
  48923. /**
  48924. * An event triggered when the generated texture has been merged in the scene.
  48925. */
  48926. onAfterComposeObservable: Observable<EffectLayer>;
  48927. /**
  48928. * An event triggered when the efffect layer changes its size.
  48929. */
  48930. onSizeChangedObservable: Observable<EffectLayer>;
  48931. /** @hidden */
  48932. static _SceneComponentInitialization: (scene: Scene) => void;
  48933. /**
  48934. * Instantiates a new effect Layer and references it in the scene.
  48935. * @param name The name of the layer
  48936. * @param scene The scene to use the layer in
  48937. */
  48938. constructor(
  48939. /** The Friendly of the effect in the scene */
  48940. name: string, scene: Scene);
  48941. /**
  48942. * Get the effect name of the layer.
  48943. * @return The effect name
  48944. */
  48945. abstract getEffectName(): string;
  48946. /**
  48947. * Checks for the readiness of the element composing the layer.
  48948. * @param subMesh the mesh to check for
  48949. * @param useInstances specify wether or not to use instances to render the mesh
  48950. * @return true if ready otherwise, false
  48951. */
  48952. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48953. /**
  48954. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48955. * @returns true if the effect requires stencil during the main canvas render pass.
  48956. */
  48957. abstract needStencil(): boolean;
  48958. /**
  48959. * Create the merge effect. This is the shader use to blit the information back
  48960. * to the main canvas at the end of the scene rendering.
  48961. * @returns The effect containing the shader used to merge the effect on the main canvas
  48962. */
  48963. protected abstract _createMergeEffect(): Effect;
  48964. /**
  48965. * Creates the render target textures and post processes used in the effect layer.
  48966. */
  48967. protected abstract _createTextureAndPostProcesses(): void;
  48968. /**
  48969. * Implementation specific of rendering the generating effect on the main canvas.
  48970. * @param effect The effect used to render through
  48971. */
  48972. protected abstract _internalRender(effect: Effect): void;
  48973. /**
  48974. * Sets the required values for both the emissive texture and and the main color.
  48975. */
  48976. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48977. /**
  48978. * Free any resources and references associated to a mesh.
  48979. * Internal use
  48980. * @param mesh The mesh to free.
  48981. */
  48982. abstract _disposeMesh(mesh: Mesh): void;
  48983. /**
  48984. * Serializes this layer (Glow or Highlight for example)
  48985. * @returns a serialized layer object
  48986. */
  48987. abstract serialize?(): any;
  48988. /**
  48989. * Initializes the effect layer with the required options.
  48990. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48991. */
  48992. protected _init(options: Partial<IEffectLayerOptions>): void;
  48993. /**
  48994. * Generates the index buffer of the full screen quad blending to the main canvas.
  48995. */
  48996. private _generateIndexBuffer;
  48997. /**
  48998. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48999. */
  49000. private _generateVertexBuffer;
  49001. /**
  49002. * Sets the main texture desired size which is the closest power of two
  49003. * of the engine canvas size.
  49004. */
  49005. private _setMainTextureSize;
  49006. /**
  49007. * Creates the main texture for the effect layer.
  49008. */
  49009. protected _createMainTexture(): void;
  49010. /**
  49011. * Adds specific effects defines.
  49012. * @param defines The defines to add specifics to.
  49013. */
  49014. protected _addCustomEffectDefines(defines: string[]): void;
  49015. /**
  49016. * Checks for the readiness of the element composing the layer.
  49017. * @param subMesh the mesh to check for
  49018. * @param useInstances specify wether or not to use instances to render the mesh
  49019. * @param emissiveTexture the associated emissive texture used to generate the glow
  49020. * @return true if ready otherwise, false
  49021. */
  49022. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49023. /**
  49024. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49025. */
  49026. render(): void;
  49027. /**
  49028. * Determine if a given mesh will be used in the current effect.
  49029. * @param mesh mesh to test
  49030. * @returns true if the mesh will be used
  49031. */
  49032. hasMesh(mesh: AbstractMesh): boolean;
  49033. /**
  49034. * Returns true if the layer contains information to display, otherwise false.
  49035. * @returns true if the glow layer should be rendered
  49036. */
  49037. shouldRender(): boolean;
  49038. /**
  49039. * Returns true if the mesh should render, otherwise false.
  49040. * @param mesh The mesh to render
  49041. * @returns true if it should render otherwise false
  49042. */
  49043. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49044. /**
  49045. * Returns true if the mesh can be rendered, otherwise false.
  49046. * @param mesh The mesh to render
  49047. * @param material The material used on the mesh
  49048. * @returns true if it can be rendered otherwise false
  49049. */
  49050. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49051. /**
  49052. * Returns true if the mesh should render, otherwise false.
  49053. * @param mesh The mesh to render
  49054. * @returns true if it should render otherwise false
  49055. */
  49056. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49057. /**
  49058. * Renders the submesh passed in parameter to the generation map.
  49059. */
  49060. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49061. /**
  49062. * Rebuild the required buffers.
  49063. * @hidden Internal use only.
  49064. */
  49065. _rebuild(): void;
  49066. /**
  49067. * Dispose only the render target textures and post process.
  49068. */
  49069. private _disposeTextureAndPostProcesses;
  49070. /**
  49071. * Dispose the highlight layer and free resources.
  49072. */
  49073. dispose(): void;
  49074. /**
  49075. * Gets the class name of the effect layer
  49076. * @returns the string with the class name of the effect layer
  49077. */
  49078. getClassName(): string;
  49079. /**
  49080. * Creates an effect layer from parsed effect layer data
  49081. * @param parsedEffectLayer defines effect layer data
  49082. * @param scene defines the current scene
  49083. * @param rootUrl defines the root URL containing the effect layer information
  49084. * @returns a parsed effect Layer
  49085. */
  49086. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49087. }
  49088. }
  49089. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49090. import { Scene } from "babylonjs/scene";
  49091. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49092. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49093. import { AbstractScene } from "babylonjs/abstractScene";
  49094. module "babylonjs/abstractScene" {
  49095. interface AbstractScene {
  49096. /**
  49097. * The list of effect layers (highlights/glow) added to the scene
  49098. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49099. * @see http://doc.babylonjs.com/how_to/glow_layer
  49100. */
  49101. effectLayers: Array<EffectLayer>;
  49102. /**
  49103. * Removes the given effect layer from this scene.
  49104. * @param toRemove defines the effect layer to remove
  49105. * @returns the index of the removed effect layer
  49106. */
  49107. removeEffectLayer(toRemove: EffectLayer): number;
  49108. /**
  49109. * Adds the given effect layer to this scene
  49110. * @param newEffectLayer defines the effect layer to add
  49111. */
  49112. addEffectLayer(newEffectLayer: EffectLayer): void;
  49113. }
  49114. }
  49115. /**
  49116. * Defines the layer scene component responsible to manage any effect layers
  49117. * in a given scene.
  49118. */
  49119. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49120. /**
  49121. * The component name helpfull to identify the component in the list of scene components.
  49122. */
  49123. readonly name: string;
  49124. /**
  49125. * The scene the component belongs to.
  49126. */
  49127. scene: Scene;
  49128. private _engine;
  49129. private _renderEffects;
  49130. private _needStencil;
  49131. private _previousStencilState;
  49132. /**
  49133. * Creates a new instance of the component for the given scene
  49134. * @param scene Defines the scene to register the component in
  49135. */
  49136. constructor(scene: Scene);
  49137. /**
  49138. * Registers the component in a given scene
  49139. */
  49140. register(): void;
  49141. /**
  49142. * Rebuilds the elements related to this component in case of
  49143. * context lost for instance.
  49144. */
  49145. rebuild(): void;
  49146. /**
  49147. * Serializes the component data to the specified json object
  49148. * @param serializationObject The object to serialize to
  49149. */
  49150. serialize(serializationObject: any): void;
  49151. /**
  49152. * Adds all the element from the container to the scene
  49153. * @param container the container holding the elements
  49154. */
  49155. addFromContainer(container: AbstractScene): void;
  49156. /**
  49157. * Removes all the elements in the container from the scene
  49158. * @param container contains the elements to remove
  49159. * @param dispose if the removed element should be disposed (default: false)
  49160. */
  49161. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49162. /**
  49163. * Disposes the component and the associated ressources.
  49164. */
  49165. dispose(): void;
  49166. private _isReadyForMesh;
  49167. private _renderMainTexture;
  49168. private _setStencil;
  49169. private _setStencilBack;
  49170. private _draw;
  49171. private _drawCamera;
  49172. private _drawRenderingGroup;
  49173. }
  49174. }
  49175. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49176. /** @hidden */
  49177. export var glowMapMergePixelShader: {
  49178. name: string;
  49179. shader: string;
  49180. };
  49181. }
  49182. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49183. /** @hidden */
  49184. export var glowMapMergeVertexShader: {
  49185. name: string;
  49186. shader: string;
  49187. };
  49188. }
  49189. declare module "babylonjs/Layers/glowLayer" {
  49190. import { Nullable } from "babylonjs/types";
  49191. import { Camera } from "babylonjs/Cameras/camera";
  49192. import { Scene } from "babylonjs/scene";
  49193. import { Color4 } from "babylonjs/Maths/math";
  49194. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49196. import { Mesh } from "babylonjs/Meshes/mesh";
  49197. import { Texture } from "babylonjs/Materials/Textures/texture";
  49198. import { Effect } from "babylonjs/Materials/effect";
  49199. import { Material } from "babylonjs/Materials/material";
  49200. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49201. import "babylonjs/Shaders/glowMapMerge.fragment";
  49202. import "babylonjs/Shaders/glowMapMerge.vertex";
  49203. import "babylonjs/Layers/effectLayerSceneComponent";
  49204. module "babylonjs/abstractScene" {
  49205. interface AbstractScene {
  49206. /**
  49207. * Return a the first highlight layer of the scene with a given name.
  49208. * @param name The name of the highlight layer to look for.
  49209. * @return The highlight layer if found otherwise null.
  49210. */
  49211. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49212. }
  49213. }
  49214. /**
  49215. * Glow layer options. This helps customizing the behaviour
  49216. * of the glow layer.
  49217. */
  49218. export interface IGlowLayerOptions {
  49219. /**
  49220. * Multiplication factor apply to the canvas size to compute the render target size
  49221. * used to generated the glowing objects (the smaller the faster).
  49222. */
  49223. mainTextureRatio: number;
  49224. /**
  49225. * Enforces a fixed size texture to ensure resize independant blur.
  49226. */
  49227. mainTextureFixedSize?: number;
  49228. /**
  49229. * How big is the kernel of the blur texture.
  49230. */
  49231. blurKernelSize: number;
  49232. /**
  49233. * The camera attached to the layer.
  49234. */
  49235. camera: Nullable<Camera>;
  49236. /**
  49237. * Enable MSAA by chosing the number of samples.
  49238. */
  49239. mainTextureSamples?: number;
  49240. /**
  49241. * The rendering group to draw the layer in.
  49242. */
  49243. renderingGroupId: number;
  49244. }
  49245. /**
  49246. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49247. *
  49248. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49249. * glowy meshes to your scene.
  49250. *
  49251. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49252. */
  49253. export class GlowLayer extends EffectLayer {
  49254. /**
  49255. * Effect Name of the layer.
  49256. */
  49257. static readonly EffectName: string;
  49258. /**
  49259. * The default blur kernel size used for the glow.
  49260. */
  49261. static DefaultBlurKernelSize: number;
  49262. /**
  49263. * The default texture size ratio used for the glow.
  49264. */
  49265. static DefaultTextureRatio: number;
  49266. /**
  49267. * Sets the kernel size of the blur.
  49268. */
  49269. /**
  49270. * Gets the kernel size of the blur.
  49271. */
  49272. blurKernelSize: number;
  49273. /**
  49274. * Sets the glow intensity.
  49275. */
  49276. /**
  49277. * Gets the glow intensity.
  49278. */
  49279. intensity: number;
  49280. private _options;
  49281. private _intensity;
  49282. private _horizontalBlurPostprocess1;
  49283. private _verticalBlurPostprocess1;
  49284. private _horizontalBlurPostprocess2;
  49285. private _verticalBlurPostprocess2;
  49286. private _blurTexture1;
  49287. private _blurTexture2;
  49288. private _postProcesses1;
  49289. private _postProcesses2;
  49290. private _includedOnlyMeshes;
  49291. private _excludedMeshes;
  49292. /**
  49293. * Callback used to let the user override the color selection on a per mesh basis
  49294. */
  49295. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49296. /**
  49297. * Callback used to let the user override the texture selection on a per mesh basis
  49298. */
  49299. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49300. /**
  49301. * Instantiates a new glow Layer and references it to the scene.
  49302. * @param name The name of the layer
  49303. * @param scene The scene to use the layer in
  49304. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49305. */
  49306. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49307. /**
  49308. * Get the effect name of the layer.
  49309. * @return The effect name
  49310. */
  49311. getEffectName(): string;
  49312. /**
  49313. * Create the merge effect. This is the shader use to blit the information back
  49314. * to the main canvas at the end of the scene rendering.
  49315. */
  49316. protected _createMergeEffect(): Effect;
  49317. /**
  49318. * Creates the render target textures and post processes used in the glow layer.
  49319. */
  49320. protected _createTextureAndPostProcesses(): void;
  49321. /**
  49322. * Checks for the readiness of the element composing the layer.
  49323. * @param subMesh the mesh to check for
  49324. * @param useInstances specify wether or not to use instances to render the mesh
  49325. * @param emissiveTexture the associated emissive texture used to generate the glow
  49326. * @return true if ready otherwise, false
  49327. */
  49328. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49329. /**
  49330. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49331. */
  49332. needStencil(): boolean;
  49333. /**
  49334. * Returns true if the mesh can be rendered, otherwise false.
  49335. * @param mesh The mesh to render
  49336. * @param material The material used on the mesh
  49337. * @returns true if it can be rendered otherwise false
  49338. */
  49339. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49340. /**
  49341. * Implementation specific of rendering the generating effect on the main canvas.
  49342. * @param effect The effect used to render through
  49343. */
  49344. protected _internalRender(effect: Effect): void;
  49345. /**
  49346. * Sets the required values for both the emissive texture and and the main color.
  49347. */
  49348. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49349. /**
  49350. * Returns true if the mesh should render, otherwise false.
  49351. * @param mesh The mesh to render
  49352. * @returns true if it should render otherwise false
  49353. */
  49354. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49355. /**
  49356. * Adds specific effects defines.
  49357. * @param defines The defines to add specifics to.
  49358. */
  49359. protected _addCustomEffectDefines(defines: string[]): void;
  49360. /**
  49361. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49362. * @param mesh The mesh to exclude from the glow layer
  49363. */
  49364. addExcludedMesh(mesh: Mesh): void;
  49365. /**
  49366. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49367. * @param mesh The mesh to remove
  49368. */
  49369. removeExcludedMesh(mesh: Mesh): void;
  49370. /**
  49371. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49372. * @param mesh The mesh to include in the glow layer
  49373. */
  49374. addIncludedOnlyMesh(mesh: Mesh): void;
  49375. /**
  49376. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49377. * @param mesh The mesh to remove
  49378. */
  49379. removeIncludedOnlyMesh(mesh: Mesh): void;
  49380. /**
  49381. * Determine if a given mesh will be used in the glow layer
  49382. * @param mesh The mesh to test
  49383. * @returns true if the mesh will be highlighted by the current glow layer
  49384. */
  49385. hasMesh(mesh: AbstractMesh): boolean;
  49386. /**
  49387. * Free any resources and references associated to a mesh.
  49388. * Internal use
  49389. * @param mesh The mesh to free.
  49390. * @hidden
  49391. */
  49392. _disposeMesh(mesh: Mesh): void;
  49393. /**
  49394. * Gets the class name of the effect layer
  49395. * @returns the string with the class name of the effect layer
  49396. */
  49397. getClassName(): string;
  49398. /**
  49399. * Serializes this glow layer
  49400. * @returns a serialized glow layer object
  49401. */
  49402. serialize(): any;
  49403. /**
  49404. * Creates a Glow Layer from parsed glow layer data
  49405. * @param parsedGlowLayer defines glow layer data
  49406. * @param scene defines the current scene
  49407. * @param rootUrl defines the root URL containing the glow layer information
  49408. * @returns a parsed Glow Layer
  49409. */
  49410. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49411. }
  49412. }
  49413. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49414. /** @hidden */
  49415. export var glowBlurPostProcessPixelShader: {
  49416. name: string;
  49417. shader: string;
  49418. };
  49419. }
  49420. declare module "babylonjs/Layers/highlightLayer" {
  49421. import { Observable } from "babylonjs/Misc/observable";
  49422. import { Nullable } from "babylonjs/types";
  49423. import { Camera } from "babylonjs/Cameras/camera";
  49424. import { Scene } from "babylonjs/scene";
  49425. import { Color3, Color4 } from "babylonjs/Maths/math";
  49426. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49428. import { Mesh } from "babylonjs/Meshes/mesh";
  49429. import { Effect } from "babylonjs/Materials/effect";
  49430. import { Material } from "babylonjs/Materials/material";
  49431. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49432. import "babylonjs/Shaders/glowMapMerge.fragment";
  49433. import "babylonjs/Shaders/glowMapMerge.vertex";
  49434. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49435. module "babylonjs/abstractScene" {
  49436. interface AbstractScene {
  49437. /**
  49438. * Return a the first highlight layer of the scene with a given name.
  49439. * @param name The name of the highlight layer to look for.
  49440. * @return The highlight layer if found otherwise null.
  49441. */
  49442. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49443. }
  49444. }
  49445. /**
  49446. * Highlight layer options. This helps customizing the behaviour
  49447. * of the highlight layer.
  49448. */
  49449. export interface IHighlightLayerOptions {
  49450. /**
  49451. * Multiplication factor apply to the canvas size to compute the render target size
  49452. * used to generated the glowing objects (the smaller the faster).
  49453. */
  49454. mainTextureRatio: number;
  49455. /**
  49456. * Enforces a fixed size texture to ensure resize independant blur.
  49457. */
  49458. mainTextureFixedSize?: number;
  49459. /**
  49460. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49461. * of the picture to blur (the smaller the faster).
  49462. */
  49463. blurTextureSizeRatio: number;
  49464. /**
  49465. * How big in texel of the blur texture is the vertical blur.
  49466. */
  49467. blurVerticalSize: number;
  49468. /**
  49469. * How big in texel of the blur texture is the horizontal blur.
  49470. */
  49471. blurHorizontalSize: number;
  49472. /**
  49473. * Alpha blending mode used to apply the blur. Default is combine.
  49474. */
  49475. alphaBlendingMode: number;
  49476. /**
  49477. * The camera attached to the layer.
  49478. */
  49479. camera: Nullable<Camera>;
  49480. /**
  49481. * Should we display highlight as a solid stroke?
  49482. */
  49483. isStroke?: boolean;
  49484. /**
  49485. * The rendering group to draw the layer in.
  49486. */
  49487. renderingGroupId: number;
  49488. }
  49489. /**
  49490. * The highlight layer Helps adding a glow effect around a mesh.
  49491. *
  49492. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49493. * glowy meshes to your scene.
  49494. *
  49495. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49496. */
  49497. export class HighlightLayer extends EffectLayer {
  49498. name: string;
  49499. /**
  49500. * Effect Name of the highlight layer.
  49501. */
  49502. static readonly EffectName: string;
  49503. /**
  49504. * The neutral color used during the preparation of the glow effect.
  49505. * This is black by default as the blend operation is a blend operation.
  49506. */
  49507. static NeutralColor: Color4;
  49508. /**
  49509. * Stencil value used for glowing meshes.
  49510. */
  49511. static GlowingMeshStencilReference: number;
  49512. /**
  49513. * Stencil value used for the other meshes in the scene.
  49514. */
  49515. static NormalMeshStencilReference: number;
  49516. /**
  49517. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49518. */
  49519. innerGlow: boolean;
  49520. /**
  49521. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49522. */
  49523. outerGlow: boolean;
  49524. /**
  49525. * Specifies the horizontal size of the blur.
  49526. */
  49527. /**
  49528. * Gets the horizontal size of the blur.
  49529. */
  49530. blurHorizontalSize: number;
  49531. /**
  49532. * Specifies the vertical size of the blur.
  49533. */
  49534. /**
  49535. * Gets the vertical size of the blur.
  49536. */
  49537. blurVerticalSize: number;
  49538. /**
  49539. * An event triggered when the highlight layer is being blurred.
  49540. */
  49541. onBeforeBlurObservable: Observable<HighlightLayer>;
  49542. /**
  49543. * An event triggered when the highlight layer has been blurred.
  49544. */
  49545. onAfterBlurObservable: Observable<HighlightLayer>;
  49546. private _instanceGlowingMeshStencilReference;
  49547. private _options;
  49548. private _downSamplePostprocess;
  49549. private _horizontalBlurPostprocess;
  49550. private _verticalBlurPostprocess;
  49551. private _blurTexture;
  49552. private _meshes;
  49553. private _excludedMeshes;
  49554. /**
  49555. * Instantiates a new highlight Layer and references it to the scene..
  49556. * @param name The name of the layer
  49557. * @param scene The scene to use the layer in
  49558. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49559. */
  49560. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49561. /**
  49562. * Get the effect name of the layer.
  49563. * @return The effect name
  49564. */
  49565. getEffectName(): string;
  49566. /**
  49567. * Create the merge effect. This is the shader use to blit the information back
  49568. * to the main canvas at the end of the scene rendering.
  49569. */
  49570. protected _createMergeEffect(): Effect;
  49571. /**
  49572. * Creates the render target textures and post processes used in the highlight layer.
  49573. */
  49574. protected _createTextureAndPostProcesses(): void;
  49575. /**
  49576. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49577. */
  49578. needStencil(): boolean;
  49579. /**
  49580. * Checks for the readiness of the element composing the layer.
  49581. * @param subMesh the mesh to check for
  49582. * @param useInstances specify wether or not to use instances to render the mesh
  49583. * @param emissiveTexture the associated emissive texture used to generate the glow
  49584. * @return true if ready otherwise, false
  49585. */
  49586. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49587. /**
  49588. * Implementation specific of rendering the generating effect on the main canvas.
  49589. * @param effect The effect used to render through
  49590. */
  49591. protected _internalRender(effect: Effect): void;
  49592. /**
  49593. * Returns true if the layer contains information to display, otherwise false.
  49594. */
  49595. shouldRender(): boolean;
  49596. /**
  49597. * Returns true if the mesh should render, otherwise false.
  49598. * @param mesh The mesh to render
  49599. * @returns true if it should render otherwise false
  49600. */
  49601. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49602. /**
  49603. * Sets the required values for both the emissive texture and and the main color.
  49604. */
  49605. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49606. /**
  49607. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49608. * @param mesh The mesh to exclude from the highlight layer
  49609. */
  49610. addExcludedMesh(mesh: Mesh): void;
  49611. /**
  49612. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49613. * @param mesh The mesh to highlight
  49614. */
  49615. removeExcludedMesh(mesh: Mesh): void;
  49616. /**
  49617. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49618. * @param mesh mesh to test
  49619. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49620. */
  49621. hasMesh(mesh: AbstractMesh): boolean;
  49622. /**
  49623. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49624. * @param mesh The mesh to highlight
  49625. * @param color The color of the highlight
  49626. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49627. */
  49628. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49629. /**
  49630. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49631. * @param mesh The mesh to highlight
  49632. */
  49633. removeMesh(mesh: Mesh): void;
  49634. /**
  49635. * Force the stencil to the normal expected value for none glowing parts
  49636. */
  49637. private _defaultStencilReference;
  49638. /**
  49639. * Free any resources and references associated to a mesh.
  49640. * Internal use
  49641. * @param mesh The mesh to free.
  49642. * @hidden
  49643. */
  49644. _disposeMesh(mesh: Mesh): void;
  49645. /**
  49646. * Dispose the highlight layer and free resources.
  49647. */
  49648. dispose(): void;
  49649. /**
  49650. * Gets the class name of the effect layer
  49651. * @returns the string with the class name of the effect layer
  49652. */
  49653. getClassName(): string;
  49654. /**
  49655. * Serializes this Highlight layer
  49656. * @returns a serialized Highlight layer object
  49657. */
  49658. serialize(): any;
  49659. /**
  49660. * Creates a Highlight layer from parsed Highlight layer data
  49661. * @param parsedHightlightLayer defines the Highlight layer data
  49662. * @param scene defines the current scene
  49663. * @param rootUrl defines the root URL containing the Highlight layer information
  49664. * @returns a parsed Highlight layer
  49665. */
  49666. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49667. }
  49668. }
  49669. declare module "babylonjs/Layers/index" {
  49670. export * from "babylonjs/Layers/effectLayer";
  49671. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49672. export * from "babylonjs/Layers/glowLayer";
  49673. export * from "babylonjs/Layers/highlightLayer";
  49674. export * from "babylonjs/Layers/layer";
  49675. export * from "babylonjs/Layers/layerSceneComponent";
  49676. }
  49677. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49678. /** @hidden */
  49679. export var lensFlarePixelShader: {
  49680. name: string;
  49681. shader: string;
  49682. };
  49683. }
  49684. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49685. /** @hidden */
  49686. export var lensFlareVertexShader: {
  49687. name: string;
  49688. shader: string;
  49689. };
  49690. }
  49691. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49692. import { Scene } from "babylonjs/scene";
  49693. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49695. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49696. import "babylonjs/Shaders/lensFlare.fragment";
  49697. import "babylonjs/Shaders/lensFlare.vertex";
  49698. /**
  49699. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49700. * It is usually composed of several `lensFlare`.
  49701. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49702. */
  49703. export class LensFlareSystem {
  49704. /**
  49705. * Define the name of the lens flare system
  49706. */
  49707. name: string;
  49708. /**
  49709. * List of lens flares used in this system.
  49710. */
  49711. lensFlares: LensFlare[];
  49712. /**
  49713. * Define a limit from the border the lens flare can be visible.
  49714. */
  49715. borderLimit: number;
  49716. /**
  49717. * Define a viewport border we do not want to see the lens flare in.
  49718. */
  49719. viewportBorder: number;
  49720. /**
  49721. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49722. */
  49723. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49724. /**
  49725. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49726. */
  49727. layerMask: number;
  49728. /**
  49729. * Define the id of the lens flare system in the scene.
  49730. * (equal to name by default)
  49731. */
  49732. id: string;
  49733. private _scene;
  49734. private _emitter;
  49735. private _vertexBuffers;
  49736. private _indexBuffer;
  49737. private _effect;
  49738. private _positionX;
  49739. private _positionY;
  49740. private _isEnabled;
  49741. /** @hidden */
  49742. static _SceneComponentInitialization: (scene: Scene) => void;
  49743. /**
  49744. * Instantiates a lens flare system.
  49745. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49746. * It is usually composed of several `lensFlare`.
  49747. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49748. * @param name Define the name of the lens flare system in the scene
  49749. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49750. * @param scene Define the scene the lens flare system belongs to
  49751. */
  49752. constructor(
  49753. /**
  49754. * Define the name of the lens flare system
  49755. */
  49756. name: string, emitter: any, scene: Scene);
  49757. /**
  49758. * Define if the lens flare system is enabled.
  49759. */
  49760. isEnabled: boolean;
  49761. /**
  49762. * Get the scene the effects belongs to.
  49763. * @returns the scene holding the lens flare system
  49764. */
  49765. getScene(): Scene;
  49766. /**
  49767. * Get the emitter of the lens flare system.
  49768. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49769. * @returns the emitter of the lens flare system
  49770. */
  49771. getEmitter(): any;
  49772. /**
  49773. * Set the emitter of the lens flare system.
  49774. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49775. * @param newEmitter Define the new emitter of the system
  49776. */
  49777. setEmitter(newEmitter: any): void;
  49778. /**
  49779. * Get the lens flare system emitter position.
  49780. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49781. * @returns the position
  49782. */
  49783. getEmitterPosition(): Vector3;
  49784. /**
  49785. * @hidden
  49786. */
  49787. computeEffectivePosition(globalViewport: Viewport): boolean;
  49788. /** @hidden */
  49789. _isVisible(): boolean;
  49790. /**
  49791. * @hidden
  49792. */
  49793. render(): boolean;
  49794. /**
  49795. * Dispose and release the lens flare with its associated resources.
  49796. */
  49797. dispose(): void;
  49798. /**
  49799. * Parse a lens flare system from a JSON repressentation
  49800. * @param parsedLensFlareSystem Define the JSON to parse
  49801. * @param scene Define the scene the parsed system should be instantiated in
  49802. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49803. * @returns the parsed system
  49804. */
  49805. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49806. /**
  49807. * Serialize the current Lens Flare System into a JSON representation.
  49808. * @returns the serialized JSON
  49809. */
  49810. serialize(): any;
  49811. }
  49812. }
  49813. declare module "babylonjs/LensFlares/lensFlare" {
  49814. import { Nullable } from "babylonjs/types";
  49815. import { Color3 } from "babylonjs/Maths/math";
  49816. import { Texture } from "babylonjs/Materials/Textures/texture";
  49817. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49818. /**
  49819. * This represents one of the lens effect in a `lensFlareSystem`.
  49820. * It controls one of the indiviual texture used in the effect.
  49821. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49822. */
  49823. export class LensFlare {
  49824. /**
  49825. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49826. */
  49827. size: number;
  49828. /**
  49829. * 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.
  49830. */
  49831. position: number;
  49832. /**
  49833. * Define the lens color.
  49834. */
  49835. color: Color3;
  49836. /**
  49837. * Define the lens texture.
  49838. */
  49839. texture: Nullable<Texture>;
  49840. /**
  49841. * Define the alpha mode to render this particular lens.
  49842. */
  49843. alphaMode: number;
  49844. private _system;
  49845. /**
  49846. * Creates a new Lens Flare.
  49847. * This represents one of the lens effect in a `lensFlareSystem`.
  49848. * It controls one of the indiviual texture used in the effect.
  49849. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49850. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49851. * @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.
  49852. * @param color Define the lens color
  49853. * @param imgUrl Define the lens texture url
  49854. * @param system Define the `lensFlareSystem` this flare is part of
  49855. * @returns The newly created Lens Flare
  49856. */
  49857. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49858. /**
  49859. * Instantiates a new Lens Flare.
  49860. * This represents one of the lens effect in a `lensFlareSystem`.
  49861. * It controls one of the indiviual texture used in the effect.
  49862. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49863. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49864. * @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.
  49865. * @param color Define the lens color
  49866. * @param imgUrl Define the lens texture url
  49867. * @param system Define the `lensFlareSystem` this flare is part of
  49868. */
  49869. constructor(
  49870. /**
  49871. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49872. */
  49873. size: number,
  49874. /**
  49875. * 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.
  49876. */
  49877. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49878. /**
  49879. * Dispose and release the lens flare with its associated resources.
  49880. */
  49881. dispose(): void;
  49882. }
  49883. }
  49884. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49885. import { Nullable } from "babylonjs/types";
  49886. import { Scene } from "babylonjs/scene";
  49887. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49888. import { AbstractScene } from "babylonjs/abstractScene";
  49889. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49890. module "babylonjs/abstractScene" {
  49891. interface AbstractScene {
  49892. /**
  49893. * The list of lens flare system added to the scene
  49894. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49895. */
  49896. lensFlareSystems: Array<LensFlareSystem>;
  49897. /**
  49898. * Removes the given lens flare system from this scene.
  49899. * @param toRemove The lens flare system to remove
  49900. * @returns The index of the removed lens flare system
  49901. */
  49902. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49903. /**
  49904. * Adds the given lens flare system to this scene
  49905. * @param newLensFlareSystem The lens flare system to add
  49906. */
  49907. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49908. /**
  49909. * Gets a lens flare system using its name
  49910. * @param name defines the name to look for
  49911. * @returns the lens flare system or null if not found
  49912. */
  49913. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49914. /**
  49915. * Gets a lens flare system using its id
  49916. * @param id defines the id to look for
  49917. * @returns the lens flare system or null if not found
  49918. */
  49919. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49920. }
  49921. }
  49922. /**
  49923. * Defines the lens flare scene component responsible to manage any lens flares
  49924. * in a given scene.
  49925. */
  49926. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49927. /**
  49928. * The component name helpfull to identify the component in the list of scene components.
  49929. */
  49930. readonly name: string;
  49931. /**
  49932. * The scene the component belongs to.
  49933. */
  49934. scene: Scene;
  49935. /**
  49936. * Creates a new instance of the component for the given scene
  49937. * @param scene Defines the scene to register the component in
  49938. */
  49939. constructor(scene: Scene);
  49940. /**
  49941. * Registers the component in a given scene
  49942. */
  49943. register(): void;
  49944. /**
  49945. * Rebuilds the elements related to this component in case of
  49946. * context lost for instance.
  49947. */
  49948. rebuild(): void;
  49949. /**
  49950. * Adds all the element from the container to the scene
  49951. * @param container the container holding the elements
  49952. */
  49953. addFromContainer(container: AbstractScene): void;
  49954. /**
  49955. * Removes all the elements in the container from the scene
  49956. * @param container contains the elements to remove
  49957. * @param dispose if the removed element should be disposed (default: false)
  49958. */
  49959. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49960. /**
  49961. * Serializes the component data to the specified json object
  49962. * @param serializationObject The object to serialize to
  49963. */
  49964. serialize(serializationObject: any): void;
  49965. /**
  49966. * Disposes the component and the associated ressources.
  49967. */
  49968. dispose(): void;
  49969. private _draw;
  49970. }
  49971. }
  49972. declare module "babylonjs/LensFlares/index" {
  49973. export * from "babylonjs/LensFlares/lensFlare";
  49974. export * from "babylonjs/LensFlares/lensFlareSystem";
  49975. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49976. }
  49977. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49978. import { Scene } from "babylonjs/scene";
  49979. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49980. import { AbstractScene } from "babylonjs/abstractScene";
  49981. /**
  49982. * Defines the shadow generator component responsible to manage any shadow generators
  49983. * in a given scene.
  49984. */
  49985. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49986. /**
  49987. * The component name helpfull to identify the component in the list of scene components.
  49988. */
  49989. readonly name: string;
  49990. /**
  49991. * The scene the component belongs to.
  49992. */
  49993. scene: Scene;
  49994. /**
  49995. * Creates a new instance of the component for the given scene
  49996. * @param scene Defines the scene to register the component in
  49997. */
  49998. constructor(scene: Scene);
  49999. /**
  50000. * Registers the component in a given scene
  50001. */
  50002. register(): void;
  50003. /**
  50004. * Rebuilds the elements related to this component in case of
  50005. * context lost for instance.
  50006. */
  50007. rebuild(): void;
  50008. /**
  50009. * Serializes the component data to the specified json object
  50010. * @param serializationObject The object to serialize to
  50011. */
  50012. serialize(serializationObject: any): void;
  50013. /**
  50014. * Adds all the element from the container to the scene
  50015. * @param container the container holding the elements
  50016. */
  50017. addFromContainer(container: AbstractScene): void;
  50018. /**
  50019. * Removes all the elements in the container from the scene
  50020. * @param container contains the elements to remove
  50021. * @param dispose if the removed element should be disposed (default: false)
  50022. */
  50023. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50024. /**
  50025. * Rebuilds the elements related to this component in case of
  50026. * context lost for instance.
  50027. */
  50028. dispose(): void;
  50029. private _gatherRenderTargets;
  50030. }
  50031. }
  50032. declare module "babylonjs/Lights/Shadows/index" {
  50033. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50034. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50035. }
  50036. declare module "babylonjs/Lights/pointLight" {
  50037. import { Scene } from "babylonjs/scene";
  50038. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50040. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50041. import { Effect } from "babylonjs/Materials/effect";
  50042. /**
  50043. * A point light is a light defined by an unique point in world space.
  50044. * The light is emitted in every direction from this point.
  50045. * A good example of a point light is a standard light bulb.
  50046. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50047. */
  50048. export class PointLight extends ShadowLight {
  50049. private _shadowAngle;
  50050. /**
  50051. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50052. * This specifies what angle the shadow will use to be created.
  50053. *
  50054. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50055. */
  50056. /**
  50057. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50058. * This specifies what angle the shadow will use to be created.
  50059. *
  50060. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50061. */
  50062. shadowAngle: number;
  50063. /**
  50064. * Gets the direction if it has been set.
  50065. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50066. */
  50067. /**
  50068. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50069. */
  50070. direction: Vector3;
  50071. /**
  50072. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50073. * A PointLight emits the light in every direction.
  50074. * It can cast shadows.
  50075. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50076. * ```javascript
  50077. * var pointLight = new PointLight("pl", camera.position, scene);
  50078. * ```
  50079. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50080. * @param name The light friendly name
  50081. * @param position The position of the point light in the scene
  50082. * @param scene The scene the lights belongs to
  50083. */
  50084. constructor(name: string, position: Vector3, scene: Scene);
  50085. /**
  50086. * Returns the string "PointLight"
  50087. * @returns the class name
  50088. */
  50089. getClassName(): string;
  50090. /**
  50091. * Returns the integer 0.
  50092. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50093. */
  50094. getTypeID(): number;
  50095. /**
  50096. * Specifies wether or not the shadowmap should be a cube texture.
  50097. * @returns true if the shadowmap needs to be a cube texture.
  50098. */
  50099. needCube(): boolean;
  50100. /**
  50101. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50102. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50103. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50104. */
  50105. getShadowDirection(faceIndex?: number): Vector3;
  50106. /**
  50107. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50108. * - fov = PI / 2
  50109. * - aspect ratio : 1.0
  50110. * - z-near and far equal to the active camera minZ and maxZ.
  50111. * Returns the PointLight.
  50112. */
  50113. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50114. protected _buildUniformLayout(): void;
  50115. /**
  50116. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50117. * @param effect The effect to update
  50118. * @param lightIndex The index of the light in the effect to update
  50119. * @returns The point light
  50120. */
  50121. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50122. /**
  50123. * Prepares the list of defines specific to the light type.
  50124. * @param defines the list of defines
  50125. * @param lightIndex defines the index of the light for the effect
  50126. */
  50127. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50128. }
  50129. }
  50130. declare module "babylonjs/Lights/index" {
  50131. export * from "babylonjs/Lights/light";
  50132. export * from "babylonjs/Lights/shadowLight";
  50133. export * from "babylonjs/Lights/Shadows/index";
  50134. export * from "babylonjs/Lights/directionalLight";
  50135. export * from "babylonjs/Lights/hemisphericLight";
  50136. export * from "babylonjs/Lights/pointLight";
  50137. export * from "babylonjs/Lights/spotLight";
  50138. }
  50139. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50140. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50141. /**
  50142. * Header information of HDR texture files.
  50143. */
  50144. export interface HDRInfo {
  50145. /**
  50146. * The height of the texture in pixels.
  50147. */
  50148. height: number;
  50149. /**
  50150. * The width of the texture in pixels.
  50151. */
  50152. width: number;
  50153. /**
  50154. * The index of the beginning of the data in the binary file.
  50155. */
  50156. dataPosition: number;
  50157. }
  50158. /**
  50159. * This groups tools to convert HDR texture to native colors array.
  50160. */
  50161. export class HDRTools {
  50162. private static Ldexp;
  50163. private static Rgbe2float;
  50164. private static readStringLine;
  50165. /**
  50166. * Reads header information from an RGBE texture stored in a native array.
  50167. * More information on this format are available here:
  50168. * https://en.wikipedia.org/wiki/RGBE_image_format
  50169. *
  50170. * @param uint8array The binary file stored in native array.
  50171. * @return The header information.
  50172. */
  50173. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50174. /**
  50175. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50176. * This RGBE texture needs to store the information as a panorama.
  50177. *
  50178. * More information on this format are available here:
  50179. * https://en.wikipedia.org/wiki/RGBE_image_format
  50180. *
  50181. * @param buffer The binary file stored in an array buffer.
  50182. * @param size The expected size of the extracted cubemap.
  50183. * @return The Cube Map information.
  50184. */
  50185. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50186. /**
  50187. * Returns the pixels data extracted from an RGBE texture.
  50188. * This pixels will be stored left to right up to down in the R G B order in one array.
  50189. *
  50190. * More information on this format are available here:
  50191. * https://en.wikipedia.org/wiki/RGBE_image_format
  50192. *
  50193. * @param uint8array The binary file stored in an array buffer.
  50194. * @param hdrInfo The header information of the file.
  50195. * @return The pixels data in RGB right to left up to down order.
  50196. */
  50197. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50198. private static RGBE_ReadPixels_RLE;
  50199. }
  50200. }
  50201. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50202. import { Nullable } from "babylonjs/types";
  50203. import { Scene } from "babylonjs/scene";
  50204. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50205. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50206. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50207. /**
  50208. * This represents a texture coming from an HDR input.
  50209. *
  50210. * The only supported format is currently panorama picture stored in RGBE format.
  50211. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50212. */
  50213. export class HDRCubeTexture extends BaseTexture {
  50214. private static _facesMapping;
  50215. private _generateHarmonics;
  50216. private _noMipmap;
  50217. private _textureMatrix;
  50218. private _size;
  50219. private _onLoad;
  50220. private _onError;
  50221. /**
  50222. * The texture URL.
  50223. */
  50224. url: string;
  50225. /**
  50226. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50227. */
  50228. coordinatesMode: number;
  50229. protected _isBlocking: boolean;
  50230. /**
  50231. * Sets wether or not the texture is blocking during loading.
  50232. */
  50233. /**
  50234. * Gets wether or not the texture is blocking during loading.
  50235. */
  50236. isBlocking: boolean;
  50237. protected _rotationY: number;
  50238. /**
  50239. * Sets texture matrix rotation angle around Y axis in radians.
  50240. */
  50241. /**
  50242. * Gets texture matrix rotation angle around Y axis radians.
  50243. */
  50244. rotationY: number;
  50245. /**
  50246. * Gets or sets the center of the bounding box associated with the cube texture
  50247. * It must define where the camera used to render the texture was set
  50248. */
  50249. boundingBoxPosition: Vector3;
  50250. private _boundingBoxSize;
  50251. /**
  50252. * Gets or sets the size of the bounding box associated with the cube texture
  50253. * When defined, the cubemap will switch to local mode
  50254. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50255. * @example https://www.babylonjs-playground.com/#RNASML
  50256. */
  50257. boundingBoxSize: Vector3;
  50258. /**
  50259. * Instantiates an HDRTexture from the following parameters.
  50260. *
  50261. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50262. * @param scene The scene the texture will be used in
  50263. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50264. * @param noMipmap Forces to not generate the mipmap if true
  50265. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50266. * @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)
  50267. * @param reserved Reserved flag for internal use.
  50268. */
  50269. 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>);
  50270. /**
  50271. * Get the current class name of the texture useful for serialization or dynamic coding.
  50272. * @returns "HDRCubeTexture"
  50273. */
  50274. getClassName(): string;
  50275. /**
  50276. * Occurs when the file is raw .hdr file.
  50277. */
  50278. private loadTexture;
  50279. clone(): HDRCubeTexture;
  50280. delayLoad(): void;
  50281. /**
  50282. * Get the texture reflection matrix used to rotate/transform the reflection.
  50283. * @returns the reflection matrix
  50284. */
  50285. getReflectionTextureMatrix(): Matrix;
  50286. /**
  50287. * Set the texture reflection matrix used to rotate/transform the reflection.
  50288. * @param value Define the reflection matrix to set
  50289. */
  50290. setReflectionTextureMatrix(value: Matrix): void;
  50291. /**
  50292. * Parses a JSON representation of an HDR Texture in order to create the texture
  50293. * @param parsedTexture Define the JSON representation
  50294. * @param scene Define the scene the texture should be created in
  50295. * @param rootUrl Define the root url in case we need to load relative dependencies
  50296. * @returns the newly created texture after parsing
  50297. */
  50298. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50299. serialize(): any;
  50300. }
  50301. }
  50302. declare module "babylonjs/Physics/physicsEngine" {
  50303. import { Nullable } from "babylonjs/types";
  50304. import { Vector3 } from "babylonjs/Maths/math";
  50305. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50306. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50307. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50308. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50309. /**
  50310. * Class used to control physics engine
  50311. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50312. */
  50313. export class PhysicsEngine implements IPhysicsEngine {
  50314. private _physicsPlugin;
  50315. /**
  50316. * Global value used to control the smallest number supported by the simulation
  50317. */
  50318. static Epsilon: number;
  50319. private _impostors;
  50320. private _joints;
  50321. /**
  50322. * Gets the gravity vector used by the simulation
  50323. */
  50324. gravity: Vector3;
  50325. /**
  50326. * Factory used to create the default physics plugin.
  50327. * @returns The default physics plugin
  50328. */
  50329. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50330. /**
  50331. * Creates a new Physics Engine
  50332. * @param gravity defines the gravity vector used by the simulation
  50333. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50334. */
  50335. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50336. /**
  50337. * Sets the gravity vector used by the simulation
  50338. * @param gravity defines the gravity vector to use
  50339. */
  50340. setGravity(gravity: Vector3): void;
  50341. /**
  50342. * Set the time step of the physics engine.
  50343. * Default is 1/60.
  50344. * To slow it down, enter 1/600 for example.
  50345. * To speed it up, 1/30
  50346. * @param newTimeStep defines the new timestep to apply to this world.
  50347. */
  50348. setTimeStep(newTimeStep?: number): void;
  50349. /**
  50350. * Get the time step of the physics engine.
  50351. * @returns the current time step
  50352. */
  50353. getTimeStep(): number;
  50354. /**
  50355. * Release all resources
  50356. */
  50357. dispose(): void;
  50358. /**
  50359. * Gets the name of the current physics plugin
  50360. * @returns the name of the plugin
  50361. */
  50362. getPhysicsPluginName(): string;
  50363. /**
  50364. * Adding a new impostor for the impostor tracking.
  50365. * This will be done by the impostor itself.
  50366. * @param impostor the impostor to add
  50367. */
  50368. addImpostor(impostor: PhysicsImpostor): void;
  50369. /**
  50370. * Remove an impostor from the engine.
  50371. * This impostor and its mesh will not longer be updated by the physics engine.
  50372. * @param impostor the impostor to remove
  50373. */
  50374. removeImpostor(impostor: PhysicsImpostor): void;
  50375. /**
  50376. * Add a joint to the physics engine
  50377. * @param mainImpostor defines the main impostor to which the joint is added.
  50378. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50379. * @param joint defines the joint that will connect both impostors.
  50380. */
  50381. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50382. /**
  50383. * Removes a joint from the simulation
  50384. * @param mainImpostor defines the impostor used with the joint
  50385. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50386. * @param joint defines the joint to remove
  50387. */
  50388. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50389. /**
  50390. * Called by the scene. No need to call it.
  50391. * @param delta defines the timespam between frames
  50392. */
  50393. _step(delta: number): void;
  50394. /**
  50395. * Gets the current plugin used to run the simulation
  50396. * @returns current plugin
  50397. */
  50398. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50399. /**
  50400. * Gets the list of physic impostors
  50401. * @returns an array of PhysicsImpostor
  50402. */
  50403. getImpostors(): Array<PhysicsImpostor>;
  50404. /**
  50405. * Gets the impostor for a physics enabled object
  50406. * @param object defines the object impersonated by the impostor
  50407. * @returns the PhysicsImpostor or null if not found
  50408. */
  50409. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50410. /**
  50411. * Gets the impostor for a physics body object
  50412. * @param body defines physics body used by the impostor
  50413. * @returns the PhysicsImpostor or null if not found
  50414. */
  50415. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50416. /**
  50417. * Does a raycast in the physics world
  50418. * @param from when should the ray start?
  50419. * @param to when should the ray end?
  50420. * @returns PhysicsRaycastResult
  50421. */
  50422. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50423. }
  50424. }
  50425. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  50426. import { Nullable } from "babylonjs/types";
  50427. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50429. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50430. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50431. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50432. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50433. /** @hidden */
  50434. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50435. private _useDeltaForWorldStep;
  50436. world: any;
  50437. name: string;
  50438. private _physicsMaterials;
  50439. private _fixedTimeStep;
  50440. private _cannonRaycastResult;
  50441. private _raycastResult;
  50442. private _removeAfterStep;
  50443. BJSCANNON: any;
  50444. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50445. setGravity(gravity: Vector3): void;
  50446. setTimeStep(timeStep: number): void;
  50447. getTimeStep(): number;
  50448. executeStep(delta: number): void;
  50449. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50450. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50451. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50452. private _processChildMeshes;
  50453. removePhysicsBody(impostor: PhysicsImpostor): void;
  50454. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50455. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50456. private _addMaterial;
  50457. private _checkWithEpsilon;
  50458. private _createShape;
  50459. private _createHeightmap;
  50460. private _minus90X;
  50461. private _plus90X;
  50462. private _tmpPosition;
  50463. private _tmpDeltaPosition;
  50464. private _tmpUnityRotation;
  50465. private _updatePhysicsBodyTransformation;
  50466. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50467. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50468. isSupported(): boolean;
  50469. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50470. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50471. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50472. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50473. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50474. getBodyMass(impostor: PhysicsImpostor): number;
  50475. getBodyFriction(impostor: PhysicsImpostor): number;
  50476. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50477. getBodyRestitution(impostor: PhysicsImpostor): number;
  50478. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50479. sleepBody(impostor: PhysicsImpostor): void;
  50480. wakeUpBody(impostor: PhysicsImpostor): void;
  50481. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50482. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50483. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50484. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50485. getRadius(impostor: PhysicsImpostor): number;
  50486. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50487. dispose(): void;
  50488. private _extendNamespace;
  50489. /**
  50490. * Does a raycast in the physics world
  50491. * @param from when should the ray start?
  50492. * @param to when should the ray end?
  50493. * @returns PhysicsRaycastResult
  50494. */
  50495. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50496. }
  50497. }
  50498. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  50499. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50500. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50501. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50503. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50504. import { Nullable } from "babylonjs/types";
  50505. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50506. /** @hidden */
  50507. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50508. world: any;
  50509. name: string;
  50510. BJSOIMO: any;
  50511. private _raycastResult;
  50512. constructor(iterations?: number, oimoInjection?: any);
  50513. setGravity(gravity: Vector3): void;
  50514. setTimeStep(timeStep: number): void;
  50515. getTimeStep(): number;
  50516. private _tmpImpostorsArray;
  50517. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50518. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50519. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50520. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50521. private _tmpPositionVector;
  50522. removePhysicsBody(impostor: PhysicsImpostor): void;
  50523. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50524. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50525. isSupported(): boolean;
  50526. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50527. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50528. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50529. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50530. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50531. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50532. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50533. getBodyMass(impostor: PhysicsImpostor): number;
  50534. getBodyFriction(impostor: PhysicsImpostor): number;
  50535. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50536. getBodyRestitution(impostor: PhysicsImpostor): number;
  50537. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50538. sleepBody(impostor: PhysicsImpostor): void;
  50539. wakeUpBody(impostor: PhysicsImpostor): void;
  50540. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50541. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50542. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50543. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50544. getRadius(impostor: PhysicsImpostor): number;
  50545. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50546. dispose(): void;
  50547. /**
  50548. * Does a raycast in the physics world
  50549. * @param from when should the ray start?
  50550. * @param to when should the ray end?
  50551. * @returns PhysicsRaycastResult
  50552. */
  50553. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50554. }
  50555. }
  50556. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50557. import { Nullable } from "babylonjs/types";
  50558. import { Scene } from "babylonjs/scene";
  50559. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50560. import { Mesh } from "babylonjs/Meshes/mesh";
  50561. /**
  50562. * Class containing static functions to help procedurally build meshes
  50563. */
  50564. export class RibbonBuilder {
  50565. /**
  50566. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50567. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50568. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50569. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50570. * * 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
  50571. * * 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
  50572. * * 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
  50573. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50574. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50575. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50576. * * 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
  50577. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50578. * * 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
  50579. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50581. * @param name defines the name of the mesh
  50582. * @param options defines the options used to create the mesh
  50583. * @param scene defines the hosting scene
  50584. * @returns the ribbon mesh
  50585. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50586. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50587. */
  50588. static CreateRibbon(name: string, options: {
  50589. pathArray: Vector3[][];
  50590. closeArray?: boolean;
  50591. closePath?: boolean;
  50592. offset?: number;
  50593. updatable?: boolean;
  50594. sideOrientation?: number;
  50595. frontUVs?: Vector4;
  50596. backUVs?: Vector4;
  50597. instance?: Mesh;
  50598. invertUV?: boolean;
  50599. uvs?: Vector2[];
  50600. colors?: Color4[];
  50601. }, scene?: Nullable<Scene>): Mesh;
  50602. }
  50603. }
  50604. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50605. import { Nullable } from "babylonjs/types";
  50606. import { Scene } from "babylonjs/scene";
  50607. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50608. import { Mesh } from "babylonjs/Meshes/mesh";
  50609. /**
  50610. * Class containing static functions to help procedurally build meshes
  50611. */
  50612. export class ShapeBuilder {
  50613. /**
  50614. * 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.
  50615. * * 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.
  50616. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50617. * * 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.
  50618. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50619. * * 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
  50620. * * 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
  50621. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50622. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50623. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50624. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50626. * @param name defines the name of the mesh
  50627. * @param options defines the options used to create the mesh
  50628. * @param scene defines the hosting scene
  50629. * @returns the extruded shape mesh
  50630. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50631. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50632. */
  50633. static ExtrudeShape(name: string, options: {
  50634. shape: Vector3[];
  50635. path: Vector3[];
  50636. scale?: number;
  50637. rotation?: number;
  50638. cap?: number;
  50639. updatable?: boolean;
  50640. sideOrientation?: number;
  50641. frontUVs?: Vector4;
  50642. backUVs?: Vector4;
  50643. instance?: Mesh;
  50644. invertUV?: boolean;
  50645. }, scene?: Nullable<Scene>): Mesh;
  50646. /**
  50647. * Creates an custom extruded shape mesh.
  50648. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50649. * * 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.
  50650. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50651. * * 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
  50652. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50653. * * 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
  50654. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50655. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50656. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50657. * * 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
  50658. * * 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
  50659. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50661. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50662. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50664. * @param name defines the name of the mesh
  50665. * @param options defines the options used to create the mesh
  50666. * @param scene defines the hosting scene
  50667. * @returns the custom extruded shape mesh
  50668. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50669. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50670. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50671. */
  50672. static ExtrudeShapeCustom(name: string, options: {
  50673. shape: Vector3[];
  50674. path: Vector3[];
  50675. scaleFunction?: any;
  50676. rotationFunction?: any;
  50677. ribbonCloseArray?: boolean;
  50678. ribbonClosePath?: boolean;
  50679. cap?: number;
  50680. updatable?: boolean;
  50681. sideOrientation?: number;
  50682. frontUVs?: Vector4;
  50683. backUVs?: Vector4;
  50684. instance?: Mesh;
  50685. invertUV?: boolean;
  50686. }, scene?: Nullable<Scene>): Mesh;
  50687. private static _ExtrudeShapeGeneric;
  50688. }
  50689. }
  50690. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50691. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50692. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50693. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50694. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50695. import { Nullable } from "babylonjs/types";
  50696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50697. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50698. /**
  50699. * AmmoJS Physics plugin
  50700. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50701. * @see https://github.com/kripken/ammo.js/
  50702. */
  50703. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50704. private _useDeltaForWorldStep;
  50705. /**
  50706. * Reference to the Ammo library
  50707. */
  50708. bjsAMMO: any;
  50709. /**
  50710. * Created ammoJS world which physics bodies are added to
  50711. */
  50712. world: any;
  50713. /**
  50714. * Name of the plugin
  50715. */
  50716. name: string;
  50717. private _timeStep;
  50718. private _fixedTimeStep;
  50719. private _maxSteps;
  50720. private _tmpQuaternion;
  50721. private _tmpAmmoTransform;
  50722. private _tmpAmmoQuaternion;
  50723. private _tmpAmmoConcreteContactResultCallback;
  50724. private _collisionConfiguration;
  50725. private _dispatcher;
  50726. private _overlappingPairCache;
  50727. private _solver;
  50728. private _softBodySolver;
  50729. private _tmpAmmoVectorA;
  50730. private _tmpAmmoVectorB;
  50731. private _tmpAmmoVectorC;
  50732. private _tmpAmmoVectorD;
  50733. private _tmpContactCallbackResult;
  50734. private _tmpAmmoVectorRCA;
  50735. private _tmpAmmoVectorRCB;
  50736. private _raycastResult;
  50737. private static readonly DISABLE_COLLISION_FLAG;
  50738. private static readonly KINEMATIC_FLAG;
  50739. private static readonly DISABLE_DEACTIVATION_FLAG;
  50740. /**
  50741. * Initializes the ammoJS plugin
  50742. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50743. * @param ammoInjection can be used to inject your own ammo reference
  50744. */
  50745. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50746. /**
  50747. * Sets the gravity of the physics world (m/(s^2))
  50748. * @param gravity Gravity to set
  50749. */
  50750. setGravity(gravity: Vector3): void;
  50751. /**
  50752. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50753. * @param timeStep timestep to use in seconds
  50754. */
  50755. setTimeStep(timeStep: number): void;
  50756. /**
  50757. * 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)
  50758. * @param fixedTimeStep fixedTimeStep to use in seconds
  50759. */
  50760. setFixedTimeStep(fixedTimeStep: number): void;
  50761. /**
  50762. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50763. * @param maxSteps the maximum number of steps by the physics engine per frame
  50764. */
  50765. setMaxSteps(maxSteps: number): void;
  50766. /**
  50767. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50768. * @returns the current timestep in seconds
  50769. */
  50770. getTimeStep(): number;
  50771. private _isImpostorInContact;
  50772. private _isImpostorPairInContact;
  50773. private _stepSimulation;
  50774. /**
  50775. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50776. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50777. * After the step the babylon meshes are set to the position of the physics imposters
  50778. * @param delta amount of time to step forward
  50779. * @param impostors array of imposters to update before/after the step
  50780. */
  50781. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50782. /**
  50783. * Update babylon mesh to match physics world object
  50784. * @param impostor imposter to match
  50785. */
  50786. private _afterSoftStep;
  50787. /**
  50788. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50789. * @param impostor imposter to match
  50790. */
  50791. private _ropeStep;
  50792. /**
  50793. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50794. * @param impostor imposter to match
  50795. */
  50796. private _softbodyOrClothStep;
  50797. private _tmpVector;
  50798. private _tmpMatrix;
  50799. /**
  50800. * Applies an impulse on the imposter
  50801. * @param impostor imposter to apply impulse to
  50802. * @param force amount of force to be applied to the imposter
  50803. * @param contactPoint the location to apply the impulse on the imposter
  50804. */
  50805. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50806. /**
  50807. * Applies a force on the imposter
  50808. * @param impostor imposter to apply force
  50809. * @param force amount of force to be applied to the imposter
  50810. * @param contactPoint the location to apply the force on the imposter
  50811. */
  50812. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50813. /**
  50814. * Creates a physics body using the plugin
  50815. * @param impostor the imposter to create the physics body on
  50816. */
  50817. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50818. /**
  50819. * Removes the physics body from the imposter and disposes of the body's memory
  50820. * @param impostor imposter to remove the physics body from
  50821. */
  50822. removePhysicsBody(impostor: PhysicsImpostor): void;
  50823. /**
  50824. * Generates a joint
  50825. * @param impostorJoint the imposter joint to create the joint with
  50826. */
  50827. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50828. /**
  50829. * Removes a joint
  50830. * @param impostorJoint the imposter joint to remove the joint from
  50831. */
  50832. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50833. private _addMeshVerts;
  50834. /**
  50835. * Initialise the soft body vertices to match its object's (mesh) vertices
  50836. * Softbody vertices (nodes) are in world space and to match this
  50837. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50838. * @param impostor to create the softbody for
  50839. */
  50840. private _softVertexData;
  50841. /**
  50842. * Create an impostor's soft body
  50843. * @param impostor to create the softbody for
  50844. */
  50845. private _createSoftbody;
  50846. /**
  50847. * Create cloth for an impostor
  50848. * @param impostor to create the softbody for
  50849. */
  50850. private _createCloth;
  50851. /**
  50852. * Create rope for an impostor
  50853. * @param impostor to create the softbody for
  50854. */
  50855. private _createRope;
  50856. private _addHullVerts;
  50857. private _createShape;
  50858. /**
  50859. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50860. * @param impostor imposter containing the physics body and babylon object
  50861. */
  50862. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50863. /**
  50864. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50865. * @param impostor imposter containing the physics body and babylon object
  50866. * @param newPosition new position
  50867. * @param newRotation new rotation
  50868. */
  50869. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50870. /**
  50871. * If this plugin is supported
  50872. * @returns true if its supported
  50873. */
  50874. isSupported(): boolean;
  50875. /**
  50876. * Sets the linear velocity of the physics body
  50877. * @param impostor imposter to set the velocity on
  50878. * @param velocity velocity to set
  50879. */
  50880. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50881. /**
  50882. * Sets the angular velocity of the physics body
  50883. * @param impostor imposter to set the velocity on
  50884. * @param velocity velocity to set
  50885. */
  50886. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50887. /**
  50888. * gets the linear velocity
  50889. * @param impostor imposter to get linear velocity from
  50890. * @returns linear velocity
  50891. */
  50892. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50893. /**
  50894. * gets the angular velocity
  50895. * @param impostor imposter to get angular velocity from
  50896. * @returns angular velocity
  50897. */
  50898. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50899. /**
  50900. * Sets the mass of physics body
  50901. * @param impostor imposter to set the mass on
  50902. * @param mass mass to set
  50903. */
  50904. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50905. /**
  50906. * Gets the mass of the physics body
  50907. * @param impostor imposter to get the mass from
  50908. * @returns mass
  50909. */
  50910. getBodyMass(impostor: PhysicsImpostor): number;
  50911. /**
  50912. * Gets friction of the impostor
  50913. * @param impostor impostor to get friction from
  50914. * @returns friction value
  50915. */
  50916. getBodyFriction(impostor: PhysicsImpostor): number;
  50917. /**
  50918. * Sets friction of the impostor
  50919. * @param impostor impostor to set friction on
  50920. * @param friction friction value
  50921. */
  50922. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50923. /**
  50924. * Gets restitution of the impostor
  50925. * @param impostor impostor to get restitution from
  50926. * @returns restitution value
  50927. */
  50928. getBodyRestitution(impostor: PhysicsImpostor): number;
  50929. /**
  50930. * Sets resitution of the impostor
  50931. * @param impostor impostor to set resitution on
  50932. * @param restitution resitution value
  50933. */
  50934. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50935. /**
  50936. * Gets pressure inside the impostor
  50937. * @param impostor impostor to get pressure from
  50938. * @returns pressure value
  50939. */
  50940. getBodyPressure(impostor: PhysicsImpostor): number;
  50941. /**
  50942. * Sets pressure inside a soft body impostor
  50943. * Cloth and rope must remain 0 pressure
  50944. * @param impostor impostor to set pressure on
  50945. * @param pressure pressure value
  50946. */
  50947. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50948. /**
  50949. * Gets stiffness of the impostor
  50950. * @param impostor impostor to get stiffness from
  50951. * @returns pressure value
  50952. */
  50953. getBodyStiffness(impostor: PhysicsImpostor): number;
  50954. /**
  50955. * Sets stiffness of the impostor
  50956. * @param impostor impostor to set stiffness on
  50957. * @param stiffness stiffness value from 0 to 1
  50958. */
  50959. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50960. /**
  50961. * Gets velocityIterations of the impostor
  50962. * @param impostor impostor to get velocity iterations from
  50963. * @returns velocityIterations value
  50964. */
  50965. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50966. /**
  50967. * Sets velocityIterations of the impostor
  50968. * @param impostor impostor to set velocity iterations on
  50969. * @param velocityIterations velocityIterations value
  50970. */
  50971. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50972. /**
  50973. * Gets positionIterations of the impostor
  50974. * @param impostor impostor to get position iterations from
  50975. * @returns positionIterations value
  50976. */
  50977. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50978. /**
  50979. * Sets positionIterations of the impostor
  50980. * @param impostor impostor to set position on
  50981. * @param positionIterations positionIterations value
  50982. */
  50983. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50984. /**
  50985. * Append an anchor to a cloth object
  50986. * @param impostor is the cloth impostor to add anchor to
  50987. * @param otherImpostor is the rigid impostor to anchor to
  50988. * @param width ratio across width from 0 to 1
  50989. * @param height ratio up height from 0 to 1
  50990. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50991. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50992. */
  50993. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50994. /**
  50995. * Append an hook to a rope object
  50996. * @param impostor is the rope impostor to add hook to
  50997. * @param otherImpostor is the rigid impostor to hook to
  50998. * @param length ratio along the rope from 0 to 1
  50999. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51000. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51001. */
  51002. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51003. /**
  51004. * Sleeps the physics body and stops it from being active
  51005. * @param impostor impostor to sleep
  51006. */
  51007. sleepBody(impostor: PhysicsImpostor): void;
  51008. /**
  51009. * Activates the physics body
  51010. * @param impostor impostor to activate
  51011. */
  51012. wakeUpBody(impostor: PhysicsImpostor): void;
  51013. /**
  51014. * Updates the distance parameters of the joint
  51015. * @param joint joint to update
  51016. * @param maxDistance maximum distance of the joint
  51017. * @param minDistance minimum distance of the joint
  51018. */
  51019. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51020. /**
  51021. * Sets a motor on the joint
  51022. * @param joint joint to set motor on
  51023. * @param speed speed of the motor
  51024. * @param maxForce maximum force of the motor
  51025. * @param motorIndex index of the motor
  51026. */
  51027. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51028. /**
  51029. * Sets the motors limit
  51030. * @param joint joint to set limit on
  51031. * @param upperLimit upper limit
  51032. * @param lowerLimit lower limit
  51033. */
  51034. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51035. /**
  51036. * Syncs the position and rotation of a mesh with the impostor
  51037. * @param mesh mesh to sync
  51038. * @param impostor impostor to update the mesh with
  51039. */
  51040. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51041. /**
  51042. * Gets the radius of the impostor
  51043. * @param impostor impostor to get radius from
  51044. * @returns the radius
  51045. */
  51046. getRadius(impostor: PhysicsImpostor): number;
  51047. /**
  51048. * Gets the box size of the impostor
  51049. * @param impostor impostor to get box size from
  51050. * @param result the resulting box size
  51051. */
  51052. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51053. /**
  51054. * Disposes of the impostor
  51055. */
  51056. dispose(): void;
  51057. /**
  51058. * Does a raycast in the physics world
  51059. * @param from when should the ray start?
  51060. * @param to when should the ray end?
  51061. * @returns PhysicsRaycastResult
  51062. */
  51063. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51064. }
  51065. }
  51066. declare module "babylonjs/Probes/reflectionProbe" {
  51067. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51068. import { Vector3 } from "babylonjs/Maths/math";
  51069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51070. import { Nullable } from "babylonjs/types";
  51071. import { Scene } from "babylonjs/scene";
  51072. module "babylonjs/abstractScene" {
  51073. interface AbstractScene {
  51074. /**
  51075. * The list of reflection probes added to the scene
  51076. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51077. */
  51078. reflectionProbes: Array<ReflectionProbe>;
  51079. /**
  51080. * Removes the given reflection probe from this scene.
  51081. * @param toRemove The reflection probe to remove
  51082. * @returns The index of the removed reflection probe
  51083. */
  51084. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51085. /**
  51086. * Adds the given reflection probe to this scene.
  51087. * @param newReflectionProbe The reflection probe to add
  51088. */
  51089. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51090. }
  51091. }
  51092. /**
  51093. * Class used to generate realtime reflection / refraction cube textures
  51094. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51095. */
  51096. export class ReflectionProbe {
  51097. /** defines the name of the probe */
  51098. name: string;
  51099. private _scene;
  51100. private _renderTargetTexture;
  51101. private _projectionMatrix;
  51102. private _viewMatrix;
  51103. private _target;
  51104. private _add;
  51105. private _attachedMesh;
  51106. private _invertYAxis;
  51107. /** Gets or sets probe position (center of the cube map) */
  51108. position: Vector3;
  51109. /**
  51110. * Creates a new reflection probe
  51111. * @param name defines the name of the probe
  51112. * @param size defines the texture resolution (for each face)
  51113. * @param scene defines the hosting scene
  51114. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51115. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51116. */
  51117. constructor(
  51118. /** defines the name of the probe */
  51119. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51120. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51121. samples: number;
  51122. /** Gets or sets the refresh rate to use (on every frame by default) */
  51123. refreshRate: number;
  51124. /**
  51125. * Gets the hosting scene
  51126. * @returns a Scene
  51127. */
  51128. getScene(): Scene;
  51129. /** Gets the internal CubeTexture used to render to */
  51130. readonly cubeTexture: RenderTargetTexture;
  51131. /** Gets the list of meshes to render */
  51132. readonly renderList: Nullable<AbstractMesh[]>;
  51133. /**
  51134. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51135. * @param mesh defines the mesh to attach to
  51136. */
  51137. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51138. /**
  51139. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51140. * @param renderingGroupId The rendering group id corresponding to its index
  51141. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51142. */
  51143. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51144. /**
  51145. * Clean all associated resources
  51146. */
  51147. dispose(): void;
  51148. /**
  51149. * Converts the reflection probe information to a readable string for debug purpose.
  51150. * @param fullDetails Supports for multiple levels of logging within scene loading
  51151. * @returns the human readable reflection probe info
  51152. */
  51153. toString(fullDetails?: boolean): string;
  51154. /**
  51155. * Get the class name of the relfection probe.
  51156. * @returns "ReflectionProbe"
  51157. */
  51158. getClassName(): string;
  51159. /**
  51160. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51161. * @returns The JSON representation of the texture
  51162. */
  51163. serialize(): any;
  51164. /**
  51165. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51166. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51167. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51168. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51169. * @returns The parsed reflection probe if successful
  51170. */
  51171. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51172. }
  51173. }
  51174. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51175. /** @hidden */
  51176. export var _BabylonLoaderRegistered: boolean;
  51177. }
  51178. declare module "babylonjs/Loading/Plugins/index" {
  51179. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51180. }
  51181. declare module "babylonjs/Loading/index" {
  51182. export * from "babylonjs/Loading/loadingScreen";
  51183. export * from "babylonjs/Loading/Plugins/index";
  51184. export * from "babylonjs/Loading/sceneLoader";
  51185. export * from "babylonjs/Loading/sceneLoaderFlags";
  51186. }
  51187. declare module "babylonjs/Materials/Background/index" {
  51188. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51189. }
  51190. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51191. import { Scene } from "babylonjs/scene";
  51192. import { Color3 } from "babylonjs/Maths/math";
  51193. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51194. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51195. /**
  51196. * The Physically based simple base material of BJS.
  51197. *
  51198. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51199. * It is used as the base class for both the specGloss and metalRough conventions.
  51200. */
  51201. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51202. /**
  51203. * Number of Simultaneous lights allowed on the material.
  51204. */
  51205. maxSimultaneousLights: number;
  51206. /**
  51207. * If sets to true, disables all the lights affecting the material.
  51208. */
  51209. disableLighting: boolean;
  51210. /**
  51211. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51212. */
  51213. environmentTexture: BaseTexture;
  51214. /**
  51215. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51216. */
  51217. invertNormalMapX: boolean;
  51218. /**
  51219. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51220. */
  51221. invertNormalMapY: boolean;
  51222. /**
  51223. * Normal map used in the model.
  51224. */
  51225. normalTexture: BaseTexture;
  51226. /**
  51227. * Emissivie color used to self-illuminate the model.
  51228. */
  51229. emissiveColor: Color3;
  51230. /**
  51231. * Emissivie texture used to self-illuminate the model.
  51232. */
  51233. emissiveTexture: BaseTexture;
  51234. /**
  51235. * Occlusion Channel Strenght.
  51236. */
  51237. occlusionStrength: number;
  51238. /**
  51239. * Occlusion Texture of the material (adding extra occlusion effects).
  51240. */
  51241. occlusionTexture: BaseTexture;
  51242. /**
  51243. * Defines the alpha limits in alpha test mode.
  51244. */
  51245. alphaCutOff: number;
  51246. /**
  51247. * Gets the current double sided mode.
  51248. */
  51249. /**
  51250. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51251. */
  51252. doubleSided: boolean;
  51253. /**
  51254. * Stores the pre-calculated light information of a mesh in a texture.
  51255. */
  51256. lightmapTexture: BaseTexture;
  51257. /**
  51258. * If true, the light map contains occlusion information instead of lighting info.
  51259. */
  51260. useLightmapAsShadowmap: boolean;
  51261. /**
  51262. * Instantiates a new PBRMaterial instance.
  51263. *
  51264. * @param name The material name
  51265. * @param scene The scene the material will be use in.
  51266. */
  51267. constructor(name: string, scene: Scene);
  51268. getClassName(): string;
  51269. }
  51270. }
  51271. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51272. import { Scene } from "babylonjs/scene";
  51273. import { Color3 } from "babylonjs/Maths/math";
  51274. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51275. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51276. /**
  51277. * The PBR material of BJS following the metal roughness convention.
  51278. *
  51279. * This fits to the PBR convention in the GLTF definition:
  51280. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51281. */
  51282. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51283. /**
  51284. * The base color has two different interpretations depending on the value of metalness.
  51285. * When the material is a metal, the base color is the specific measured reflectance value
  51286. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51287. * of the material.
  51288. */
  51289. baseColor: Color3;
  51290. /**
  51291. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51292. * well as opacity information in the alpha channel.
  51293. */
  51294. baseTexture: BaseTexture;
  51295. /**
  51296. * Specifies the metallic scalar value of the material.
  51297. * Can also be used to scale the metalness values of the metallic texture.
  51298. */
  51299. metallic: number;
  51300. /**
  51301. * Specifies the roughness scalar value of the material.
  51302. * Can also be used to scale the roughness values of the metallic texture.
  51303. */
  51304. roughness: number;
  51305. /**
  51306. * Texture containing both the metallic value in the B channel and the
  51307. * roughness value in the G channel to keep better precision.
  51308. */
  51309. metallicRoughnessTexture: BaseTexture;
  51310. /**
  51311. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51312. *
  51313. * @param name The material name
  51314. * @param scene The scene the material will be use in.
  51315. */
  51316. constructor(name: string, scene: Scene);
  51317. /**
  51318. * Return the currrent class name of the material.
  51319. */
  51320. getClassName(): string;
  51321. /**
  51322. * Makes a duplicate of the current material.
  51323. * @param name - name to use for the new material.
  51324. */
  51325. clone(name: string): PBRMetallicRoughnessMaterial;
  51326. /**
  51327. * Serialize the material to a parsable JSON object.
  51328. */
  51329. serialize(): any;
  51330. /**
  51331. * Parses a JSON object correponding to the serialize function.
  51332. */
  51333. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51334. }
  51335. }
  51336. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51337. import { Scene } from "babylonjs/scene";
  51338. import { Color3 } from "babylonjs/Maths/math";
  51339. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51340. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51341. /**
  51342. * The PBR material of BJS following the specular glossiness convention.
  51343. *
  51344. * This fits to the PBR convention in the GLTF definition:
  51345. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51346. */
  51347. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51348. /**
  51349. * Specifies the diffuse color of the material.
  51350. */
  51351. diffuseColor: Color3;
  51352. /**
  51353. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51354. * channel.
  51355. */
  51356. diffuseTexture: BaseTexture;
  51357. /**
  51358. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51359. */
  51360. specularColor: Color3;
  51361. /**
  51362. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51363. */
  51364. glossiness: number;
  51365. /**
  51366. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51367. */
  51368. specularGlossinessTexture: BaseTexture;
  51369. /**
  51370. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51371. *
  51372. * @param name The material name
  51373. * @param scene The scene the material will be use in.
  51374. */
  51375. constructor(name: string, scene: Scene);
  51376. /**
  51377. * Return the currrent class name of the material.
  51378. */
  51379. getClassName(): string;
  51380. /**
  51381. * Makes a duplicate of the current material.
  51382. * @param name - name to use for the new material.
  51383. */
  51384. clone(name: string): PBRSpecularGlossinessMaterial;
  51385. /**
  51386. * Serialize the material to a parsable JSON object.
  51387. */
  51388. serialize(): any;
  51389. /**
  51390. * Parses a JSON object correponding to the serialize function.
  51391. */
  51392. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51393. }
  51394. }
  51395. declare module "babylonjs/Materials/PBR/index" {
  51396. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51397. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51398. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51399. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51400. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51401. }
  51402. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  51403. import { Nullable } from "babylonjs/types";
  51404. import { Scene } from "babylonjs/scene";
  51405. import { Matrix } from "babylonjs/Maths/math";
  51406. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51407. /**
  51408. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51409. * It can help converting any input color in a desired output one. This can then be used to create effects
  51410. * from sepia, black and white to sixties or futuristic rendering...
  51411. *
  51412. * The only supported format is currently 3dl.
  51413. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51414. */
  51415. export class ColorGradingTexture extends BaseTexture {
  51416. /**
  51417. * The current texture matrix. (will always be identity in color grading texture)
  51418. */
  51419. private _textureMatrix;
  51420. /**
  51421. * The texture URL.
  51422. */
  51423. url: string;
  51424. /**
  51425. * Empty line regex stored for GC.
  51426. */
  51427. private static _noneEmptyLineRegex;
  51428. private _engine;
  51429. /**
  51430. * Instantiates a ColorGradingTexture from the following parameters.
  51431. *
  51432. * @param url The location of the color gradind data (currently only supporting 3dl)
  51433. * @param scene The scene the texture will be used in
  51434. */
  51435. constructor(url: string, scene: Scene);
  51436. /**
  51437. * Returns the texture matrix used in most of the material.
  51438. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51439. */
  51440. getTextureMatrix(): Matrix;
  51441. /**
  51442. * Occurs when the file being loaded is a .3dl LUT file.
  51443. */
  51444. private load3dlTexture;
  51445. /**
  51446. * Starts the loading process of the texture.
  51447. */
  51448. private loadTexture;
  51449. /**
  51450. * Clones the color gradind texture.
  51451. */
  51452. clone(): ColorGradingTexture;
  51453. /**
  51454. * Called during delayed load for textures.
  51455. */
  51456. delayLoad(): void;
  51457. /**
  51458. * Parses a color grading texture serialized by Babylon.
  51459. * @param parsedTexture The texture information being parsedTexture
  51460. * @param scene The scene to load the texture in
  51461. * @param rootUrl The root url of the data assets to load
  51462. * @return A color gradind texture
  51463. */
  51464. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51465. /**
  51466. * Serializes the LUT texture to json format.
  51467. */
  51468. serialize(): any;
  51469. }
  51470. }
  51471. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  51472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51473. import { Scene } from "babylonjs/scene";
  51474. import { Nullable } from "babylonjs/types";
  51475. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51476. /**
  51477. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51478. */
  51479. export class EquiRectangularCubeTexture extends BaseTexture {
  51480. /** The six faces of the cube. */
  51481. private static _FacesMapping;
  51482. private _noMipmap;
  51483. private _onLoad;
  51484. private _onError;
  51485. /** The size of the cubemap. */
  51486. private _size;
  51487. /** The buffer of the image. */
  51488. private _buffer;
  51489. /** The width of the input image. */
  51490. private _width;
  51491. /** The height of the input image. */
  51492. private _height;
  51493. /** The URL to the image. */
  51494. url: string;
  51495. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51496. coordinatesMode: number;
  51497. /**
  51498. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51499. * @param url The location of the image
  51500. * @param scene The scene the texture will be used in
  51501. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51502. * @param noMipmap Forces to not generate the mipmap if true
  51503. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51504. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51505. * @param onLoad — defines a callback called when texture is loaded
  51506. * @param onError — defines a callback called if there is an error
  51507. */
  51508. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51509. /**
  51510. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51511. */
  51512. private loadImage;
  51513. /**
  51514. * Convert the image buffer into a cubemap and create a CubeTexture.
  51515. */
  51516. private loadTexture;
  51517. /**
  51518. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51519. * @param buffer The ArrayBuffer that should be converted.
  51520. * @returns The buffer as Float32Array.
  51521. */
  51522. private getFloat32ArrayFromArrayBuffer;
  51523. /**
  51524. * Get the current class name of the texture useful for serialization or dynamic coding.
  51525. * @returns "EquiRectangularCubeTexture"
  51526. */
  51527. getClassName(): string;
  51528. /**
  51529. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51530. * @returns A clone of the current EquiRectangularCubeTexture.
  51531. */
  51532. clone(): EquiRectangularCubeTexture;
  51533. }
  51534. }
  51535. declare module "babylonjs/Misc/tga" {
  51536. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51537. /**
  51538. * Based on jsTGALoader - Javascript loader for TGA file
  51539. * By Vincent Thibault
  51540. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51541. */
  51542. export class TGATools {
  51543. private static _TYPE_INDEXED;
  51544. private static _TYPE_RGB;
  51545. private static _TYPE_GREY;
  51546. private static _TYPE_RLE_INDEXED;
  51547. private static _TYPE_RLE_RGB;
  51548. private static _TYPE_RLE_GREY;
  51549. private static _ORIGIN_MASK;
  51550. private static _ORIGIN_SHIFT;
  51551. private static _ORIGIN_BL;
  51552. private static _ORIGIN_BR;
  51553. private static _ORIGIN_UL;
  51554. private static _ORIGIN_UR;
  51555. /**
  51556. * Gets the header of a TGA file
  51557. * @param data defines the TGA data
  51558. * @returns the header
  51559. */
  51560. static GetTGAHeader(data: Uint8Array): any;
  51561. /**
  51562. * Uploads TGA content to a Babylon Texture
  51563. * @hidden
  51564. */
  51565. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51566. /** @hidden */
  51567. 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;
  51568. /** @hidden */
  51569. 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;
  51570. /** @hidden */
  51571. 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;
  51572. /** @hidden */
  51573. 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;
  51574. /** @hidden */
  51575. 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;
  51576. /** @hidden */
  51577. 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;
  51578. }
  51579. }
  51580. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51581. import { Nullable } from "babylonjs/types";
  51582. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51583. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51584. /**
  51585. * Implementation of the TGA Texture Loader.
  51586. * @hidden
  51587. */
  51588. export class _TGATextureLoader implements IInternalTextureLoader {
  51589. /**
  51590. * Defines wether the loader supports cascade loading the different faces.
  51591. */
  51592. readonly supportCascades: boolean;
  51593. /**
  51594. * This returns if the loader support the current file information.
  51595. * @param extension defines the file extension of the file being loaded
  51596. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51597. * @param fallback defines the fallback internal texture if any
  51598. * @param isBase64 defines whether the texture is encoded as a base64
  51599. * @param isBuffer defines whether the texture data are stored as a buffer
  51600. * @returns true if the loader can load the specified file
  51601. */
  51602. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51603. /**
  51604. * Transform the url before loading if required.
  51605. * @param rootUrl the url of the texture
  51606. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51607. * @returns the transformed texture
  51608. */
  51609. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51610. /**
  51611. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51612. * @param rootUrl the url of the texture
  51613. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51614. * @returns the fallback texture
  51615. */
  51616. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51617. /**
  51618. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51619. * @param data contains the texture data
  51620. * @param texture defines the BabylonJS internal texture
  51621. * @param createPolynomials will be true if polynomials have been requested
  51622. * @param onLoad defines the callback to trigger once the texture is ready
  51623. * @param onError defines the callback to trigger in case of error
  51624. */
  51625. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51626. /**
  51627. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51628. * @param data contains the texture data
  51629. * @param texture defines the BabylonJS internal texture
  51630. * @param callback defines the method to call once ready to upload
  51631. */
  51632. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51633. }
  51634. }
  51635. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51636. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51637. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51638. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51639. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51640. }
  51641. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51642. import { Scene } from "babylonjs/scene";
  51643. import { Texture } from "babylonjs/Materials/Textures/texture";
  51644. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51645. /**
  51646. * 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.
  51647. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51648. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51649. */
  51650. export class CustomProceduralTexture extends ProceduralTexture {
  51651. private _animate;
  51652. private _time;
  51653. private _config;
  51654. private _texturePath;
  51655. /**
  51656. * Instantiates a new Custom Procedural Texture.
  51657. * 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.
  51658. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51659. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51660. * @param name Define the name of the texture
  51661. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51662. * @param size Define the size of the texture to create
  51663. * @param scene Define the scene the texture belongs to
  51664. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51665. * @param generateMipMaps Define if the texture should creates mip maps or not
  51666. */
  51667. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51668. private _loadJson;
  51669. /**
  51670. * Is the texture ready to be used ? (rendered at least once)
  51671. * @returns true if ready, otherwise, false.
  51672. */
  51673. isReady(): boolean;
  51674. /**
  51675. * Render the texture to its associated render target.
  51676. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51677. */
  51678. render(useCameraPostProcess?: boolean): void;
  51679. /**
  51680. * Update the list of dependant textures samplers in the shader.
  51681. */
  51682. updateTextures(): void;
  51683. /**
  51684. * Update the uniform values of the procedural texture in the shader.
  51685. */
  51686. updateShaderUniforms(): void;
  51687. /**
  51688. * Define if the texture animates or not.
  51689. */
  51690. animate: boolean;
  51691. }
  51692. }
  51693. declare module "babylonjs/Shaders/noise.fragment" {
  51694. /** @hidden */
  51695. export var noisePixelShader: {
  51696. name: string;
  51697. shader: string;
  51698. };
  51699. }
  51700. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51701. import { Nullable } from "babylonjs/types";
  51702. import { Scene } from "babylonjs/scene";
  51703. import { Texture } from "babylonjs/Materials/Textures/texture";
  51704. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51705. import "babylonjs/Shaders/noise.fragment";
  51706. /**
  51707. * Class used to generate noise procedural textures
  51708. */
  51709. export class NoiseProceduralTexture extends ProceduralTexture {
  51710. private _time;
  51711. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51712. brightness: number;
  51713. /** Defines the number of octaves to process */
  51714. octaves: number;
  51715. /** Defines the level of persistence (0.8 by default) */
  51716. persistence: number;
  51717. /** Gets or sets animation speed factor (default is 1) */
  51718. animationSpeedFactor: number;
  51719. /**
  51720. * Creates a new NoiseProceduralTexture
  51721. * @param name defines the name fo the texture
  51722. * @param size defines the size of the texture (default is 256)
  51723. * @param scene defines the hosting scene
  51724. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51725. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51726. */
  51727. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51728. private _updateShaderUniforms;
  51729. protected _getDefines(): string;
  51730. /** Generate the current state of the procedural texture */
  51731. render(useCameraPostProcess?: boolean): void;
  51732. /**
  51733. * Serializes this noise procedural texture
  51734. * @returns a serialized noise procedural texture object
  51735. */
  51736. serialize(): any;
  51737. /**
  51738. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51739. * @param parsedTexture defines parsed texture data
  51740. * @param scene defines the current scene
  51741. * @param rootUrl defines the root URL containing noise procedural texture information
  51742. * @returns a parsed NoiseProceduralTexture
  51743. */
  51744. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51745. }
  51746. }
  51747. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51748. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51749. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51750. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51751. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51752. }
  51753. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51754. import { Nullable } from "babylonjs/types";
  51755. import { Scene } from "babylonjs/scene";
  51756. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51757. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51758. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51759. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51760. /**
  51761. * Raw cube texture where the raw buffers are passed in
  51762. */
  51763. export class RawCubeTexture extends CubeTexture {
  51764. /**
  51765. * Creates a cube texture where the raw buffers are passed in.
  51766. * @param scene defines the scene the texture is attached to
  51767. * @param data defines the array of data to use to create each face
  51768. * @param size defines the size of the textures
  51769. * @param format defines the format of the data
  51770. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51771. * @param generateMipMaps defines if the engine should generate the mip levels
  51772. * @param invertY defines if data must be stored with Y axis inverted
  51773. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51774. * @param compression defines the compression used (null by default)
  51775. */
  51776. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51777. /**
  51778. * Updates the raw cube texture.
  51779. * @param data defines the data to store
  51780. * @param format defines the data format
  51781. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51782. * @param invertY defines if data must be stored with Y axis inverted
  51783. * @param compression defines the compression used (null by default)
  51784. * @param level defines which level of the texture to update
  51785. */
  51786. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51787. /**
  51788. * Updates a raw cube texture with RGBD encoded data.
  51789. * @param data defines the array of data [mipmap][face] to use to create each face
  51790. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51791. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51792. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51793. * @returns a promsie that resolves when the operation is complete
  51794. */
  51795. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51796. /**
  51797. * Clones the raw cube texture.
  51798. * @return a new cube texture
  51799. */
  51800. clone(): CubeTexture;
  51801. /** @hidden */
  51802. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51803. }
  51804. }
  51805. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51806. import { Scene } from "babylonjs/scene";
  51807. import { Texture } from "babylonjs/Materials/Textures/texture";
  51808. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51809. /**
  51810. * Class used to store 3D textures containing user data
  51811. */
  51812. export class RawTexture3D extends Texture {
  51813. /** Gets or sets the texture format to use */
  51814. format: number;
  51815. private _engine;
  51816. /**
  51817. * Create a new RawTexture3D
  51818. * @param data defines the data of the texture
  51819. * @param width defines the width of the texture
  51820. * @param height defines the height of the texture
  51821. * @param depth defines the depth of the texture
  51822. * @param format defines the texture format to use
  51823. * @param scene defines the hosting scene
  51824. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51825. * @param invertY defines if texture must be stored with Y axis inverted
  51826. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51827. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51828. */
  51829. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51830. /** Gets or sets the texture format to use */
  51831. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51832. /**
  51833. * Update the texture with new data
  51834. * @param data defines the data to store in the texture
  51835. */
  51836. update(data: ArrayBufferView): void;
  51837. }
  51838. }
  51839. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51840. import { Scene } from "babylonjs/scene";
  51841. import { Plane } from "babylonjs/Maths/math";
  51842. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51843. /**
  51844. * Creates a refraction texture used by refraction channel of the standard material.
  51845. * It is like a mirror but to see through a material.
  51846. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51847. */
  51848. export class RefractionTexture extends RenderTargetTexture {
  51849. /**
  51850. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51851. * 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.
  51852. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51853. */
  51854. refractionPlane: Plane;
  51855. /**
  51856. * Define how deep under the surface we should see.
  51857. */
  51858. depth: number;
  51859. /**
  51860. * Creates a refraction texture used by refraction channel of the standard material.
  51861. * It is like a mirror but to see through a material.
  51862. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51863. * @param name Define the texture name
  51864. * @param size Define the size of the underlying texture
  51865. * @param scene Define the scene the refraction belongs to
  51866. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51867. */
  51868. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51869. /**
  51870. * Clone the refraction texture.
  51871. * @returns the cloned texture
  51872. */
  51873. clone(): RefractionTexture;
  51874. /**
  51875. * Serialize the texture to a JSON representation you could use in Parse later on
  51876. * @returns the serialized JSON representation
  51877. */
  51878. serialize(): any;
  51879. }
  51880. }
  51881. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  51882. import { Nullable } from "babylonjs/types";
  51883. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51884. import { Matrix } from "babylonjs/Maths/math";
  51885. import { Engine } from "babylonjs/Engines/engine";
  51886. import { Scene } from "babylonjs/scene";
  51887. /**
  51888. * Defines the options related to the creation of an HtmlElementTexture
  51889. */
  51890. export interface IHtmlElementTextureOptions {
  51891. /**
  51892. * Defines wether mip maps should be created or not.
  51893. */
  51894. generateMipMaps?: boolean;
  51895. /**
  51896. * Defines the sampling mode of the texture.
  51897. */
  51898. samplingMode?: number;
  51899. /**
  51900. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51901. */
  51902. engine: Nullable<Engine>;
  51903. /**
  51904. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51905. */
  51906. scene: Nullable<Scene>;
  51907. }
  51908. /**
  51909. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51910. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51911. * is automatically managed.
  51912. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51913. * in your application.
  51914. *
  51915. * As the update is not automatic, you need to call them manually.
  51916. */
  51917. export class HtmlElementTexture extends BaseTexture {
  51918. /**
  51919. * The texture URL.
  51920. */
  51921. element: HTMLVideoElement | HTMLCanvasElement;
  51922. private static readonly DefaultOptions;
  51923. private _textureMatrix;
  51924. private _engine;
  51925. private _isVideo;
  51926. private _generateMipMaps;
  51927. private _samplingMode;
  51928. /**
  51929. * Instantiates a HtmlElementTexture from the following parameters.
  51930. *
  51931. * @param name Defines the name of the texture
  51932. * @param element Defines the video or canvas the texture is filled with
  51933. * @param options Defines the other none mandatory texture creation options
  51934. */
  51935. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51936. private _createInternalTexture;
  51937. /**
  51938. * Returns the texture matrix used in most of the material.
  51939. */
  51940. getTextureMatrix(): Matrix;
  51941. /**
  51942. * Updates the content of the texture.
  51943. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51944. */
  51945. update(invertY?: Nullable<boolean>): void;
  51946. }
  51947. }
  51948. declare module "babylonjs/Materials/Textures/index" {
  51949. export * from "babylonjs/Materials/Textures/baseTexture";
  51950. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51951. export * from "babylonjs/Materials/Textures/cubeTexture";
  51952. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51953. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51954. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51955. export * from "babylonjs/Materials/Textures/internalTexture";
  51956. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51957. export * from "babylonjs/Materials/Textures/Loaders/index";
  51958. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51959. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51960. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51961. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51962. export * from "babylonjs/Materials/Textures/rawTexture";
  51963. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51964. export * from "babylonjs/Materials/Textures/refractionTexture";
  51965. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51966. export * from "babylonjs/Materials/Textures/texture";
  51967. export * from "babylonjs/Materials/Textures/videoTexture";
  51968. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  51969. }
  51970. declare module "babylonjs/Materials/index" {
  51971. export * from "babylonjs/Materials/Background/index";
  51972. export * from "babylonjs/Materials/colorCurves";
  51973. export * from "babylonjs/Materials/effect";
  51974. export * from "babylonjs/Materials/fresnelParameters";
  51975. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51976. export * from "babylonjs/Materials/material";
  51977. export * from "babylonjs/Materials/materialDefines";
  51978. export * from "babylonjs/Materials/materialHelper";
  51979. export * from "babylonjs/Materials/multiMaterial";
  51980. export * from "babylonjs/Materials/PBR/index";
  51981. export * from "babylonjs/Materials/pushMaterial";
  51982. export * from "babylonjs/Materials/shaderMaterial";
  51983. export * from "babylonjs/Materials/standardMaterial";
  51984. export * from "babylonjs/Materials/Textures/index";
  51985. export * from "babylonjs/Materials/uniformBuffer";
  51986. export * from "babylonjs/Materials/materialFlags";
  51987. }
  51988. declare module "babylonjs/Maths/index" {
  51989. export * from "babylonjs/Maths/math.scalar";
  51990. export * from "babylonjs/Maths/math";
  51991. export * from "babylonjs/Maths/sphericalPolynomial";
  51992. }
  51993. declare module "babylonjs/Misc/workerPool" {
  51994. import { IDisposable } from "babylonjs/scene";
  51995. /**
  51996. * Helper class to push actions to a pool of workers.
  51997. */
  51998. export class WorkerPool implements IDisposable {
  51999. private _workerInfos;
  52000. private _pendingActions;
  52001. /**
  52002. * Constructor
  52003. * @param workers Array of workers to use for actions
  52004. */
  52005. constructor(workers: Array<Worker>);
  52006. /**
  52007. * Terminates all workers and clears any pending actions.
  52008. */
  52009. dispose(): void;
  52010. /**
  52011. * Pushes an action to the worker pool. If all the workers are active, the action will be
  52012. * pended until a worker has completed its action.
  52013. * @param action The action to perform. Call onComplete when the action is complete.
  52014. */
  52015. push(action: (worker: Worker, onComplete: () => void) => void): void;
  52016. private _execute;
  52017. }
  52018. }
  52019. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  52020. import { IDisposable } from "babylonjs/scene";
  52021. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  52022. /**
  52023. * Configuration for Draco compression
  52024. */
  52025. export interface IDracoCompressionConfiguration {
  52026. /**
  52027. * Configuration for the decoder.
  52028. */
  52029. decoder: {
  52030. /**
  52031. * The url to the WebAssembly module.
  52032. */
  52033. wasmUrl?: string;
  52034. /**
  52035. * The url to the WebAssembly binary.
  52036. */
  52037. wasmBinaryUrl?: string;
  52038. /**
  52039. * The url to the fallback JavaScript module.
  52040. */
  52041. fallbackUrl?: string;
  52042. };
  52043. }
  52044. /**
  52045. * Draco compression (https://google.github.io/draco/)
  52046. *
  52047. * This class wraps the Draco module.
  52048. *
  52049. * **Encoder**
  52050. *
  52051. * The encoder is not currently implemented.
  52052. *
  52053. * **Decoder**
  52054. *
  52055. * 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.
  52056. *
  52057. * To update the configuration, use the following code:
  52058. * ```javascript
  52059. * DracoCompression.Configuration = {
  52060. * decoder: {
  52061. * wasmUrl: "<url to the WebAssembly library>",
  52062. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  52063. * fallbackUrl: "<url to the fallback JavaScript library>",
  52064. * }
  52065. * };
  52066. * ```
  52067. *
  52068. * 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.
  52069. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  52070. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  52071. *
  52072. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  52073. * ```javascript
  52074. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  52075. * ```
  52076. *
  52077. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52078. */
  52079. export class DracoCompression implements IDisposable {
  52080. private _workerPoolPromise?;
  52081. private _decoderModulePromise?;
  52082. /**
  52083. * The configuration. Defaults to the following urls:
  52084. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52085. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  52086. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52087. */
  52088. static Configuration: IDracoCompressionConfiguration;
  52089. /**
  52090. * Returns true if the decoder configuration is available.
  52091. */
  52092. static readonly DecoderAvailable: boolean;
  52093. /**
  52094. * Default number of workers to create when creating the draco compression object.
  52095. */
  52096. static DefaultNumWorkers: number;
  52097. private static GetDefaultNumWorkers;
  52098. private static _Default;
  52099. /**
  52100. * Default instance for the draco compression object.
  52101. */
  52102. static readonly Default: DracoCompression;
  52103. /**
  52104. * Constructor
  52105. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  52106. */
  52107. constructor(numWorkers?: number);
  52108. /**
  52109. * Stop all async operations and release resources.
  52110. */
  52111. dispose(): void;
  52112. /**
  52113. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52114. * @returns a promise that resolves when ready
  52115. */
  52116. whenReadyAsync(): Promise<void>;
  52117. /**
  52118. * Decode Draco compressed mesh data to vertex data.
  52119. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52120. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52121. * @returns A promise that resolves with the decoded vertex data
  52122. */
  52123. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52124. [kind: string]: number;
  52125. }): Promise<VertexData>;
  52126. }
  52127. }
  52128. declare module "babylonjs/Meshes/Compression/index" {
  52129. export * from "babylonjs/Meshes/Compression/dracoCompression";
  52130. }
  52131. declare module "babylonjs/Meshes/csg" {
  52132. import { Nullable } from "babylonjs/types";
  52133. import { Scene } from "babylonjs/scene";
  52134. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  52135. import { Mesh } from "babylonjs/Meshes/mesh";
  52136. import { Material } from "babylonjs/Materials/material";
  52137. /**
  52138. * Class for building Constructive Solid Geometry
  52139. */
  52140. export class CSG {
  52141. private polygons;
  52142. /**
  52143. * The world matrix
  52144. */
  52145. matrix: Matrix;
  52146. /**
  52147. * Stores the position
  52148. */
  52149. position: Vector3;
  52150. /**
  52151. * Stores the rotation
  52152. */
  52153. rotation: Vector3;
  52154. /**
  52155. * Stores the rotation quaternion
  52156. */
  52157. rotationQuaternion: Nullable<Quaternion>;
  52158. /**
  52159. * Stores the scaling vector
  52160. */
  52161. scaling: Vector3;
  52162. /**
  52163. * Convert the Mesh to CSG
  52164. * @param mesh The Mesh to convert to CSG
  52165. * @returns A new CSG from the Mesh
  52166. */
  52167. static FromMesh(mesh: Mesh): CSG;
  52168. /**
  52169. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52170. * @param polygons Polygons used to construct a CSG solid
  52171. */
  52172. private static FromPolygons;
  52173. /**
  52174. * Clones, or makes a deep copy, of the CSG
  52175. * @returns A new CSG
  52176. */
  52177. clone(): CSG;
  52178. /**
  52179. * Unions this CSG with another CSG
  52180. * @param csg The CSG to union against this CSG
  52181. * @returns The unioned CSG
  52182. */
  52183. union(csg: CSG): CSG;
  52184. /**
  52185. * Unions this CSG with another CSG in place
  52186. * @param csg The CSG to union against this CSG
  52187. */
  52188. unionInPlace(csg: CSG): void;
  52189. /**
  52190. * Subtracts this CSG with another CSG
  52191. * @param csg The CSG to subtract against this CSG
  52192. * @returns A new CSG
  52193. */
  52194. subtract(csg: CSG): CSG;
  52195. /**
  52196. * Subtracts this CSG with another CSG in place
  52197. * @param csg The CSG to subtact against this CSG
  52198. */
  52199. subtractInPlace(csg: CSG): void;
  52200. /**
  52201. * Intersect this CSG with another CSG
  52202. * @param csg The CSG to intersect against this CSG
  52203. * @returns A new CSG
  52204. */
  52205. intersect(csg: CSG): CSG;
  52206. /**
  52207. * Intersects this CSG with another CSG in place
  52208. * @param csg The CSG to intersect against this CSG
  52209. */
  52210. intersectInPlace(csg: CSG): void;
  52211. /**
  52212. * Return a new CSG solid with solid and empty space switched. This solid is
  52213. * not modified.
  52214. * @returns A new CSG solid with solid and empty space switched
  52215. */
  52216. inverse(): CSG;
  52217. /**
  52218. * Inverses the CSG in place
  52219. */
  52220. inverseInPlace(): void;
  52221. /**
  52222. * This is used to keep meshes transformations so they can be restored
  52223. * when we build back a Babylon Mesh
  52224. * NB : All CSG operations are performed in world coordinates
  52225. * @param csg The CSG to copy the transform attributes from
  52226. * @returns This CSG
  52227. */
  52228. copyTransformAttributes(csg: CSG): CSG;
  52229. /**
  52230. * Build Raw mesh from CSG
  52231. * Coordinates here are in world space
  52232. * @param name The name of the mesh geometry
  52233. * @param scene The Scene
  52234. * @param keepSubMeshes Specifies if the submeshes should be kept
  52235. * @returns A new Mesh
  52236. */
  52237. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52238. /**
  52239. * Build Mesh from CSG taking material and transforms into account
  52240. * @param name The name of the Mesh
  52241. * @param material The material of the Mesh
  52242. * @param scene The Scene
  52243. * @param keepSubMeshes Specifies if submeshes should be kept
  52244. * @returns The new Mesh
  52245. */
  52246. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52247. }
  52248. }
  52249. declare module "babylonjs/Meshes/trailMesh" {
  52250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52251. import { Mesh } from "babylonjs/Meshes/mesh";
  52252. import { Scene } from "babylonjs/scene";
  52253. /**
  52254. * Class used to create a trail following a mesh
  52255. */
  52256. export class TrailMesh extends Mesh {
  52257. private _generator;
  52258. private _autoStart;
  52259. private _running;
  52260. private _diameter;
  52261. private _length;
  52262. private _sectionPolygonPointsCount;
  52263. private _sectionVectors;
  52264. private _sectionNormalVectors;
  52265. private _beforeRenderObserver;
  52266. /**
  52267. * @constructor
  52268. * @param name The value used by scene.getMeshByName() to do a lookup.
  52269. * @param generator The mesh to generate a trail.
  52270. * @param scene The scene to add this mesh to.
  52271. * @param diameter Diameter of trailing mesh. Default is 1.
  52272. * @param length Length of trailing mesh. Default is 60.
  52273. * @param autoStart Automatically start trailing mesh. Default true.
  52274. */
  52275. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52276. /**
  52277. * "TrailMesh"
  52278. * @returns "TrailMesh"
  52279. */
  52280. getClassName(): string;
  52281. private _createMesh;
  52282. /**
  52283. * Start trailing mesh.
  52284. */
  52285. start(): void;
  52286. /**
  52287. * Stop trailing mesh.
  52288. */
  52289. stop(): void;
  52290. /**
  52291. * Update trailing mesh geometry.
  52292. */
  52293. update(): void;
  52294. /**
  52295. * Returns a new TrailMesh object.
  52296. * @param name is a string, the name given to the new mesh
  52297. * @param newGenerator use new generator object for cloned trail mesh
  52298. * @returns a new mesh
  52299. */
  52300. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52301. /**
  52302. * Serializes this trail mesh
  52303. * @param serializationObject object to write serialization to
  52304. */
  52305. serialize(serializationObject: any): void;
  52306. /**
  52307. * Parses a serialized trail mesh
  52308. * @param parsedMesh the serialized mesh
  52309. * @param scene the scene to create the trail mesh in
  52310. * @returns the created trail mesh
  52311. */
  52312. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52313. }
  52314. }
  52315. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  52316. import { Vector4 } from "babylonjs/Maths/math";
  52317. import { Mesh } from "babylonjs/Meshes/mesh";
  52318. /**
  52319. * Class containing static functions to help procedurally build meshes
  52320. */
  52321. export class TorusKnotBuilder {
  52322. /**
  52323. * Creates a torus knot mesh
  52324. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52325. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52326. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52327. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52331. * @param name defines the name of the mesh
  52332. * @param options defines the options used to create the mesh
  52333. * @param scene defines the hosting scene
  52334. * @returns the torus knot mesh
  52335. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52336. */
  52337. static CreateTorusKnot(name: string, options: {
  52338. radius?: number;
  52339. tube?: number;
  52340. radialSegments?: number;
  52341. tubularSegments?: number;
  52342. p?: number;
  52343. q?: number;
  52344. updatable?: boolean;
  52345. sideOrientation?: number;
  52346. frontUVs?: Vector4;
  52347. backUVs?: Vector4;
  52348. }, scene: any): Mesh;
  52349. }
  52350. }
  52351. declare module "babylonjs/Meshes/polygonMesh" {
  52352. import { Scene } from "babylonjs/scene";
  52353. import { Vector2, Path2 } from "babylonjs/Maths/math";
  52354. import { Mesh } from "babylonjs/Meshes/mesh";
  52355. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  52356. /**
  52357. * Polygon
  52358. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52359. */
  52360. export class Polygon {
  52361. /**
  52362. * Creates a rectangle
  52363. * @param xmin bottom X coord
  52364. * @param ymin bottom Y coord
  52365. * @param xmax top X coord
  52366. * @param ymax top Y coord
  52367. * @returns points that make the resulting rectation
  52368. */
  52369. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52370. /**
  52371. * Creates a circle
  52372. * @param radius radius of circle
  52373. * @param cx scale in x
  52374. * @param cy scale in y
  52375. * @param numberOfSides number of sides that make up the circle
  52376. * @returns points that make the resulting circle
  52377. */
  52378. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52379. /**
  52380. * Creates a polygon from input string
  52381. * @param input Input polygon data
  52382. * @returns the parsed points
  52383. */
  52384. static Parse(input: string): Vector2[];
  52385. /**
  52386. * Starts building a polygon from x and y coordinates
  52387. * @param x x coordinate
  52388. * @param y y coordinate
  52389. * @returns the started path2
  52390. */
  52391. static StartingAt(x: number, y: number): Path2;
  52392. }
  52393. /**
  52394. * Builds a polygon
  52395. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52396. */
  52397. export class PolygonMeshBuilder {
  52398. private _points;
  52399. private _outlinepoints;
  52400. private _holes;
  52401. private _name;
  52402. private _scene;
  52403. private _epoints;
  52404. private _eholes;
  52405. private _addToepoint;
  52406. /**
  52407. * Babylon reference to the earcut plugin.
  52408. */
  52409. bjsEarcut: any;
  52410. /**
  52411. * Creates a PolygonMeshBuilder
  52412. * @param name name of the builder
  52413. * @param contours Path of the polygon
  52414. * @param scene scene to add to when creating the mesh
  52415. * @param earcutInjection can be used to inject your own earcut reference
  52416. */
  52417. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52418. /**
  52419. * Adds a whole within the polygon
  52420. * @param hole Array of points defining the hole
  52421. * @returns this
  52422. */
  52423. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52424. /**
  52425. * Creates the polygon
  52426. * @param updatable If the mesh should be updatable
  52427. * @param depth The depth of the mesh created
  52428. * @returns the created mesh
  52429. */
  52430. build(updatable?: boolean, depth?: number): Mesh;
  52431. /**
  52432. * Creates the polygon
  52433. * @param depth The depth of the mesh created
  52434. * @returns the created VertexData
  52435. */
  52436. buildVertexData(depth?: number): VertexData;
  52437. /**
  52438. * Adds a side to the polygon
  52439. * @param positions points that make the polygon
  52440. * @param normals normals of the polygon
  52441. * @param uvs uvs of the polygon
  52442. * @param indices indices of the polygon
  52443. * @param bounds bounds of the polygon
  52444. * @param points points of the polygon
  52445. * @param depth depth of the polygon
  52446. * @param flip flip of the polygon
  52447. */
  52448. private addSide;
  52449. }
  52450. }
  52451. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  52452. import { Scene } from "babylonjs/scene";
  52453. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  52454. import { Mesh } from "babylonjs/Meshes/mesh";
  52455. import { Nullable } from "babylonjs/types";
  52456. /**
  52457. * Class containing static functions to help procedurally build meshes
  52458. */
  52459. export class PolygonBuilder {
  52460. /**
  52461. * Creates a polygon mesh
  52462. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52463. * * 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
  52464. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52466. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52467. * * Remember you can only change the shape positions, not their number when updating a polygon
  52468. * @param name defines the name of the mesh
  52469. * @param options defines the options used to create the mesh
  52470. * @param scene defines the hosting scene
  52471. * @param earcutInjection can be used to inject your own earcut reference
  52472. * @returns the polygon mesh
  52473. */
  52474. static CreatePolygon(name: string, options: {
  52475. shape: Vector3[];
  52476. holes?: Vector3[][];
  52477. depth?: number;
  52478. faceUV?: Vector4[];
  52479. faceColors?: Color4[];
  52480. updatable?: boolean;
  52481. sideOrientation?: number;
  52482. frontUVs?: Vector4;
  52483. backUVs?: Vector4;
  52484. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52485. /**
  52486. * Creates an extruded polygon mesh, with depth in the Y direction.
  52487. * * 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)
  52488. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52489. * @param name defines the name of the mesh
  52490. * @param options defines the options used to create the mesh
  52491. * @param scene defines the hosting scene
  52492. * @param earcutInjection can be used to inject your own earcut reference
  52493. * @returns the polygon mesh
  52494. */
  52495. static ExtrudePolygon(name: string, options: {
  52496. shape: Vector3[];
  52497. holes?: Vector3[][];
  52498. depth?: number;
  52499. faceUV?: Vector4[];
  52500. faceColors?: Color4[];
  52501. updatable?: boolean;
  52502. sideOrientation?: number;
  52503. frontUVs?: Vector4;
  52504. backUVs?: Vector4;
  52505. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52506. }
  52507. }
  52508. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  52509. import { Scene } from "babylonjs/scene";
  52510. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52511. import { Mesh } from "babylonjs/Meshes/mesh";
  52512. import { Nullable } from "babylonjs/types";
  52513. /**
  52514. * Class containing static functions to help procedurally build meshes
  52515. */
  52516. export class LatheBuilder {
  52517. /**
  52518. * Creates lathe mesh.
  52519. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52520. * * 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
  52521. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52522. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52523. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52524. * * 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
  52525. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52526. * * 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
  52527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52528. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52529. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52531. * @param name defines the name of the mesh
  52532. * @param options defines the options used to create the mesh
  52533. * @param scene defines the hosting scene
  52534. * @returns the lathe mesh
  52535. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52536. */
  52537. static CreateLathe(name: string, options: {
  52538. shape: Vector3[];
  52539. radius?: number;
  52540. tessellation?: number;
  52541. clip?: number;
  52542. arc?: number;
  52543. closed?: boolean;
  52544. updatable?: boolean;
  52545. sideOrientation?: number;
  52546. frontUVs?: Vector4;
  52547. backUVs?: Vector4;
  52548. cap?: number;
  52549. invertUV?: boolean;
  52550. }, scene?: Nullable<Scene>): Mesh;
  52551. }
  52552. }
  52553. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  52554. import { Nullable } from "babylonjs/types";
  52555. import { Scene } from "babylonjs/scene";
  52556. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52557. import { Mesh } from "babylonjs/Meshes/mesh";
  52558. /**
  52559. * Class containing static functions to help procedurally build meshes
  52560. */
  52561. export class TubeBuilder {
  52562. /**
  52563. * Creates a tube mesh.
  52564. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52565. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52566. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52567. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52568. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52569. * * 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)
  52570. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52571. * * 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
  52572. * * 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
  52573. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52574. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52575. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52577. * @param name defines the name of the mesh
  52578. * @param options defines the options used to create the mesh
  52579. * @param scene defines the hosting scene
  52580. * @returns the tube mesh
  52581. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52582. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52583. */
  52584. static CreateTube(name: string, options: {
  52585. path: Vector3[];
  52586. radius?: number;
  52587. tessellation?: number;
  52588. radiusFunction?: {
  52589. (i: number, distance: number): number;
  52590. };
  52591. cap?: number;
  52592. arc?: number;
  52593. updatable?: boolean;
  52594. sideOrientation?: number;
  52595. frontUVs?: Vector4;
  52596. backUVs?: Vector4;
  52597. instance?: Mesh;
  52598. invertUV?: boolean;
  52599. }, scene?: Nullable<Scene>): Mesh;
  52600. }
  52601. }
  52602. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  52603. import { Scene } from "babylonjs/scene";
  52604. import { Vector4 } from "babylonjs/Maths/math";
  52605. import { Mesh } from "babylonjs/Meshes/mesh";
  52606. import { Nullable } from "babylonjs/types";
  52607. /**
  52608. * Class containing static functions to help procedurally build meshes
  52609. */
  52610. export class IcoSphereBuilder {
  52611. /**
  52612. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52613. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52614. * * 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`)
  52615. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52616. * * 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
  52617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52618. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52620. * @param name defines the name of the mesh
  52621. * @param options defines the options used to create the mesh
  52622. * @param scene defines the hosting scene
  52623. * @returns the icosahedron mesh
  52624. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52625. */
  52626. static CreateIcoSphere(name: string, options: {
  52627. radius?: number;
  52628. radiusX?: number;
  52629. radiusY?: number;
  52630. radiusZ?: number;
  52631. flat?: boolean;
  52632. subdivisions?: number;
  52633. sideOrientation?: number;
  52634. frontUVs?: Vector4;
  52635. backUVs?: Vector4;
  52636. updatable?: boolean;
  52637. }, scene?: Nullable<Scene>): Mesh;
  52638. }
  52639. }
  52640. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52641. import { Vector3 } from "babylonjs/Maths/math";
  52642. import { Mesh } from "babylonjs/Meshes/mesh";
  52643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52644. /**
  52645. * Class containing static functions to help procedurally build meshes
  52646. */
  52647. export class DecalBuilder {
  52648. /**
  52649. * Creates a decal mesh.
  52650. * 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
  52651. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52652. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52653. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52654. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52655. * @param name defines the name of the mesh
  52656. * @param sourceMesh defines the mesh where the decal must be applied
  52657. * @param options defines the options used to create the mesh
  52658. * @param scene defines the hosting scene
  52659. * @returns the decal mesh
  52660. * @see https://doc.babylonjs.com/how_to/decals
  52661. */
  52662. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52663. position?: Vector3;
  52664. normal?: Vector3;
  52665. size?: Vector3;
  52666. angle?: number;
  52667. }): Mesh;
  52668. }
  52669. }
  52670. declare module "babylonjs/Meshes/meshBuilder" {
  52671. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52672. import { Nullable } from "babylonjs/types";
  52673. import { Scene } from "babylonjs/scene";
  52674. import { Mesh } from "babylonjs/Meshes/mesh";
  52675. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52676. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52678. /**
  52679. * Class containing static functions to help procedurally build meshes
  52680. */
  52681. export class MeshBuilder {
  52682. /**
  52683. * Creates a box mesh
  52684. * * The parameter `size` sets the size (float) of each box side (default 1)
  52685. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52686. * * 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)
  52687. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52691. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52692. * @param name defines the name of the mesh
  52693. * @param options defines the options used to create the mesh
  52694. * @param scene defines the hosting scene
  52695. * @returns the box mesh
  52696. */
  52697. static CreateBox(name: string, options: {
  52698. size?: number;
  52699. width?: number;
  52700. height?: number;
  52701. depth?: number;
  52702. faceUV?: Vector4[];
  52703. faceColors?: Color4[];
  52704. sideOrientation?: number;
  52705. frontUVs?: Vector4;
  52706. backUVs?: Vector4;
  52707. updatable?: boolean;
  52708. }, scene?: Nullable<Scene>): Mesh;
  52709. /**
  52710. * Creates a sphere mesh
  52711. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52712. * * 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`)
  52713. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52714. * * 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
  52715. * * 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)
  52716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52719. * @param name defines the name of the mesh
  52720. * @param options defines the options used to create the mesh
  52721. * @param scene defines the hosting scene
  52722. * @returns the sphere mesh
  52723. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52724. */
  52725. static CreateSphere(name: string, options: {
  52726. segments?: number;
  52727. diameter?: number;
  52728. diameterX?: number;
  52729. diameterY?: number;
  52730. diameterZ?: number;
  52731. arc?: number;
  52732. slice?: number;
  52733. sideOrientation?: number;
  52734. frontUVs?: Vector4;
  52735. backUVs?: Vector4;
  52736. updatable?: boolean;
  52737. }, scene?: Nullable<Scene>): Mesh;
  52738. /**
  52739. * Creates a plane polygonal mesh. By default, this is a disc
  52740. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52741. * * 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
  52742. * * 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
  52743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52746. * @param name defines the name of the mesh
  52747. * @param options defines the options used to create the mesh
  52748. * @param scene defines the hosting scene
  52749. * @returns the plane polygonal mesh
  52750. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52751. */
  52752. static CreateDisc(name: string, options: {
  52753. radius?: number;
  52754. tessellation?: number;
  52755. arc?: number;
  52756. updatable?: boolean;
  52757. sideOrientation?: number;
  52758. frontUVs?: Vector4;
  52759. backUVs?: Vector4;
  52760. }, scene?: Nullable<Scene>): Mesh;
  52761. /**
  52762. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52763. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52764. * * 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`)
  52765. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52766. * * 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
  52767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52768. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52770. * @param name defines the name of the mesh
  52771. * @param options defines the options used to create the mesh
  52772. * @param scene defines the hosting scene
  52773. * @returns the icosahedron mesh
  52774. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52775. */
  52776. static CreateIcoSphere(name: string, options: {
  52777. radius?: number;
  52778. radiusX?: number;
  52779. radiusY?: number;
  52780. radiusZ?: number;
  52781. flat?: boolean;
  52782. subdivisions?: number;
  52783. sideOrientation?: number;
  52784. frontUVs?: Vector4;
  52785. backUVs?: Vector4;
  52786. updatable?: boolean;
  52787. }, scene?: Nullable<Scene>): Mesh;
  52788. /**
  52789. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52790. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52791. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52792. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52793. * * 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
  52794. * * 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
  52795. * * 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
  52796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52797. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52798. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52799. * * 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
  52800. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52801. * * 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
  52802. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52804. * @param name defines the name of the mesh
  52805. * @param options defines the options used to create the mesh
  52806. * @param scene defines the hosting scene
  52807. * @returns the ribbon mesh
  52808. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52809. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52810. */
  52811. static CreateRibbon(name: string, options: {
  52812. pathArray: Vector3[][];
  52813. closeArray?: boolean;
  52814. closePath?: boolean;
  52815. offset?: number;
  52816. updatable?: boolean;
  52817. sideOrientation?: number;
  52818. frontUVs?: Vector4;
  52819. backUVs?: Vector4;
  52820. instance?: Mesh;
  52821. invertUV?: boolean;
  52822. uvs?: Vector2[];
  52823. colors?: Color4[];
  52824. }, scene?: Nullable<Scene>): Mesh;
  52825. /**
  52826. * Creates a cylinder or a cone mesh
  52827. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52828. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52829. * * 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.
  52830. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52831. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52832. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52833. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52834. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52835. * * 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).
  52836. * * 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
  52837. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52838. * * 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
  52839. * * 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.
  52840. * * If `enclose` is false, a ring surface is one element.
  52841. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52842. * * 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
  52843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52846. * @param name defines the name of the mesh
  52847. * @param options defines the options used to create the mesh
  52848. * @param scene defines the hosting scene
  52849. * @returns the cylinder mesh
  52850. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52851. */
  52852. static CreateCylinder(name: string, options: {
  52853. height?: number;
  52854. diameterTop?: number;
  52855. diameterBottom?: number;
  52856. diameter?: number;
  52857. tessellation?: number;
  52858. subdivisions?: number;
  52859. arc?: number;
  52860. faceColors?: Color4[];
  52861. faceUV?: Vector4[];
  52862. updatable?: boolean;
  52863. hasRings?: boolean;
  52864. enclose?: boolean;
  52865. sideOrientation?: number;
  52866. frontUVs?: Vector4;
  52867. backUVs?: Vector4;
  52868. }, scene?: Nullable<Scene>): Mesh;
  52869. /**
  52870. * Creates a torus mesh
  52871. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52872. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52873. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52877. * @param name defines the name of the mesh
  52878. * @param options defines the options used to create the mesh
  52879. * @param scene defines the hosting scene
  52880. * @returns the torus mesh
  52881. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52882. */
  52883. static CreateTorus(name: string, options: {
  52884. diameter?: number;
  52885. thickness?: number;
  52886. tessellation?: number;
  52887. updatable?: boolean;
  52888. sideOrientation?: number;
  52889. frontUVs?: Vector4;
  52890. backUVs?: Vector4;
  52891. }, scene?: Nullable<Scene>): Mesh;
  52892. /**
  52893. * Creates a torus knot mesh
  52894. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52895. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52896. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52897. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52899. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52901. * @param name defines the name of the mesh
  52902. * @param options defines the options used to create the mesh
  52903. * @param scene defines the hosting scene
  52904. * @returns the torus knot mesh
  52905. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52906. */
  52907. static CreateTorusKnot(name: string, options: {
  52908. radius?: number;
  52909. tube?: number;
  52910. radialSegments?: number;
  52911. tubularSegments?: number;
  52912. p?: number;
  52913. q?: number;
  52914. updatable?: boolean;
  52915. sideOrientation?: number;
  52916. frontUVs?: Vector4;
  52917. backUVs?: Vector4;
  52918. }, scene?: Nullable<Scene>): Mesh;
  52919. /**
  52920. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52921. * * 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
  52922. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52923. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52924. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52925. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52926. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52927. * * 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
  52928. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52930. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52931. * @param name defines the name of the new line system
  52932. * @param options defines the options used to create the line system
  52933. * @param scene defines the hosting scene
  52934. * @returns a new line system mesh
  52935. */
  52936. static CreateLineSystem(name: string, options: {
  52937. lines: Vector3[][];
  52938. updatable?: boolean;
  52939. instance?: Nullable<LinesMesh>;
  52940. colors?: Nullable<Color4[][]>;
  52941. useVertexAlpha?: boolean;
  52942. }, scene: Nullable<Scene>): LinesMesh;
  52943. /**
  52944. * Creates a line mesh
  52945. * 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
  52946. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52947. * * The parameter `points` is an array successive Vector3
  52948. * * 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
  52949. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52950. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52951. * * When updating an instance, remember that only point positions can change, not the number of points
  52952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52953. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52954. * @param name defines the name of the new line system
  52955. * @param options defines the options used to create the line system
  52956. * @param scene defines the hosting scene
  52957. * @returns a new line mesh
  52958. */
  52959. static CreateLines(name: string, options: {
  52960. points: Vector3[];
  52961. updatable?: boolean;
  52962. instance?: Nullable<LinesMesh>;
  52963. colors?: Color4[];
  52964. useVertexAlpha?: boolean;
  52965. }, scene?: Nullable<Scene>): LinesMesh;
  52966. /**
  52967. * Creates a dashed line mesh
  52968. * * 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
  52969. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52970. * * The parameter `points` is an array successive Vector3
  52971. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52972. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52973. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52974. * * 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
  52975. * * When updating an instance, remember that only point positions can change, not the number of points
  52976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52977. * @param name defines the name of the mesh
  52978. * @param options defines the options used to create the mesh
  52979. * @param scene defines the hosting scene
  52980. * @returns the dashed line mesh
  52981. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52982. */
  52983. static CreateDashedLines(name: string, options: {
  52984. points: Vector3[];
  52985. dashSize?: number;
  52986. gapSize?: number;
  52987. dashNb?: number;
  52988. updatable?: boolean;
  52989. instance?: LinesMesh;
  52990. }, scene?: Nullable<Scene>): LinesMesh;
  52991. /**
  52992. * 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.
  52993. * * 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.
  52994. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52995. * * 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.
  52996. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52997. * * 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
  52998. * * 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
  52999. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53001. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53002. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53004. * @param name defines the name of the mesh
  53005. * @param options defines the options used to create the mesh
  53006. * @param scene defines the hosting scene
  53007. * @returns the extruded shape mesh
  53008. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53009. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53010. */
  53011. static ExtrudeShape(name: string, options: {
  53012. shape: Vector3[];
  53013. path: Vector3[];
  53014. scale?: number;
  53015. rotation?: number;
  53016. cap?: number;
  53017. updatable?: boolean;
  53018. sideOrientation?: number;
  53019. frontUVs?: Vector4;
  53020. backUVs?: Vector4;
  53021. instance?: Mesh;
  53022. invertUV?: boolean;
  53023. }, scene?: Nullable<Scene>): Mesh;
  53024. /**
  53025. * Creates an custom extruded shape mesh.
  53026. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53027. * * 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.
  53028. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53029. * * 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
  53030. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53031. * * 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
  53032. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53033. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53034. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53035. * * 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
  53036. * * 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
  53037. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53039. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53040. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53042. * @param name defines the name of the mesh
  53043. * @param options defines the options used to create the mesh
  53044. * @param scene defines the hosting scene
  53045. * @returns the custom extruded shape mesh
  53046. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53047. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53048. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53049. */
  53050. static ExtrudeShapeCustom(name: string, options: {
  53051. shape: Vector3[];
  53052. path: Vector3[];
  53053. scaleFunction?: any;
  53054. rotationFunction?: any;
  53055. ribbonCloseArray?: boolean;
  53056. ribbonClosePath?: boolean;
  53057. cap?: number;
  53058. updatable?: boolean;
  53059. sideOrientation?: number;
  53060. frontUVs?: Vector4;
  53061. backUVs?: Vector4;
  53062. instance?: Mesh;
  53063. invertUV?: boolean;
  53064. }, scene?: Nullable<Scene>): Mesh;
  53065. /**
  53066. * Creates lathe mesh.
  53067. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53068. * * 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
  53069. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53070. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53071. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53072. * * 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
  53073. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53074. * * 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
  53075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53077. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53079. * @param name defines the name of the mesh
  53080. * @param options defines the options used to create the mesh
  53081. * @param scene defines the hosting scene
  53082. * @returns the lathe mesh
  53083. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53084. */
  53085. static CreateLathe(name: string, options: {
  53086. shape: Vector3[];
  53087. radius?: number;
  53088. tessellation?: number;
  53089. clip?: number;
  53090. arc?: number;
  53091. closed?: boolean;
  53092. updatable?: boolean;
  53093. sideOrientation?: number;
  53094. frontUVs?: Vector4;
  53095. backUVs?: Vector4;
  53096. cap?: number;
  53097. invertUV?: boolean;
  53098. }, scene?: Nullable<Scene>): Mesh;
  53099. /**
  53100. * Creates a plane mesh
  53101. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53102. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53103. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53105. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53107. * @param name defines the name of the mesh
  53108. * @param options defines the options used to create the mesh
  53109. * @param scene defines the hosting scene
  53110. * @returns the plane mesh
  53111. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53112. */
  53113. static CreatePlane(name: string, options: {
  53114. size?: number;
  53115. width?: number;
  53116. height?: number;
  53117. sideOrientation?: number;
  53118. frontUVs?: Vector4;
  53119. backUVs?: Vector4;
  53120. updatable?: boolean;
  53121. sourcePlane?: Plane;
  53122. }, scene?: Nullable<Scene>): Mesh;
  53123. /**
  53124. * Creates a ground mesh
  53125. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53126. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53128. * @param name defines the name of the mesh
  53129. * @param options defines the options used to create the mesh
  53130. * @param scene defines the hosting scene
  53131. * @returns the ground mesh
  53132. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53133. */
  53134. static CreateGround(name: string, options: {
  53135. width?: number;
  53136. height?: number;
  53137. subdivisions?: number;
  53138. subdivisionsX?: number;
  53139. subdivisionsY?: number;
  53140. updatable?: boolean;
  53141. }, scene?: Nullable<Scene>): Mesh;
  53142. /**
  53143. * Creates a tiled ground mesh
  53144. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53145. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53146. * * 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
  53147. * * 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
  53148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53149. * @param name defines the name of the mesh
  53150. * @param options defines the options used to create the mesh
  53151. * @param scene defines the hosting scene
  53152. * @returns the tiled ground mesh
  53153. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53154. */
  53155. static CreateTiledGround(name: string, options: {
  53156. xmin: number;
  53157. zmin: number;
  53158. xmax: number;
  53159. zmax: number;
  53160. subdivisions?: {
  53161. w: number;
  53162. h: number;
  53163. };
  53164. precision?: {
  53165. w: number;
  53166. h: number;
  53167. };
  53168. updatable?: boolean;
  53169. }, scene?: Nullable<Scene>): Mesh;
  53170. /**
  53171. * Creates a ground mesh from a height map
  53172. * * The parameter `url` sets the URL of the height map image resource.
  53173. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53174. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53175. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53176. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53177. * * 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.
  53178. * * 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).
  53179. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53181. * @param name defines the name of the mesh
  53182. * @param url defines the url to the height map
  53183. * @param options defines the options used to create the mesh
  53184. * @param scene defines the hosting scene
  53185. * @returns the ground mesh
  53186. * @see https://doc.babylonjs.com/babylon101/height_map
  53187. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53188. */
  53189. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53190. width?: number;
  53191. height?: number;
  53192. subdivisions?: number;
  53193. minHeight?: number;
  53194. maxHeight?: number;
  53195. colorFilter?: Color3;
  53196. alphaFilter?: number;
  53197. updatable?: boolean;
  53198. onReady?: (mesh: GroundMesh) => void;
  53199. }, scene?: Nullable<Scene>): GroundMesh;
  53200. /**
  53201. * Creates a polygon mesh
  53202. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53203. * * 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
  53204. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  53207. * * Remember you can only change the shape positions, not their number when updating a polygon
  53208. * @param name defines the name of the mesh
  53209. * @param options defines the options used to create the mesh
  53210. * @param scene defines the hosting scene
  53211. * @param earcutInjection can be used to inject your own earcut reference
  53212. * @returns the polygon mesh
  53213. */
  53214. static CreatePolygon(name: string, options: {
  53215. shape: Vector3[];
  53216. holes?: Vector3[][];
  53217. depth?: number;
  53218. faceUV?: Vector4[];
  53219. faceColors?: Color4[];
  53220. updatable?: boolean;
  53221. sideOrientation?: number;
  53222. frontUVs?: Vector4;
  53223. backUVs?: Vector4;
  53224. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53225. /**
  53226. * Creates an extruded polygon mesh, with depth in the Y direction.
  53227. * * 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)
  53228. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53229. * @param name defines the name of the mesh
  53230. * @param options defines the options used to create the mesh
  53231. * @param scene defines the hosting scene
  53232. * @param earcutInjection can be used to inject your own earcut reference
  53233. * @returns the polygon mesh
  53234. */
  53235. static ExtrudePolygon(name: string, options: {
  53236. shape: Vector3[];
  53237. holes?: Vector3[][];
  53238. depth?: number;
  53239. faceUV?: Vector4[];
  53240. faceColors?: Color4[];
  53241. updatable?: boolean;
  53242. sideOrientation?: number;
  53243. frontUVs?: Vector4;
  53244. backUVs?: Vector4;
  53245. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53246. /**
  53247. * Creates a tube mesh.
  53248. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53249. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53250. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53251. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53252. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53253. * * 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)
  53254. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53255. * * 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
  53256. * * 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
  53257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53259. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53261. * @param name defines the name of the mesh
  53262. * @param options defines the options used to create the mesh
  53263. * @param scene defines the hosting scene
  53264. * @returns the tube mesh
  53265. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53266. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53267. */
  53268. static CreateTube(name: string, options: {
  53269. path: Vector3[];
  53270. radius?: number;
  53271. tessellation?: number;
  53272. radiusFunction?: {
  53273. (i: number, distance: number): number;
  53274. };
  53275. cap?: number;
  53276. arc?: number;
  53277. updatable?: boolean;
  53278. sideOrientation?: number;
  53279. frontUVs?: Vector4;
  53280. backUVs?: Vector4;
  53281. instance?: Mesh;
  53282. invertUV?: boolean;
  53283. }, scene?: Nullable<Scene>): Mesh;
  53284. /**
  53285. * Creates a polyhedron mesh
  53286. * * 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
  53287. * * The parameter `size` (positive float, default 1) sets the polygon size
  53288. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53289. * * 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`
  53290. * * 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
  53291. * * 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)`)
  53292. * * 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
  53293. * * 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
  53294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53295. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53297. * @param name defines the name of the mesh
  53298. * @param options defines the options used to create the mesh
  53299. * @param scene defines the hosting scene
  53300. * @returns the polyhedron mesh
  53301. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53302. */
  53303. static CreatePolyhedron(name: string, options: {
  53304. type?: number;
  53305. size?: number;
  53306. sizeX?: number;
  53307. sizeY?: number;
  53308. sizeZ?: number;
  53309. custom?: any;
  53310. faceUV?: Vector4[];
  53311. faceColors?: Color4[];
  53312. flat?: boolean;
  53313. updatable?: boolean;
  53314. sideOrientation?: number;
  53315. frontUVs?: Vector4;
  53316. backUVs?: Vector4;
  53317. }, scene?: Nullable<Scene>): Mesh;
  53318. /**
  53319. * Creates a decal mesh.
  53320. * 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
  53321. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53322. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53323. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53324. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53325. * @param name defines the name of the mesh
  53326. * @param sourceMesh defines the mesh where the decal must be applied
  53327. * @param options defines the options used to create the mesh
  53328. * @param scene defines the hosting scene
  53329. * @returns the decal mesh
  53330. * @see https://doc.babylonjs.com/how_to/decals
  53331. */
  53332. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53333. position?: Vector3;
  53334. normal?: Vector3;
  53335. size?: Vector3;
  53336. angle?: number;
  53337. }): Mesh;
  53338. }
  53339. }
  53340. declare module "babylonjs/Meshes/meshSimplification" {
  53341. import { Mesh } from "babylonjs/Meshes/mesh";
  53342. /**
  53343. * A simplifier interface for future simplification implementations
  53344. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53345. */
  53346. export interface ISimplifier {
  53347. /**
  53348. * Simplification of a given mesh according to the given settings.
  53349. * Since this requires computation, it is assumed that the function runs async.
  53350. * @param settings The settings of the simplification, including quality and distance
  53351. * @param successCallback A callback that will be called after the mesh was simplified.
  53352. * @param errorCallback in case of an error, this callback will be called. optional.
  53353. */
  53354. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53355. }
  53356. /**
  53357. * Expected simplification settings.
  53358. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53359. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53360. */
  53361. export interface ISimplificationSettings {
  53362. /**
  53363. * Gets or sets the expected quality
  53364. */
  53365. quality: number;
  53366. /**
  53367. * Gets or sets the distance when this optimized version should be used
  53368. */
  53369. distance: number;
  53370. /**
  53371. * Gets an already optimized mesh
  53372. */
  53373. optimizeMesh?: boolean;
  53374. }
  53375. /**
  53376. * Class used to specify simplification options
  53377. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53378. */
  53379. export class SimplificationSettings implements ISimplificationSettings {
  53380. /** expected quality */
  53381. quality: number;
  53382. /** distance when this optimized version should be used */
  53383. distance: number;
  53384. /** already optimized mesh */
  53385. optimizeMesh?: boolean | undefined;
  53386. /**
  53387. * Creates a SimplificationSettings
  53388. * @param quality expected quality
  53389. * @param distance distance when this optimized version should be used
  53390. * @param optimizeMesh already optimized mesh
  53391. */
  53392. constructor(
  53393. /** expected quality */
  53394. quality: number,
  53395. /** distance when this optimized version should be used */
  53396. distance: number,
  53397. /** already optimized mesh */
  53398. optimizeMesh?: boolean | undefined);
  53399. }
  53400. /**
  53401. * Interface used to define a simplification task
  53402. */
  53403. export interface ISimplificationTask {
  53404. /**
  53405. * Array of settings
  53406. */
  53407. settings: Array<ISimplificationSettings>;
  53408. /**
  53409. * Simplification type
  53410. */
  53411. simplificationType: SimplificationType;
  53412. /**
  53413. * Mesh to simplify
  53414. */
  53415. mesh: Mesh;
  53416. /**
  53417. * Callback called on success
  53418. */
  53419. successCallback?: () => void;
  53420. /**
  53421. * Defines if parallel processing can be used
  53422. */
  53423. parallelProcessing: boolean;
  53424. }
  53425. /**
  53426. * Queue used to order the simplification tasks
  53427. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53428. */
  53429. export class SimplificationQueue {
  53430. private _simplificationArray;
  53431. /**
  53432. * Gets a boolean indicating that the process is still running
  53433. */
  53434. running: boolean;
  53435. /**
  53436. * Creates a new queue
  53437. */
  53438. constructor();
  53439. /**
  53440. * Adds a new simplification task
  53441. * @param task defines a task to add
  53442. */
  53443. addTask(task: ISimplificationTask): void;
  53444. /**
  53445. * Execute next task
  53446. */
  53447. executeNext(): void;
  53448. /**
  53449. * Execute a simplification task
  53450. * @param task defines the task to run
  53451. */
  53452. runSimplification(task: ISimplificationTask): void;
  53453. private getSimplifier;
  53454. }
  53455. /**
  53456. * The implemented types of simplification
  53457. * At the moment only Quadratic Error Decimation is implemented
  53458. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53459. */
  53460. export enum SimplificationType {
  53461. /** Quadratic error decimation */
  53462. QUADRATIC = 0
  53463. }
  53464. }
  53465. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  53466. import { Scene } from "babylonjs/scene";
  53467. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  53468. import { ISceneComponent } from "babylonjs/sceneComponent";
  53469. module "babylonjs/scene" {
  53470. interface Scene {
  53471. /** @hidden (Backing field) */
  53472. _simplificationQueue: SimplificationQueue;
  53473. /**
  53474. * Gets or sets the simplification queue attached to the scene
  53475. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53476. */
  53477. simplificationQueue: SimplificationQueue;
  53478. }
  53479. }
  53480. module "babylonjs/Meshes/mesh" {
  53481. interface Mesh {
  53482. /**
  53483. * Simplify the mesh according to the given array of settings.
  53484. * Function will return immediately and will simplify async
  53485. * @param settings a collection of simplification settings
  53486. * @param parallelProcessing should all levels calculate parallel or one after the other
  53487. * @param simplificationType the type of simplification to run
  53488. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53489. * @returns the current mesh
  53490. */
  53491. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53492. }
  53493. }
  53494. /**
  53495. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53496. * created in a scene
  53497. */
  53498. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53499. /**
  53500. * The component name helpfull to identify the component in the list of scene components.
  53501. */
  53502. readonly name: string;
  53503. /**
  53504. * The scene the component belongs to.
  53505. */
  53506. scene: Scene;
  53507. /**
  53508. * Creates a new instance of the component for the given scene
  53509. * @param scene Defines the scene to register the component in
  53510. */
  53511. constructor(scene: Scene);
  53512. /**
  53513. * Registers the component in a given scene
  53514. */
  53515. register(): void;
  53516. /**
  53517. * Rebuilds the elements related to this component in case of
  53518. * context lost for instance.
  53519. */
  53520. rebuild(): void;
  53521. /**
  53522. * Disposes the component and the associated ressources
  53523. */
  53524. dispose(): void;
  53525. private _beforeCameraUpdate;
  53526. }
  53527. }
  53528. declare module "babylonjs/Meshes/Builders/index" {
  53529. export * from "babylonjs/Meshes/Builders/boxBuilder";
  53530. export * from "babylonjs/Meshes/Builders/discBuilder";
  53531. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  53532. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  53533. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  53534. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  53535. export * from "babylonjs/Meshes/Builders/torusBuilder";
  53536. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  53537. export * from "babylonjs/Meshes/Builders/linesBuilder";
  53538. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  53539. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  53540. export * from "babylonjs/Meshes/Builders/latheBuilder";
  53541. export * from "babylonjs/Meshes/Builders/planeBuilder";
  53542. export * from "babylonjs/Meshes/Builders/groundBuilder";
  53543. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  53544. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  53545. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  53546. export * from "babylonjs/Meshes/Builders/decalBuilder";
  53547. }
  53548. declare module "babylonjs/Meshes/index" {
  53549. export * from "babylonjs/Meshes/abstractMesh";
  53550. export * from "babylonjs/Meshes/buffer";
  53551. export * from "babylonjs/Meshes/Compression/index";
  53552. export * from "babylonjs/Meshes/csg";
  53553. export * from "babylonjs/Meshes/geometry";
  53554. export * from "babylonjs/Meshes/groundMesh";
  53555. export * from "babylonjs/Meshes/trailMesh";
  53556. export * from "babylonjs/Meshes/instancedMesh";
  53557. export * from "babylonjs/Meshes/linesMesh";
  53558. export * from "babylonjs/Meshes/mesh";
  53559. export * from "babylonjs/Meshes/mesh.vertexData";
  53560. export * from "babylonjs/Meshes/meshBuilder";
  53561. export * from "babylonjs/Meshes/meshSimplification";
  53562. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  53563. export * from "babylonjs/Meshes/polygonMesh";
  53564. export * from "babylonjs/Meshes/subMesh";
  53565. export * from "babylonjs/Meshes/meshLODLevel";
  53566. export * from "babylonjs/Meshes/transformNode";
  53567. export * from "babylonjs/Meshes/Builders/index";
  53568. export * from "babylonjs/Meshes/dataBuffer";
  53569. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  53570. }
  53571. declare module "babylonjs/Morph/index" {
  53572. export * from "babylonjs/Morph/morphTarget";
  53573. export * from "babylonjs/Morph/morphTargetManager";
  53574. }
  53575. declare module "babylonjs/Offline/database" {
  53576. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  53577. /**
  53578. * Class used to enable access to IndexedDB
  53579. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53580. */
  53581. export class Database implements IOfflineProvider {
  53582. private _callbackManifestChecked;
  53583. private _currentSceneUrl;
  53584. private _db;
  53585. private _enableSceneOffline;
  53586. private _enableTexturesOffline;
  53587. private _manifestVersionFound;
  53588. private _mustUpdateRessources;
  53589. private _hasReachedQuota;
  53590. private _isSupported;
  53591. private _idbFactory;
  53592. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53593. private static IsUASupportingBlobStorage;
  53594. /**
  53595. * Gets a boolean indicating if Database storate is enabled (off by default)
  53596. */
  53597. static IDBStorageEnabled: boolean;
  53598. /**
  53599. * Gets a boolean indicating if scene must be saved in the database
  53600. */
  53601. readonly enableSceneOffline: boolean;
  53602. /**
  53603. * Gets a boolean indicating if textures must be saved in the database
  53604. */
  53605. readonly enableTexturesOffline: boolean;
  53606. /**
  53607. * Creates a new Database
  53608. * @param urlToScene defines the url to load the scene
  53609. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53610. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53611. */
  53612. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53613. private static _ParseURL;
  53614. private static _ReturnFullUrlLocation;
  53615. private _checkManifestFile;
  53616. /**
  53617. * Open the database and make it available
  53618. * @param successCallback defines the callback to call on success
  53619. * @param errorCallback defines the callback to call on error
  53620. */
  53621. open(successCallback: () => void, errorCallback: () => void): void;
  53622. /**
  53623. * Loads an image from the database
  53624. * @param url defines the url to load from
  53625. * @param image defines the target DOM image
  53626. */
  53627. loadImage(url: string, image: HTMLImageElement): void;
  53628. private _loadImageFromDBAsync;
  53629. private _saveImageIntoDBAsync;
  53630. private _checkVersionFromDB;
  53631. private _loadVersionFromDBAsync;
  53632. private _saveVersionIntoDBAsync;
  53633. /**
  53634. * Loads a file from database
  53635. * @param url defines the URL to load from
  53636. * @param sceneLoaded defines a callback to call on success
  53637. * @param progressCallBack defines a callback to call when progress changed
  53638. * @param errorCallback defines a callback to call on error
  53639. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53640. */
  53641. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53642. private _loadFileAsync;
  53643. private _saveFileAsync;
  53644. /**
  53645. * Validates if xhr data is correct
  53646. * @param xhr defines the request to validate
  53647. * @param dataType defines the expected data type
  53648. * @returns true if data is correct
  53649. */
  53650. private static _ValidateXHRData;
  53651. }
  53652. }
  53653. declare module "babylonjs/Offline/index" {
  53654. export * from "babylonjs/Offline/database";
  53655. export * from "babylonjs/Offline/IOfflineProvider";
  53656. }
  53657. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53658. /** @hidden */
  53659. export var gpuUpdateParticlesPixelShader: {
  53660. name: string;
  53661. shader: string;
  53662. };
  53663. }
  53664. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53665. /** @hidden */
  53666. export var gpuUpdateParticlesVertexShader: {
  53667. name: string;
  53668. shader: string;
  53669. };
  53670. }
  53671. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53672. /** @hidden */
  53673. export var clipPlaneFragmentDeclaration2: {
  53674. name: string;
  53675. shader: string;
  53676. };
  53677. }
  53678. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53679. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53680. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53681. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53682. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53683. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53684. /** @hidden */
  53685. export var gpuRenderParticlesPixelShader: {
  53686. name: string;
  53687. shader: string;
  53688. };
  53689. }
  53690. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53691. /** @hidden */
  53692. export var clipPlaneVertexDeclaration2: {
  53693. name: string;
  53694. shader: string;
  53695. };
  53696. }
  53697. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53698. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53699. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53700. /** @hidden */
  53701. export var gpuRenderParticlesVertexShader: {
  53702. name: string;
  53703. shader: string;
  53704. };
  53705. }
  53706. declare module "babylonjs/Particles/gpuParticleSystem" {
  53707. import { Nullable } from "babylonjs/types";
  53708. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53709. import { Observable } from "babylonjs/Misc/observable";
  53710. import { Color4, Color3 } from "babylonjs/Maths/math";
  53711. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53712. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53713. import { Scene, IDisposable } from "babylonjs/scene";
  53714. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53715. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53716. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53717. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53718. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53719. /**
  53720. * This represents a GPU particle system in Babylon
  53721. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53722. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53723. */
  53724. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53725. /**
  53726. * The layer mask we are rendering the particles through.
  53727. */
  53728. layerMask: number;
  53729. private _capacity;
  53730. private _activeCount;
  53731. private _currentActiveCount;
  53732. private _accumulatedCount;
  53733. private _renderEffect;
  53734. private _updateEffect;
  53735. private _buffer0;
  53736. private _buffer1;
  53737. private _spriteBuffer;
  53738. private _updateVAO;
  53739. private _renderVAO;
  53740. private _targetIndex;
  53741. private _sourceBuffer;
  53742. private _targetBuffer;
  53743. private _engine;
  53744. private _currentRenderId;
  53745. private _started;
  53746. private _stopped;
  53747. private _timeDelta;
  53748. private _randomTexture;
  53749. private _randomTexture2;
  53750. private _attributesStrideSize;
  53751. private _updateEffectOptions;
  53752. private _randomTextureSize;
  53753. private _actualFrame;
  53754. private readonly _rawTextureWidth;
  53755. /**
  53756. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53757. */
  53758. static readonly IsSupported: boolean;
  53759. /**
  53760. * An event triggered when the system is disposed.
  53761. */
  53762. onDisposeObservable: Observable<GPUParticleSystem>;
  53763. /**
  53764. * Gets the maximum number of particles active at the same time.
  53765. * @returns The max number of active particles.
  53766. */
  53767. getCapacity(): number;
  53768. /**
  53769. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53770. * to override the particles.
  53771. */
  53772. forceDepthWrite: boolean;
  53773. /**
  53774. * Gets or set the number of active particles
  53775. */
  53776. activeParticleCount: number;
  53777. private _preWarmDone;
  53778. /**
  53779. * Is this system ready to be used/rendered
  53780. * @return true if the system is ready
  53781. */
  53782. isReady(): boolean;
  53783. /**
  53784. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53785. * @returns True if it has been started, otherwise false.
  53786. */
  53787. isStarted(): boolean;
  53788. /**
  53789. * Starts the particle system and begins to emit
  53790. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53791. */
  53792. start(delay?: number): void;
  53793. /**
  53794. * Stops the particle system.
  53795. */
  53796. stop(): void;
  53797. /**
  53798. * Remove all active particles
  53799. */
  53800. reset(): void;
  53801. /**
  53802. * Returns the string "GPUParticleSystem"
  53803. * @returns a string containing the class name
  53804. */
  53805. getClassName(): string;
  53806. private _colorGradientsTexture;
  53807. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53808. /**
  53809. * Adds a new color gradient
  53810. * @param gradient defines the gradient to use (between 0 and 1)
  53811. * @param color1 defines the color to affect to the specified gradient
  53812. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53813. * @returns the current particle system
  53814. */
  53815. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53816. /**
  53817. * Remove a specific color gradient
  53818. * @param gradient defines the gradient to remove
  53819. * @returns the current particle system
  53820. */
  53821. removeColorGradient(gradient: number): GPUParticleSystem;
  53822. private _angularSpeedGradientsTexture;
  53823. private _sizeGradientsTexture;
  53824. private _velocityGradientsTexture;
  53825. private _limitVelocityGradientsTexture;
  53826. private _dragGradientsTexture;
  53827. private _addFactorGradient;
  53828. /**
  53829. * Adds a new size gradient
  53830. * @param gradient defines the gradient to use (between 0 and 1)
  53831. * @param factor defines the size factor to affect to the specified gradient
  53832. * @returns the current particle system
  53833. */
  53834. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53835. /**
  53836. * Remove a specific size gradient
  53837. * @param gradient defines the gradient to remove
  53838. * @returns the current particle system
  53839. */
  53840. removeSizeGradient(gradient: number): GPUParticleSystem;
  53841. /**
  53842. * Adds a new angular speed gradient
  53843. * @param gradient defines the gradient to use (between 0 and 1)
  53844. * @param factor defines the angular speed to affect to the specified gradient
  53845. * @returns the current particle system
  53846. */
  53847. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53848. /**
  53849. * Remove a specific angular speed gradient
  53850. * @param gradient defines the gradient to remove
  53851. * @returns the current particle system
  53852. */
  53853. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53854. /**
  53855. * Adds a new velocity gradient
  53856. * @param gradient defines the gradient to use (between 0 and 1)
  53857. * @param factor defines the velocity to affect to the specified gradient
  53858. * @returns the current particle system
  53859. */
  53860. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53861. /**
  53862. * Remove a specific velocity gradient
  53863. * @param gradient defines the gradient to remove
  53864. * @returns the current particle system
  53865. */
  53866. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53867. /**
  53868. * Adds a new limit velocity gradient
  53869. * @param gradient defines the gradient to use (between 0 and 1)
  53870. * @param factor defines the limit velocity value to affect to the specified gradient
  53871. * @returns the current particle system
  53872. */
  53873. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53874. /**
  53875. * Remove a specific limit velocity gradient
  53876. * @param gradient defines the gradient to remove
  53877. * @returns the current particle system
  53878. */
  53879. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53880. /**
  53881. * Adds a new drag gradient
  53882. * @param gradient defines the gradient to use (between 0 and 1)
  53883. * @param factor defines the drag value to affect to the specified gradient
  53884. * @returns the current particle system
  53885. */
  53886. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53887. /**
  53888. * Remove a specific drag gradient
  53889. * @param gradient defines the gradient to remove
  53890. * @returns the current particle system
  53891. */
  53892. removeDragGradient(gradient: number): GPUParticleSystem;
  53893. /**
  53894. * Not supported by GPUParticleSystem
  53895. * @param gradient defines the gradient to use (between 0 and 1)
  53896. * @param factor defines the emit rate value to affect to the specified gradient
  53897. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53898. * @returns the current particle system
  53899. */
  53900. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53901. /**
  53902. * Not supported by GPUParticleSystem
  53903. * @param gradient defines the gradient to remove
  53904. * @returns the current particle system
  53905. */
  53906. removeEmitRateGradient(gradient: number): IParticleSystem;
  53907. /**
  53908. * Not supported by GPUParticleSystem
  53909. * @param gradient defines the gradient to use (between 0 and 1)
  53910. * @param factor defines the start size value to affect to the specified gradient
  53911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53912. * @returns the current particle system
  53913. */
  53914. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53915. /**
  53916. * Not supported by GPUParticleSystem
  53917. * @param gradient defines the gradient to remove
  53918. * @returns the current particle system
  53919. */
  53920. removeStartSizeGradient(gradient: number): IParticleSystem;
  53921. /**
  53922. * Not supported by GPUParticleSystem
  53923. * @param gradient defines the gradient to use (between 0 and 1)
  53924. * @param min defines the color remap minimal range
  53925. * @param max defines the color remap maximal range
  53926. * @returns the current particle system
  53927. */
  53928. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53929. /**
  53930. * Not supported by GPUParticleSystem
  53931. * @param gradient defines the gradient to remove
  53932. * @returns the current particle system
  53933. */
  53934. removeColorRemapGradient(): IParticleSystem;
  53935. /**
  53936. * Not supported by GPUParticleSystem
  53937. * @param gradient defines the gradient to use (between 0 and 1)
  53938. * @param min defines the alpha remap minimal range
  53939. * @param max defines the alpha remap maximal range
  53940. * @returns the current particle system
  53941. */
  53942. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53943. /**
  53944. * Not supported by GPUParticleSystem
  53945. * @param gradient defines the gradient to remove
  53946. * @returns the current particle system
  53947. */
  53948. removeAlphaRemapGradient(): IParticleSystem;
  53949. /**
  53950. * Not supported by GPUParticleSystem
  53951. * @param gradient defines the gradient to use (between 0 and 1)
  53952. * @param color defines the color to affect to the specified gradient
  53953. * @returns the current particle system
  53954. */
  53955. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53956. /**
  53957. * Not supported by GPUParticleSystem
  53958. * @param gradient defines the gradient to remove
  53959. * @returns the current particle system
  53960. */
  53961. removeRampGradient(): IParticleSystem;
  53962. /**
  53963. * Not supported by GPUParticleSystem
  53964. * @returns the list of ramp gradients
  53965. */
  53966. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53967. /**
  53968. * Not supported by GPUParticleSystem
  53969. * Gets or sets a boolean indicating that ramp gradients must be used
  53970. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53971. */
  53972. useRampGradients: boolean;
  53973. /**
  53974. * Not supported by GPUParticleSystem
  53975. * @param gradient defines the gradient to use (between 0 and 1)
  53976. * @param factor defines the life time factor to affect to the specified gradient
  53977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53978. * @returns the current particle system
  53979. */
  53980. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53981. /**
  53982. * Not supported by GPUParticleSystem
  53983. * @param gradient defines the gradient to remove
  53984. * @returns the current particle system
  53985. */
  53986. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53987. /**
  53988. * Instantiates a GPU particle system.
  53989. * 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.
  53990. * @param name The name of the particle system
  53991. * @param options The options used to create the system
  53992. * @param scene The scene the particle system belongs to
  53993. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53994. */
  53995. constructor(name: string, options: Partial<{
  53996. capacity: number;
  53997. randomTextureSize: number;
  53998. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53999. protected _reset(): void;
  54000. private _createUpdateVAO;
  54001. private _createRenderVAO;
  54002. private _initialize;
  54003. /** @hidden */
  54004. _recreateUpdateEffect(): void;
  54005. /** @hidden */
  54006. _recreateRenderEffect(): void;
  54007. /**
  54008. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  54009. * @param preWarm defines if we are in the pre-warmimg phase
  54010. */
  54011. animate(preWarm?: boolean): void;
  54012. private _createFactorGradientTexture;
  54013. private _createSizeGradientTexture;
  54014. private _createAngularSpeedGradientTexture;
  54015. private _createVelocityGradientTexture;
  54016. private _createLimitVelocityGradientTexture;
  54017. private _createDragGradientTexture;
  54018. private _createColorGradientTexture;
  54019. /**
  54020. * Renders the particle system in its current state
  54021. * @param preWarm defines if the system should only update the particles but not render them
  54022. * @returns the current number of particles
  54023. */
  54024. render(preWarm?: boolean): number;
  54025. /**
  54026. * Rebuilds the particle system
  54027. */
  54028. rebuild(): void;
  54029. private _releaseBuffers;
  54030. private _releaseVAOs;
  54031. /**
  54032. * Disposes the particle system and free the associated resources
  54033. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  54034. */
  54035. dispose(disposeTexture?: boolean): void;
  54036. /**
  54037. * Clones the particle system.
  54038. * @param name The name of the cloned object
  54039. * @param newEmitter The new emitter to use
  54040. * @returns the cloned particle system
  54041. */
  54042. clone(name: string, newEmitter: any): GPUParticleSystem;
  54043. /**
  54044. * Serializes the particle system to a JSON object.
  54045. * @returns the JSON object
  54046. */
  54047. serialize(): any;
  54048. /**
  54049. * Parses a JSON object to create a GPU particle system.
  54050. * @param parsedParticleSystem The JSON object to parse
  54051. * @param scene The scene to create the particle system in
  54052. * @param rootUrl The root url to use to load external dependencies like texture
  54053. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  54054. * @returns the parsed GPU particle system
  54055. */
  54056. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  54057. }
  54058. }
  54059. declare module "babylonjs/Particles/particleSystemSet" {
  54060. import { Nullable } from "babylonjs/types";
  54061. import { Color3 } from "babylonjs/Maths/math";
  54062. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54064. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54065. import { Scene, IDisposable } from "babylonjs/scene";
  54066. /**
  54067. * Represents a set of particle systems working together to create a specific effect
  54068. */
  54069. export class ParticleSystemSet implements IDisposable {
  54070. private _emitterCreationOptions;
  54071. private _emitterNode;
  54072. /**
  54073. * Gets the particle system list
  54074. */
  54075. systems: IParticleSystem[];
  54076. /**
  54077. * Gets the emitter node used with this set
  54078. */
  54079. readonly emitterNode: Nullable<TransformNode>;
  54080. /**
  54081. * Creates a new emitter mesh as a sphere
  54082. * @param options defines the options used to create the sphere
  54083. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  54084. * @param scene defines the hosting scene
  54085. */
  54086. setEmitterAsSphere(options: {
  54087. diameter: number;
  54088. segments: number;
  54089. color: Color3;
  54090. }, renderingGroupId: number, scene: Scene): void;
  54091. /**
  54092. * Starts all particle systems of the set
  54093. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54094. */
  54095. start(emitter?: AbstractMesh): void;
  54096. /**
  54097. * Release all associated resources
  54098. */
  54099. dispose(): void;
  54100. /**
  54101. * Serialize the set into a JSON compatible object
  54102. * @returns a JSON compatible representation of the set
  54103. */
  54104. serialize(): any;
  54105. /**
  54106. * Parse a new ParticleSystemSet from a serialized source
  54107. * @param data defines a JSON compatible representation of the set
  54108. * @param scene defines the hosting scene
  54109. * @param gpu defines if we want GPU particles or CPU particles
  54110. * @returns a new ParticleSystemSet
  54111. */
  54112. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54113. }
  54114. }
  54115. declare module "babylonjs/Particles/particleHelper" {
  54116. import { Nullable } from "babylonjs/types";
  54117. import { Scene } from "babylonjs/scene";
  54118. import { Vector3 } from "babylonjs/Maths/math";
  54119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54120. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54121. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  54122. /**
  54123. * This class is made for on one-liner static method to help creating particle system set.
  54124. */
  54125. export class ParticleHelper {
  54126. /**
  54127. * Gets or sets base Assets URL
  54128. */
  54129. static BaseAssetsUrl: string;
  54130. /**
  54131. * Create a default particle system that you can tweak
  54132. * @param emitter defines the emitter to use
  54133. * @param capacity defines the system capacity (default is 500 particles)
  54134. * @param scene defines the hosting scene
  54135. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54136. * @returns the new Particle system
  54137. */
  54138. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54139. /**
  54140. * This is the main static method (one-liner) of this helper to create different particle systems
  54141. * @param type This string represents the type to the particle system to create
  54142. * @param scene The scene where the particle system should live
  54143. * @param gpu If the system will use gpu
  54144. * @returns the ParticleSystemSet created
  54145. */
  54146. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54147. /**
  54148. * Static function used to export a particle system to a ParticleSystemSet variable.
  54149. * Please note that the emitter shape is not exported
  54150. * @param systems defines the particle systems to export
  54151. * @returns the created particle system set
  54152. */
  54153. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54154. }
  54155. }
  54156. declare module "babylonjs/Particles/particleSystemComponent" {
  54157. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54158. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54159. import "babylonjs/Shaders/particles.vertex";
  54160. module "babylonjs/Engines/engine" {
  54161. interface Engine {
  54162. /**
  54163. * Create an effect to use with particle systems.
  54164. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54165. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54166. * @param uniformsNames defines a list of attribute names
  54167. * @param samplers defines an array of string used to represent textures
  54168. * @param defines defines the string containing the defines to use to compile the shaders
  54169. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54170. * @param onCompiled defines a function to call when the effect creation is successful
  54171. * @param onError defines a function to call when the effect creation has failed
  54172. * @returns the new Effect
  54173. */
  54174. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54175. }
  54176. }
  54177. module "babylonjs/Meshes/mesh" {
  54178. interface Mesh {
  54179. /**
  54180. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54181. * @returns an array of IParticleSystem
  54182. */
  54183. getEmittedParticleSystems(): IParticleSystem[];
  54184. /**
  54185. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54186. * @returns an array of IParticleSystem
  54187. */
  54188. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54189. }
  54190. }
  54191. /**
  54192. * @hidden
  54193. */
  54194. export var _IDoNeedToBeInTheBuild: number;
  54195. }
  54196. declare module "babylonjs/Particles/index" {
  54197. export * from "babylonjs/Particles/baseParticleSystem";
  54198. export * from "babylonjs/Particles/EmitterTypes/index";
  54199. export * from "babylonjs/Particles/gpuParticleSystem";
  54200. export * from "babylonjs/Particles/IParticleSystem";
  54201. export * from "babylonjs/Particles/particle";
  54202. export * from "babylonjs/Particles/particleHelper";
  54203. export * from "babylonjs/Particles/particleSystem";
  54204. export * from "babylonjs/Particles/particleSystemComponent";
  54205. export * from "babylonjs/Particles/particleSystemSet";
  54206. export * from "babylonjs/Particles/solidParticle";
  54207. export * from "babylonjs/Particles/solidParticleSystem";
  54208. export * from "babylonjs/Particles/subEmitter";
  54209. }
  54210. declare module "babylonjs/Physics/physicsEngineComponent" {
  54211. import { Nullable } from "babylonjs/types";
  54212. import { Observable, Observer } from "babylonjs/Misc/observable";
  54213. import { Vector3 } from "babylonjs/Maths/math";
  54214. import { Mesh } from "babylonjs/Meshes/mesh";
  54215. import { ISceneComponent } from "babylonjs/sceneComponent";
  54216. import { Scene } from "babylonjs/scene";
  54217. import { Node } from "babylonjs/node";
  54218. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54219. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54220. module "babylonjs/scene" {
  54221. interface Scene {
  54222. /** @hidden (Backing field) */
  54223. _physicsEngine: Nullable<IPhysicsEngine>;
  54224. /**
  54225. * Gets the current physics engine
  54226. * @returns a IPhysicsEngine or null if none attached
  54227. */
  54228. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54229. /**
  54230. * Enables physics to the current scene
  54231. * @param gravity defines the scene's gravity for the physics engine
  54232. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54233. * @return a boolean indicating if the physics engine was initialized
  54234. */
  54235. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54236. /**
  54237. * Disables and disposes the physics engine associated with the scene
  54238. */
  54239. disablePhysicsEngine(): void;
  54240. /**
  54241. * Gets a boolean indicating if there is an active physics engine
  54242. * @returns a boolean indicating if there is an active physics engine
  54243. */
  54244. isPhysicsEnabled(): boolean;
  54245. /**
  54246. * Deletes a physics compound impostor
  54247. * @param compound defines the compound to delete
  54248. */
  54249. deleteCompoundImpostor(compound: any): void;
  54250. /**
  54251. * An event triggered when physic simulation is about to be run
  54252. */
  54253. onBeforePhysicsObservable: Observable<Scene>;
  54254. /**
  54255. * An event triggered when physic simulation has been done
  54256. */
  54257. onAfterPhysicsObservable: Observable<Scene>;
  54258. }
  54259. }
  54260. module "babylonjs/Meshes/abstractMesh" {
  54261. interface AbstractMesh {
  54262. /** @hidden */
  54263. _physicsImpostor: Nullable<PhysicsImpostor>;
  54264. /**
  54265. * Gets or sets impostor used for physic simulation
  54266. * @see http://doc.babylonjs.com/features/physics_engine
  54267. */
  54268. physicsImpostor: Nullable<PhysicsImpostor>;
  54269. /**
  54270. * Gets the current physics impostor
  54271. * @see http://doc.babylonjs.com/features/physics_engine
  54272. * @returns a physics impostor or null
  54273. */
  54274. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54275. /** Apply a physic impulse to the mesh
  54276. * @param force defines the force to apply
  54277. * @param contactPoint defines where to apply the force
  54278. * @returns the current mesh
  54279. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54280. */
  54281. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54282. /**
  54283. * Creates a physic joint between two meshes
  54284. * @param otherMesh defines the other mesh to use
  54285. * @param pivot1 defines the pivot to use on this mesh
  54286. * @param pivot2 defines the pivot to use on the other mesh
  54287. * @param options defines additional options (can be plugin dependent)
  54288. * @returns the current mesh
  54289. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54290. */
  54291. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54292. /** @hidden */
  54293. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54294. }
  54295. }
  54296. /**
  54297. * Defines the physics engine scene component responsible to manage a physics engine
  54298. */
  54299. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54300. /**
  54301. * The component name helpful to identify the component in the list of scene components.
  54302. */
  54303. readonly name: string;
  54304. /**
  54305. * The scene the component belongs to.
  54306. */
  54307. scene: Scene;
  54308. /**
  54309. * Creates a new instance of the component for the given scene
  54310. * @param scene Defines the scene to register the component in
  54311. */
  54312. constructor(scene: Scene);
  54313. /**
  54314. * Registers the component in a given scene
  54315. */
  54316. register(): void;
  54317. /**
  54318. * Rebuilds the elements related to this component in case of
  54319. * context lost for instance.
  54320. */
  54321. rebuild(): void;
  54322. /**
  54323. * Disposes the component and the associated ressources
  54324. */
  54325. dispose(): void;
  54326. }
  54327. }
  54328. declare module "babylonjs/Physics/physicsHelper" {
  54329. import { Nullable } from "babylonjs/types";
  54330. import { Vector3 } from "babylonjs/Maths/math";
  54331. import { Mesh } from "babylonjs/Meshes/mesh";
  54332. import { Scene } from "babylonjs/scene";
  54333. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54334. /**
  54335. * A helper for physics simulations
  54336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54337. */
  54338. export class PhysicsHelper {
  54339. private _scene;
  54340. private _physicsEngine;
  54341. /**
  54342. * Initializes the Physics helper
  54343. * @param scene Babylon.js scene
  54344. */
  54345. constructor(scene: Scene);
  54346. /**
  54347. * Applies a radial explosion impulse
  54348. * @param origin the origin of the explosion
  54349. * @param radiusOrEventOptions the radius or the options of radial explosion
  54350. * @param strength the explosion strength
  54351. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54352. * @returns A physics radial explosion event, or null
  54353. */
  54354. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54355. /**
  54356. * Applies a radial explosion force
  54357. * @param origin the origin of the explosion
  54358. * @param radiusOrEventOptions the radius or the options of radial explosion
  54359. * @param strength the explosion strength
  54360. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54361. * @returns A physics radial explosion event, or null
  54362. */
  54363. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54364. /**
  54365. * Creates a gravitational field
  54366. * @param origin the origin of the explosion
  54367. * @param radiusOrEventOptions the radius or the options of radial explosion
  54368. * @param strength the explosion strength
  54369. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54370. * @returns A physics gravitational field event, or null
  54371. */
  54372. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54373. /**
  54374. * Creates a physics updraft event
  54375. * @param origin the origin of the updraft
  54376. * @param radiusOrEventOptions the radius or the options of the updraft
  54377. * @param strength the strength of the updraft
  54378. * @param height the height of the updraft
  54379. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54380. * @returns A physics updraft event, or null
  54381. */
  54382. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54383. /**
  54384. * Creates a physics vortex event
  54385. * @param origin the of the vortex
  54386. * @param radiusOrEventOptions the radius or the options of the vortex
  54387. * @param strength the strength of the vortex
  54388. * @param height the height of the vortex
  54389. * @returns a Physics vortex event, or null
  54390. * A physics vortex event or null
  54391. */
  54392. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54393. }
  54394. /**
  54395. * Represents a physics radial explosion event
  54396. */
  54397. class PhysicsRadialExplosionEvent {
  54398. private _scene;
  54399. private _options;
  54400. private _sphere;
  54401. private _dataFetched;
  54402. /**
  54403. * Initializes a radial explosioin event
  54404. * @param _scene BabylonJS scene
  54405. * @param _options The options for the vortex event
  54406. */
  54407. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54408. /**
  54409. * Returns the data related to the radial explosion event (sphere).
  54410. * @returns The radial explosion event data
  54411. */
  54412. getData(): PhysicsRadialExplosionEventData;
  54413. /**
  54414. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54415. * @param impostor A physics imposter
  54416. * @param origin the origin of the explosion
  54417. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54418. */
  54419. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54420. /**
  54421. * Triggers affecterd impostors callbacks
  54422. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54423. */
  54424. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54425. /**
  54426. * Disposes the sphere.
  54427. * @param force Specifies if the sphere should be disposed by force
  54428. */
  54429. dispose(force?: boolean): void;
  54430. /*** Helpers ***/
  54431. private _prepareSphere;
  54432. private _intersectsWithSphere;
  54433. }
  54434. /**
  54435. * Represents a gravitational field event
  54436. */
  54437. class PhysicsGravitationalFieldEvent {
  54438. private _physicsHelper;
  54439. private _scene;
  54440. private _origin;
  54441. private _options;
  54442. private _tickCallback;
  54443. private _sphere;
  54444. private _dataFetched;
  54445. /**
  54446. * Initializes the physics gravitational field event
  54447. * @param _physicsHelper A physics helper
  54448. * @param _scene BabylonJS scene
  54449. * @param _origin The origin position of the gravitational field event
  54450. * @param _options The options for the vortex event
  54451. */
  54452. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54453. /**
  54454. * Returns the data related to the gravitational field event (sphere).
  54455. * @returns A gravitational field event
  54456. */
  54457. getData(): PhysicsGravitationalFieldEventData;
  54458. /**
  54459. * Enables the gravitational field.
  54460. */
  54461. enable(): void;
  54462. /**
  54463. * Disables the gravitational field.
  54464. */
  54465. disable(): void;
  54466. /**
  54467. * Disposes the sphere.
  54468. * @param force The force to dispose from the gravitational field event
  54469. */
  54470. dispose(force?: boolean): void;
  54471. private _tick;
  54472. }
  54473. /**
  54474. * Represents a physics updraft event
  54475. */
  54476. class PhysicsUpdraftEvent {
  54477. private _scene;
  54478. private _origin;
  54479. private _options;
  54480. private _physicsEngine;
  54481. private _originTop;
  54482. private _originDirection;
  54483. private _tickCallback;
  54484. private _cylinder;
  54485. private _cylinderPosition;
  54486. private _dataFetched;
  54487. /**
  54488. * Initializes the physics updraft event
  54489. * @param _scene BabylonJS scene
  54490. * @param _origin The origin position of the updraft
  54491. * @param _options The options for the updraft event
  54492. */
  54493. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54494. /**
  54495. * Returns the data related to the updraft event (cylinder).
  54496. * @returns A physics updraft event
  54497. */
  54498. getData(): PhysicsUpdraftEventData;
  54499. /**
  54500. * Enables the updraft.
  54501. */
  54502. enable(): void;
  54503. /**
  54504. * Disables the updraft.
  54505. */
  54506. disable(): void;
  54507. /**
  54508. * Disposes the cylinder.
  54509. * @param force Specifies if the updraft should be disposed by force
  54510. */
  54511. dispose(force?: boolean): void;
  54512. private getImpostorHitData;
  54513. private _tick;
  54514. /*** Helpers ***/
  54515. private _prepareCylinder;
  54516. private _intersectsWithCylinder;
  54517. }
  54518. /**
  54519. * Represents a physics vortex event
  54520. */
  54521. class PhysicsVortexEvent {
  54522. private _scene;
  54523. private _origin;
  54524. private _options;
  54525. private _physicsEngine;
  54526. private _originTop;
  54527. private _tickCallback;
  54528. private _cylinder;
  54529. private _cylinderPosition;
  54530. private _dataFetched;
  54531. /**
  54532. * Initializes the physics vortex event
  54533. * @param _scene The BabylonJS scene
  54534. * @param _origin The origin position of the vortex
  54535. * @param _options The options for the vortex event
  54536. */
  54537. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54538. /**
  54539. * Returns the data related to the vortex event (cylinder).
  54540. * @returns The physics vortex event data
  54541. */
  54542. getData(): PhysicsVortexEventData;
  54543. /**
  54544. * Enables the vortex.
  54545. */
  54546. enable(): void;
  54547. /**
  54548. * Disables the cortex.
  54549. */
  54550. disable(): void;
  54551. /**
  54552. * Disposes the sphere.
  54553. * @param force
  54554. */
  54555. dispose(force?: boolean): void;
  54556. private getImpostorHitData;
  54557. private _tick;
  54558. /*** Helpers ***/
  54559. private _prepareCylinder;
  54560. private _intersectsWithCylinder;
  54561. }
  54562. /**
  54563. * Options fot the radial explosion event
  54564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54565. */
  54566. export class PhysicsRadialExplosionEventOptions {
  54567. /**
  54568. * The radius of the sphere for the radial explosion.
  54569. */
  54570. radius: number;
  54571. /**
  54572. * The strenth of the explosion.
  54573. */
  54574. strength: number;
  54575. /**
  54576. * The strenght of the force in correspondence to the distance of the affected object
  54577. */
  54578. falloff: PhysicsRadialImpulseFalloff;
  54579. /**
  54580. * Sphere options for the radial explosion.
  54581. */
  54582. sphere: {
  54583. segments: number;
  54584. diameter: number;
  54585. };
  54586. /**
  54587. * Sphere options for the radial explosion.
  54588. */
  54589. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54590. }
  54591. /**
  54592. * Options fot the updraft event
  54593. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54594. */
  54595. export class PhysicsUpdraftEventOptions {
  54596. /**
  54597. * The radius of the cylinder for the vortex
  54598. */
  54599. radius: number;
  54600. /**
  54601. * The strenth of the updraft.
  54602. */
  54603. strength: number;
  54604. /**
  54605. * The height of the cylinder for the updraft.
  54606. */
  54607. height: number;
  54608. /**
  54609. * The mode for the the updraft.
  54610. */
  54611. updraftMode: PhysicsUpdraftMode;
  54612. }
  54613. /**
  54614. * Options fot the vortex event
  54615. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54616. */
  54617. export class PhysicsVortexEventOptions {
  54618. /**
  54619. * The radius of the cylinder for the vortex
  54620. */
  54621. radius: number;
  54622. /**
  54623. * The strenth of the vortex.
  54624. */
  54625. strength: number;
  54626. /**
  54627. * The height of the cylinder for the vortex.
  54628. */
  54629. height: number;
  54630. /**
  54631. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54632. */
  54633. centripetalForceThreshold: number;
  54634. /**
  54635. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54636. */
  54637. centripetalForceMultiplier: number;
  54638. /**
  54639. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54640. */
  54641. centrifugalForceMultiplier: number;
  54642. /**
  54643. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54644. */
  54645. updraftForceMultiplier: number;
  54646. }
  54647. /**
  54648. * The strenght of the force in correspondence to the distance of the affected object
  54649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54650. */
  54651. export enum PhysicsRadialImpulseFalloff {
  54652. /** Defines that impulse is constant in strength across it's whole radius */
  54653. Constant = 0,
  54654. /** Defines that impulse gets weaker if it's further from the origin */
  54655. Linear = 1
  54656. }
  54657. /**
  54658. * The strength of the force in correspondence to the distance of the affected object
  54659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54660. */
  54661. export enum PhysicsUpdraftMode {
  54662. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54663. Center = 0,
  54664. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54665. Perpendicular = 1
  54666. }
  54667. /**
  54668. * Interface for a physics hit data
  54669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54670. */
  54671. export interface PhysicsHitData {
  54672. /**
  54673. * The force applied at the contact point
  54674. */
  54675. force: Vector3;
  54676. /**
  54677. * The contact point
  54678. */
  54679. contactPoint: Vector3;
  54680. /**
  54681. * The distance from the origin to the contact point
  54682. */
  54683. distanceFromOrigin: number;
  54684. }
  54685. /**
  54686. * Interface for radial explosion event data
  54687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54688. */
  54689. export interface PhysicsRadialExplosionEventData {
  54690. /**
  54691. * A sphere used for the radial explosion event
  54692. */
  54693. sphere: Mesh;
  54694. }
  54695. /**
  54696. * Interface for gravitational field event data
  54697. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54698. */
  54699. export interface PhysicsGravitationalFieldEventData {
  54700. /**
  54701. * A sphere mesh used for the gravitational field event
  54702. */
  54703. sphere: Mesh;
  54704. }
  54705. /**
  54706. * Interface for updraft event data
  54707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54708. */
  54709. export interface PhysicsUpdraftEventData {
  54710. /**
  54711. * A cylinder used for the updraft event
  54712. */
  54713. cylinder: Mesh;
  54714. }
  54715. /**
  54716. * Interface for vortex event data
  54717. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54718. */
  54719. export interface PhysicsVortexEventData {
  54720. /**
  54721. * A cylinder used for the vortex event
  54722. */
  54723. cylinder: Mesh;
  54724. }
  54725. /**
  54726. * Interface for an affected physics impostor
  54727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54728. */
  54729. export interface PhysicsAffectedImpostorWithData {
  54730. /**
  54731. * The impostor affected by the effect
  54732. */
  54733. impostor: PhysicsImpostor;
  54734. /**
  54735. * The data about the hit/horce from the explosion
  54736. */
  54737. hitData: PhysicsHitData;
  54738. }
  54739. }
  54740. declare module "babylonjs/Physics/Plugins/index" {
  54741. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54742. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54743. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54744. }
  54745. declare module "babylonjs/Physics/index" {
  54746. export * from "babylonjs/Physics/IPhysicsEngine";
  54747. export * from "babylonjs/Physics/physicsEngine";
  54748. export * from "babylonjs/Physics/physicsEngineComponent";
  54749. export * from "babylonjs/Physics/physicsHelper";
  54750. export * from "babylonjs/Physics/physicsImpostor";
  54751. export * from "babylonjs/Physics/physicsJoint";
  54752. export * from "babylonjs/Physics/Plugins/index";
  54753. }
  54754. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54755. /** @hidden */
  54756. export var blackAndWhitePixelShader: {
  54757. name: string;
  54758. shader: string;
  54759. };
  54760. }
  54761. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54762. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54763. import { Camera } from "babylonjs/Cameras/camera";
  54764. import { Engine } from "babylonjs/Engines/engine";
  54765. import "babylonjs/Shaders/blackAndWhite.fragment";
  54766. /**
  54767. * Post process used to render in black and white
  54768. */
  54769. export class BlackAndWhitePostProcess extends PostProcess {
  54770. /**
  54771. * Linear about to convert he result to black and white (default: 1)
  54772. */
  54773. degree: number;
  54774. /**
  54775. * Creates a black and white post process
  54776. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54777. * @param name The name of the effect.
  54778. * @param options The required width/height ratio to downsize to before computing the render pass.
  54779. * @param camera The camera to apply the render pass to.
  54780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54781. * @param engine The engine which the post process will be applied. (default: current engine)
  54782. * @param reusable If the post process can be reused on the same frame. (default: false)
  54783. */
  54784. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54785. }
  54786. }
  54787. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54788. import { Nullable } from "babylonjs/types";
  54789. import { Camera } from "babylonjs/Cameras/camera";
  54790. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54791. import { Engine } from "babylonjs/Engines/engine";
  54792. /**
  54793. * This represents a set of one or more post processes in Babylon.
  54794. * A post process can be used to apply a shader to a texture after it is rendered.
  54795. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54796. */
  54797. export class PostProcessRenderEffect {
  54798. private _postProcesses;
  54799. private _getPostProcesses;
  54800. private _singleInstance;
  54801. private _cameras;
  54802. private _indicesForCamera;
  54803. /**
  54804. * Name of the effect
  54805. * @hidden
  54806. */
  54807. _name: string;
  54808. /**
  54809. * Instantiates a post process render effect.
  54810. * A post process can be used to apply a shader to a texture after it is rendered.
  54811. * @param engine The engine the effect is tied to
  54812. * @param name The name of the effect
  54813. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54814. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54815. */
  54816. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54817. /**
  54818. * Checks if all the post processes in the effect are supported.
  54819. */
  54820. readonly isSupported: boolean;
  54821. /**
  54822. * Updates the current state of the effect
  54823. * @hidden
  54824. */
  54825. _update(): void;
  54826. /**
  54827. * Attaches the effect on cameras
  54828. * @param cameras The camera to attach to.
  54829. * @hidden
  54830. */
  54831. _attachCameras(cameras: Camera): void;
  54832. /**
  54833. * Attaches the effect on cameras
  54834. * @param cameras The camera to attach to.
  54835. * @hidden
  54836. */
  54837. _attachCameras(cameras: Camera[]): void;
  54838. /**
  54839. * Detaches the effect on cameras
  54840. * @param cameras The camera to detatch from.
  54841. * @hidden
  54842. */
  54843. _detachCameras(cameras: Camera): void;
  54844. /**
  54845. * Detatches the effect on cameras
  54846. * @param cameras The camera to detatch from.
  54847. * @hidden
  54848. */
  54849. _detachCameras(cameras: Camera[]): void;
  54850. /**
  54851. * Enables the effect on given cameras
  54852. * @param cameras The camera to enable.
  54853. * @hidden
  54854. */
  54855. _enable(cameras: Camera): void;
  54856. /**
  54857. * Enables the effect on given cameras
  54858. * @param cameras The camera to enable.
  54859. * @hidden
  54860. */
  54861. _enable(cameras: Nullable<Camera[]>): void;
  54862. /**
  54863. * Disables the effect on the given cameras
  54864. * @param cameras The camera to disable.
  54865. * @hidden
  54866. */
  54867. _disable(cameras: Camera): void;
  54868. /**
  54869. * Disables the effect on the given cameras
  54870. * @param cameras The camera to disable.
  54871. * @hidden
  54872. */
  54873. _disable(cameras: Nullable<Camera[]>): void;
  54874. /**
  54875. * Gets a list of the post processes contained in the effect.
  54876. * @param camera The camera to get the post processes on.
  54877. * @returns The list of the post processes in the effect.
  54878. */
  54879. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54880. }
  54881. }
  54882. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54883. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54884. /** @hidden */
  54885. export var extractHighlightsPixelShader: {
  54886. name: string;
  54887. shader: string;
  54888. };
  54889. }
  54890. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54891. import { Nullable } from "babylonjs/types";
  54892. import { Camera } from "babylonjs/Cameras/camera";
  54893. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54894. import { Engine } from "babylonjs/Engines/engine";
  54895. import "babylonjs/Shaders/extractHighlights.fragment";
  54896. /**
  54897. * 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.
  54898. */
  54899. export class ExtractHighlightsPostProcess extends PostProcess {
  54900. /**
  54901. * The luminance threshold, pixels below this value will be set to black.
  54902. */
  54903. threshold: number;
  54904. /** @hidden */
  54905. _exposure: number;
  54906. /**
  54907. * Post process which has the input texture to be used when performing highlight extraction
  54908. * @hidden
  54909. */
  54910. _inputPostProcess: Nullable<PostProcess>;
  54911. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54912. }
  54913. }
  54914. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54915. /** @hidden */
  54916. export var bloomMergePixelShader: {
  54917. name: string;
  54918. shader: string;
  54919. };
  54920. }
  54921. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54922. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54923. import { Nullable } from "babylonjs/types";
  54924. import { Engine } from "babylonjs/Engines/engine";
  54925. import { Camera } from "babylonjs/Cameras/camera";
  54926. import "babylonjs/Shaders/bloomMerge.fragment";
  54927. /**
  54928. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54929. */
  54930. export class BloomMergePostProcess extends PostProcess {
  54931. /** Weight of the bloom to be added to the original input. */
  54932. weight: number;
  54933. /**
  54934. * Creates a new instance of @see BloomMergePostProcess
  54935. * @param name The name of the effect.
  54936. * @param originalFromInput Post process which's input will be used for the merge.
  54937. * @param blurred Blurred highlights post process which's output will be used.
  54938. * @param weight Weight of the bloom to be added to the original input.
  54939. * @param options The required width/height ratio to downsize to before computing the render pass.
  54940. * @param camera The camera to apply the render pass to.
  54941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54942. * @param engine The engine which the post process will be applied. (default: current engine)
  54943. * @param reusable If the post process can be reused on the same frame. (default: false)
  54944. * @param textureType Type of textures used when performing the post process. (default: 0)
  54945. * @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)
  54946. */
  54947. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54948. /** Weight of the bloom to be added to the original input. */
  54949. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54950. }
  54951. }
  54952. declare module "babylonjs/PostProcesses/bloomEffect" {
  54953. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54954. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54955. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54956. import { Camera } from "babylonjs/Cameras/camera";
  54957. import { Scene } from "babylonjs/scene";
  54958. /**
  54959. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54960. */
  54961. export class BloomEffect extends PostProcessRenderEffect {
  54962. private bloomScale;
  54963. /**
  54964. * @hidden Internal
  54965. */
  54966. _effects: Array<PostProcess>;
  54967. /**
  54968. * @hidden Internal
  54969. */
  54970. _downscale: ExtractHighlightsPostProcess;
  54971. private _blurX;
  54972. private _blurY;
  54973. private _merge;
  54974. /**
  54975. * The luminance threshold to find bright areas of the image to bloom.
  54976. */
  54977. threshold: number;
  54978. /**
  54979. * The strength of the bloom.
  54980. */
  54981. weight: number;
  54982. /**
  54983. * Specifies the size of the bloom blur kernel, relative to the final output size
  54984. */
  54985. kernel: number;
  54986. /**
  54987. * Creates a new instance of @see BloomEffect
  54988. * @param scene The scene the effect belongs to.
  54989. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54990. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54991. * @param bloomWeight The the strength of bloom.
  54992. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54993. * @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)
  54994. */
  54995. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54996. /**
  54997. * Disposes each of the internal effects for a given camera.
  54998. * @param camera The camera to dispose the effect on.
  54999. */
  55000. disposeEffects(camera: Camera): void;
  55001. /**
  55002. * @hidden Internal
  55003. */
  55004. _updateEffects(): void;
  55005. /**
  55006. * Internal
  55007. * @returns if all the contained post processes are ready.
  55008. * @hidden
  55009. */
  55010. _isReady(): boolean;
  55011. }
  55012. }
  55013. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  55014. /** @hidden */
  55015. export var chromaticAberrationPixelShader: {
  55016. name: string;
  55017. shader: string;
  55018. };
  55019. }
  55020. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  55021. import { Vector2 } from "babylonjs/Maths/math";
  55022. import { Nullable } from "babylonjs/types";
  55023. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55024. import { Camera } from "babylonjs/Cameras/camera";
  55025. import { Engine } from "babylonjs/Engines/engine";
  55026. import "babylonjs/Shaders/chromaticAberration.fragment";
  55027. /**
  55028. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  55029. */
  55030. export class ChromaticAberrationPostProcess extends PostProcess {
  55031. /**
  55032. * The amount of seperation of rgb channels (default: 30)
  55033. */
  55034. aberrationAmount: number;
  55035. /**
  55036. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  55037. */
  55038. radialIntensity: number;
  55039. /**
  55040. * 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))
  55041. */
  55042. direction: Vector2;
  55043. /**
  55044. * 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))
  55045. */
  55046. centerPosition: Vector2;
  55047. /**
  55048. * Creates a new instance ChromaticAberrationPostProcess
  55049. * @param name The name of the effect.
  55050. * @param screenWidth The width of the screen to apply the effect on.
  55051. * @param screenHeight The height of the screen to apply the effect on.
  55052. * @param options The required width/height ratio to downsize to before computing the render pass.
  55053. * @param camera The camera to apply the render pass to.
  55054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55055. * @param engine The engine which the post process will be applied. (default: current engine)
  55056. * @param reusable If the post process can be reused on the same frame. (default: false)
  55057. * @param textureType Type of textures used when performing the post process. (default: 0)
  55058. * @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)
  55059. */
  55060. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55061. }
  55062. }
  55063. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  55064. /** @hidden */
  55065. export var circleOfConfusionPixelShader: {
  55066. name: string;
  55067. shader: string;
  55068. };
  55069. }
  55070. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  55071. import { Nullable } from "babylonjs/types";
  55072. import { Engine } from "babylonjs/Engines/engine";
  55073. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55074. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55075. import { Camera } from "babylonjs/Cameras/camera";
  55076. import "babylonjs/Shaders/circleOfConfusion.fragment";
  55077. /**
  55078. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  55079. */
  55080. export class CircleOfConfusionPostProcess extends PostProcess {
  55081. /**
  55082. * 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.
  55083. */
  55084. lensSize: number;
  55085. /**
  55086. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55087. */
  55088. fStop: number;
  55089. /**
  55090. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55091. */
  55092. focusDistance: number;
  55093. /**
  55094. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55095. */
  55096. focalLength: number;
  55097. private _depthTexture;
  55098. /**
  55099. * Creates a new instance CircleOfConfusionPostProcess
  55100. * @param name The name of the effect.
  55101. * @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.
  55102. * @param options The required width/height ratio to downsize to before computing the render pass.
  55103. * @param camera The camera to apply the render pass to.
  55104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55105. * @param engine The engine which the post process will be applied. (default: current engine)
  55106. * @param reusable If the post process can be reused on the same frame. (default: false)
  55107. * @param textureType Type of textures used when performing the post process. (default: 0)
  55108. * @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)
  55109. */
  55110. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55111. /**
  55112. * 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.
  55113. */
  55114. depthTexture: RenderTargetTexture;
  55115. }
  55116. }
  55117. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  55118. /** @hidden */
  55119. export var colorCorrectionPixelShader: {
  55120. name: string;
  55121. shader: string;
  55122. };
  55123. }
  55124. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  55125. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55126. import { Engine } from "babylonjs/Engines/engine";
  55127. import { Camera } from "babylonjs/Cameras/camera";
  55128. import "babylonjs/Shaders/colorCorrection.fragment";
  55129. /**
  55130. *
  55131. * This post-process allows the modification of rendered colors by using
  55132. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55133. *
  55134. * The object needs to be provided an url to a texture containing the color
  55135. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55136. * Use an image editing software to tweak the LUT to match your needs.
  55137. *
  55138. * For an example of a color LUT, see here:
  55139. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55140. * For explanations on color grading, see here:
  55141. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55142. *
  55143. */
  55144. export class ColorCorrectionPostProcess extends PostProcess {
  55145. private _colorTableTexture;
  55146. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55147. }
  55148. }
  55149. declare module "babylonjs/Shaders/convolution.fragment" {
  55150. /** @hidden */
  55151. export var convolutionPixelShader: {
  55152. name: string;
  55153. shader: string;
  55154. };
  55155. }
  55156. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  55157. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55158. import { Nullable } from "babylonjs/types";
  55159. import { Camera } from "babylonjs/Cameras/camera";
  55160. import { Engine } from "babylonjs/Engines/engine";
  55161. import "babylonjs/Shaders/convolution.fragment";
  55162. /**
  55163. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55164. * input texture to perform effects such as edge detection or sharpening
  55165. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55166. */
  55167. export class ConvolutionPostProcess extends PostProcess {
  55168. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55169. kernel: number[];
  55170. /**
  55171. * Creates a new instance ConvolutionPostProcess
  55172. * @param name The name of the effect.
  55173. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  55174. * @param options The required width/height ratio to downsize to before computing the render pass.
  55175. * @param camera The camera to apply the render pass to.
  55176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55177. * @param engine The engine which the post process will be applied. (default: current engine)
  55178. * @param reusable If the post process can be reused on the same frame. (default: false)
  55179. * @param textureType Type of textures used when performing the post process. (default: 0)
  55180. */
  55181. constructor(name: string,
  55182. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55183. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55184. /**
  55185. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55186. */
  55187. static EdgeDetect0Kernel: number[];
  55188. /**
  55189. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55190. */
  55191. static EdgeDetect1Kernel: number[];
  55192. /**
  55193. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55194. */
  55195. static EdgeDetect2Kernel: number[];
  55196. /**
  55197. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55198. */
  55199. static SharpenKernel: number[];
  55200. /**
  55201. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55202. */
  55203. static EmbossKernel: number[];
  55204. /**
  55205. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55206. */
  55207. static GaussianKernel: number[];
  55208. }
  55209. }
  55210. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  55211. import { Nullable } from "babylonjs/types";
  55212. import { Vector2 } from "babylonjs/Maths/math";
  55213. import { Camera } from "babylonjs/Cameras/camera";
  55214. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55215. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55216. import { Engine } from "babylonjs/Engines/engine";
  55217. import { Scene } from "babylonjs/scene";
  55218. /**
  55219. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55220. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55221. * based on samples that have a large difference in distance than the center pixel.
  55222. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55223. */
  55224. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55225. direction: Vector2;
  55226. /**
  55227. * Creates a new instance CircleOfConfusionPostProcess
  55228. * @param name The name of the effect.
  55229. * @param scene The scene the effect belongs to.
  55230. * @param direction The direction the blur should be applied.
  55231. * @param kernel The size of the kernel used to blur.
  55232. * @param options The required width/height ratio to downsize to before computing the render pass.
  55233. * @param camera The camera to apply the render pass to.
  55234. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55235. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55236. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55237. * @param engine The engine which the post process will be applied. (default: current engine)
  55238. * @param reusable If the post process can be reused on the same frame. (default: false)
  55239. * @param textureType Type of textures used when performing the post process. (default: 0)
  55240. * @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)
  55241. */
  55242. 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);
  55243. }
  55244. }
  55245. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  55246. /** @hidden */
  55247. export var depthOfFieldMergePixelShader: {
  55248. name: string;
  55249. shader: string;
  55250. };
  55251. }
  55252. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  55253. import { Nullable } from "babylonjs/types";
  55254. import { Camera } from "babylonjs/Cameras/camera";
  55255. import { Effect } from "babylonjs/Materials/effect";
  55256. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55257. import { Engine } from "babylonjs/Engines/engine";
  55258. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  55259. /**
  55260. * Options to be set when merging outputs from the default pipeline.
  55261. */
  55262. export class DepthOfFieldMergePostProcessOptions {
  55263. /**
  55264. * The original image to merge on top of
  55265. */
  55266. originalFromInput: PostProcess;
  55267. /**
  55268. * Parameters to perform the merge of the depth of field effect
  55269. */
  55270. depthOfField?: {
  55271. circleOfConfusion: PostProcess;
  55272. blurSteps: Array<PostProcess>;
  55273. };
  55274. /**
  55275. * Parameters to perform the merge of bloom effect
  55276. */
  55277. bloom?: {
  55278. blurred: PostProcess;
  55279. weight: number;
  55280. };
  55281. }
  55282. /**
  55283. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55284. */
  55285. export class DepthOfFieldMergePostProcess extends PostProcess {
  55286. private blurSteps;
  55287. /**
  55288. * Creates a new instance of DepthOfFieldMergePostProcess
  55289. * @param name The name of the effect.
  55290. * @param originalFromInput Post process which's input will be used for the merge.
  55291. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55292. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55293. * @param options The required width/height ratio to downsize to before computing the render pass.
  55294. * @param camera The camera to apply the render pass to.
  55295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55296. * @param engine The engine which the post process will be applied. (default: current engine)
  55297. * @param reusable If the post process can be reused on the same frame. (default: false)
  55298. * @param textureType Type of textures used when performing the post process. (default: 0)
  55299. * @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)
  55300. */
  55301. 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);
  55302. /**
  55303. * Updates the effect with the current post process compile time values and recompiles the shader.
  55304. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55305. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55306. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55307. * @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
  55308. * @param onCompiled Called when the shader has been compiled.
  55309. * @param onError Called if there is an error when compiling a shader.
  55310. */
  55311. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55312. }
  55313. }
  55314. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  55315. import { Nullable } from "babylonjs/types";
  55316. import { Camera } from "babylonjs/Cameras/camera";
  55317. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55318. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55319. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55320. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55321. import { Scene } from "babylonjs/scene";
  55322. /**
  55323. * Specifies the level of max blur that should be applied when using the depth of field effect
  55324. */
  55325. export enum DepthOfFieldEffectBlurLevel {
  55326. /**
  55327. * Subtle blur
  55328. */
  55329. Low = 0,
  55330. /**
  55331. * Medium blur
  55332. */
  55333. Medium = 1,
  55334. /**
  55335. * Large blur
  55336. */
  55337. High = 2
  55338. }
  55339. /**
  55340. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55341. */
  55342. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55343. private _circleOfConfusion;
  55344. /**
  55345. * @hidden Internal, blurs from high to low
  55346. */
  55347. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55348. private _depthOfFieldBlurY;
  55349. private _dofMerge;
  55350. /**
  55351. * @hidden Internal post processes in depth of field effect
  55352. */
  55353. _effects: Array<PostProcess>;
  55354. /**
  55355. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55356. */
  55357. focalLength: number;
  55358. /**
  55359. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55360. */
  55361. fStop: number;
  55362. /**
  55363. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55364. */
  55365. focusDistance: number;
  55366. /**
  55367. * 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.
  55368. */
  55369. lensSize: number;
  55370. /**
  55371. * Creates a new instance DepthOfFieldEffect
  55372. * @param scene The scene the effect belongs to.
  55373. * @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.
  55374. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55375. * @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)
  55376. */
  55377. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55378. /**
  55379. * Get the current class name of the current effet
  55380. * @returns "DepthOfFieldEffect"
  55381. */
  55382. getClassName(): string;
  55383. /**
  55384. * 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.
  55385. */
  55386. depthTexture: RenderTargetTexture;
  55387. /**
  55388. * Disposes each of the internal effects for a given camera.
  55389. * @param camera The camera to dispose the effect on.
  55390. */
  55391. disposeEffects(camera: Camera): void;
  55392. /**
  55393. * @hidden Internal
  55394. */
  55395. _updateEffects(): void;
  55396. /**
  55397. * Internal
  55398. * @returns if all the contained post processes are ready.
  55399. * @hidden
  55400. */
  55401. _isReady(): boolean;
  55402. }
  55403. }
  55404. declare module "babylonjs/Shaders/displayPass.fragment" {
  55405. /** @hidden */
  55406. export var displayPassPixelShader: {
  55407. name: string;
  55408. shader: string;
  55409. };
  55410. }
  55411. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  55412. import { Nullable } from "babylonjs/types";
  55413. import { Camera } from "babylonjs/Cameras/camera";
  55414. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55415. import { Engine } from "babylonjs/Engines/engine";
  55416. import "babylonjs/Shaders/displayPass.fragment";
  55417. /**
  55418. * DisplayPassPostProcess which produces an output the same as it's input
  55419. */
  55420. export class DisplayPassPostProcess extends PostProcess {
  55421. /**
  55422. * Creates the DisplayPassPostProcess
  55423. * @param name The name of the effect.
  55424. * @param options The required width/height ratio to downsize to before computing the render pass.
  55425. * @param camera The camera to apply the render pass to.
  55426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55427. * @param engine The engine which the post process will be applied. (default: current engine)
  55428. * @param reusable If the post process can be reused on the same frame. (default: false)
  55429. */
  55430. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55431. }
  55432. }
  55433. declare module "babylonjs/Shaders/filter.fragment" {
  55434. /** @hidden */
  55435. export var filterPixelShader: {
  55436. name: string;
  55437. shader: string;
  55438. };
  55439. }
  55440. declare module "babylonjs/PostProcesses/filterPostProcess" {
  55441. import { Nullable } from "babylonjs/types";
  55442. import { Matrix } from "babylonjs/Maths/math";
  55443. import { Camera } from "babylonjs/Cameras/camera";
  55444. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55445. import { Engine } from "babylonjs/Engines/engine";
  55446. import "babylonjs/Shaders/filter.fragment";
  55447. /**
  55448. * Applies a kernel filter to the image
  55449. */
  55450. export class FilterPostProcess extends PostProcess {
  55451. /** The matrix to be applied to the image */
  55452. kernelMatrix: Matrix;
  55453. /**
  55454. *
  55455. * @param name The name of the effect.
  55456. * @param kernelMatrix The matrix to be applied to the image
  55457. * @param options The required width/height ratio to downsize to before computing the render pass.
  55458. * @param camera The camera to apply the render pass to.
  55459. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55460. * @param engine The engine which the post process will be applied. (default: current engine)
  55461. * @param reusable If the post process can be reused on the same frame. (default: false)
  55462. */
  55463. constructor(name: string,
  55464. /** The matrix to be applied to the image */
  55465. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55466. }
  55467. }
  55468. declare module "babylonjs/Shaders/fxaa.fragment" {
  55469. /** @hidden */
  55470. export var fxaaPixelShader: {
  55471. name: string;
  55472. shader: string;
  55473. };
  55474. }
  55475. declare module "babylonjs/Shaders/fxaa.vertex" {
  55476. /** @hidden */
  55477. export var fxaaVertexShader: {
  55478. name: string;
  55479. shader: string;
  55480. };
  55481. }
  55482. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  55483. import { Nullable } from "babylonjs/types";
  55484. import { Camera } from "babylonjs/Cameras/camera";
  55485. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55486. import { Engine } from "babylonjs/Engines/engine";
  55487. import "babylonjs/Shaders/fxaa.fragment";
  55488. import "babylonjs/Shaders/fxaa.vertex";
  55489. /**
  55490. * Fxaa post process
  55491. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55492. */
  55493. export class FxaaPostProcess extends PostProcess {
  55494. /** @hidden */
  55495. texelWidth: number;
  55496. /** @hidden */
  55497. texelHeight: number;
  55498. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55499. private _getDefines;
  55500. }
  55501. }
  55502. declare module "babylonjs/Shaders/grain.fragment" {
  55503. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55504. /** @hidden */
  55505. export var grainPixelShader: {
  55506. name: string;
  55507. shader: string;
  55508. };
  55509. }
  55510. declare module "babylonjs/PostProcesses/grainPostProcess" {
  55511. import { Nullable } from "babylonjs/types";
  55512. import { Camera } from "babylonjs/Cameras/camera";
  55513. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55514. import { Engine } from "babylonjs/Engines/engine";
  55515. import "babylonjs/Shaders/grain.fragment";
  55516. /**
  55517. * The GrainPostProcess adds noise to the image at mid luminance levels
  55518. */
  55519. export class GrainPostProcess extends PostProcess {
  55520. /**
  55521. * The intensity of the grain added (default: 30)
  55522. */
  55523. intensity: number;
  55524. /**
  55525. * If the grain should be randomized on every frame
  55526. */
  55527. animated: boolean;
  55528. /**
  55529. * Creates a new instance of @see GrainPostProcess
  55530. * @param name The name of the effect.
  55531. * @param options The required width/height ratio to downsize to before computing the render pass.
  55532. * @param camera The camera to apply the render pass to.
  55533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55534. * @param engine The engine which the post process will be applied. (default: current engine)
  55535. * @param reusable If the post process can be reused on the same frame. (default: false)
  55536. * @param textureType Type of textures used when performing the post process. (default: 0)
  55537. * @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)
  55538. */
  55539. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55540. }
  55541. }
  55542. declare module "babylonjs/Shaders/highlights.fragment" {
  55543. /** @hidden */
  55544. export var highlightsPixelShader: {
  55545. name: string;
  55546. shader: string;
  55547. };
  55548. }
  55549. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  55550. import { Nullable } from "babylonjs/types";
  55551. import { Camera } from "babylonjs/Cameras/camera";
  55552. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55553. import { Engine } from "babylonjs/Engines/engine";
  55554. import "babylonjs/Shaders/highlights.fragment";
  55555. /**
  55556. * Extracts highlights from the image
  55557. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55558. */
  55559. export class HighlightsPostProcess extends PostProcess {
  55560. /**
  55561. * Extracts highlights from the image
  55562. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55563. * @param name The name of the effect.
  55564. * @param options The required width/height ratio to downsize to before computing the render pass.
  55565. * @param camera The camera to apply the render pass to.
  55566. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55567. * @param engine The engine which the post process will be applied. (default: current engine)
  55568. * @param reusable If the post process can be reused on the same frame. (default: false)
  55569. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55570. */
  55571. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55572. }
  55573. }
  55574. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  55575. /** @hidden */
  55576. export var mrtFragmentDeclaration: {
  55577. name: string;
  55578. shader: string;
  55579. };
  55580. }
  55581. declare module "babylonjs/Shaders/geometry.fragment" {
  55582. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  55583. /** @hidden */
  55584. export var geometryPixelShader: {
  55585. name: string;
  55586. shader: string;
  55587. };
  55588. }
  55589. declare module "babylonjs/Shaders/geometry.vertex" {
  55590. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55591. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55592. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55593. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55594. /** @hidden */
  55595. export var geometryVertexShader: {
  55596. name: string;
  55597. shader: string;
  55598. };
  55599. }
  55600. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  55601. import { Matrix } from "babylonjs/Maths/math";
  55602. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55603. import { Mesh } from "babylonjs/Meshes/mesh";
  55604. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  55605. import { Effect } from "babylonjs/Materials/effect";
  55606. import { Scene } from "babylonjs/scene";
  55607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55608. import "babylonjs/Shaders/geometry.fragment";
  55609. import "babylonjs/Shaders/geometry.vertex";
  55610. /** @hidden */
  55611. interface ISavedTransformationMatrix {
  55612. world: Matrix;
  55613. viewProjection: Matrix;
  55614. }
  55615. /**
  55616. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55617. */
  55618. export class GeometryBufferRenderer {
  55619. /**
  55620. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55621. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55622. */
  55623. static readonly POSITION_TEXTURE_TYPE: number;
  55624. /**
  55625. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55626. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55627. */
  55628. static readonly VELOCITY_TEXTURE_TYPE: number;
  55629. /**
  55630. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55631. * in order to compute objects velocities when enableVelocity is set to "true"
  55632. * @hidden
  55633. */
  55634. _previousTransformationMatrices: {
  55635. [index: number]: ISavedTransformationMatrix;
  55636. };
  55637. /**
  55638. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  55639. * in order to compute objects velocities when enableVelocity is set to "true"
  55640. * @hidden
  55641. */
  55642. _previousBonesTransformationMatrices: {
  55643. [index: number]: Float32Array;
  55644. };
  55645. /**
  55646. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  55647. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  55648. */
  55649. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  55650. private _scene;
  55651. private _multiRenderTarget;
  55652. private _ratio;
  55653. private _enablePosition;
  55654. private _enableVelocity;
  55655. private _positionIndex;
  55656. private _velocityIndex;
  55657. protected _effect: Effect;
  55658. protected _cachedDefines: string;
  55659. /**
  55660. * Set the render list (meshes to be rendered) used in the G buffer.
  55661. */
  55662. renderList: Mesh[];
  55663. /**
  55664. * Gets wether or not G buffer are supported by the running hardware.
  55665. * This requires draw buffer supports
  55666. */
  55667. readonly isSupported: boolean;
  55668. /**
  55669. * Returns the index of the given texture type in the G-Buffer textures array
  55670. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55671. * @returns the index of the given texture type in the G-Buffer textures array
  55672. */
  55673. getTextureIndex(textureType: number): number;
  55674. /**
  55675. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55676. */
  55677. /**
  55678. * Sets whether or not objects positions are enabled for the G buffer.
  55679. */
  55680. enablePosition: boolean;
  55681. /**
  55682. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55683. */
  55684. /**
  55685. * Sets wether or not objects velocities are enabled for the G buffer.
  55686. */
  55687. enableVelocity: boolean;
  55688. /**
  55689. * Gets the scene associated with the buffer.
  55690. */
  55691. readonly scene: Scene;
  55692. /**
  55693. * Gets the ratio used by the buffer during its creation.
  55694. * How big is the buffer related to the main canvas.
  55695. */
  55696. readonly ratio: number;
  55697. /** @hidden */
  55698. static _SceneComponentInitialization: (scene: Scene) => void;
  55699. /**
  55700. * Creates a new G Buffer for the scene
  55701. * @param scene The scene the buffer belongs to
  55702. * @param ratio How big is the buffer related to the main canvas.
  55703. */
  55704. constructor(scene: Scene, ratio?: number);
  55705. /**
  55706. * Checks wether everything is ready to render a submesh to the G buffer.
  55707. * @param subMesh the submesh to check readiness for
  55708. * @param useInstances is the mesh drawn using instance or not
  55709. * @returns true if ready otherwise false
  55710. */
  55711. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55712. /**
  55713. * Gets the current underlying G Buffer.
  55714. * @returns the buffer
  55715. */
  55716. getGBuffer(): MultiRenderTarget;
  55717. /**
  55718. * Gets the number of samples used to render the buffer (anti aliasing).
  55719. */
  55720. /**
  55721. * Sets the number of samples used to render the buffer (anti aliasing).
  55722. */
  55723. samples: number;
  55724. /**
  55725. * Disposes the renderer and frees up associated resources.
  55726. */
  55727. dispose(): void;
  55728. protected _createRenderTargets(): void;
  55729. private _copyBonesTransformationMatrices;
  55730. }
  55731. }
  55732. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55733. import { Nullable } from "babylonjs/types";
  55734. import { Scene } from "babylonjs/scene";
  55735. import { ISceneComponent } from "babylonjs/sceneComponent";
  55736. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55737. module "babylonjs/scene" {
  55738. interface Scene {
  55739. /** @hidden (Backing field) */
  55740. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55741. /**
  55742. * Gets or Sets the current geometry buffer associated to the scene.
  55743. */
  55744. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55745. /**
  55746. * Enables a GeometryBufferRender and associates it with the scene
  55747. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55748. * @returns the GeometryBufferRenderer
  55749. */
  55750. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55751. /**
  55752. * Disables the GeometryBufferRender associated with the scene
  55753. */
  55754. disableGeometryBufferRenderer(): void;
  55755. }
  55756. }
  55757. /**
  55758. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55759. * in several rendering techniques.
  55760. */
  55761. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55762. /**
  55763. * The component name helpful to identify the component in the list of scene components.
  55764. */
  55765. readonly name: string;
  55766. /**
  55767. * The scene the component belongs to.
  55768. */
  55769. scene: Scene;
  55770. /**
  55771. * Creates a new instance of the component for the given scene
  55772. * @param scene Defines the scene to register the component in
  55773. */
  55774. constructor(scene: Scene);
  55775. /**
  55776. * Registers the component in a given scene
  55777. */
  55778. register(): void;
  55779. /**
  55780. * Rebuilds the elements related to this component in case of
  55781. * context lost for instance.
  55782. */
  55783. rebuild(): void;
  55784. /**
  55785. * Disposes the component and the associated ressources
  55786. */
  55787. dispose(): void;
  55788. private _gatherRenderTargets;
  55789. }
  55790. }
  55791. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55792. /** @hidden */
  55793. export var motionBlurPixelShader: {
  55794. name: string;
  55795. shader: string;
  55796. };
  55797. }
  55798. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55799. import { Nullable } from "babylonjs/types";
  55800. import { Camera } from "babylonjs/Cameras/camera";
  55801. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55802. import { Scene } from "babylonjs/scene";
  55803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55804. import "babylonjs/Animations/animatable";
  55805. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55806. import "babylonjs/Shaders/motionBlur.fragment";
  55807. import { Engine } from "babylonjs/Engines/engine";
  55808. /**
  55809. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55810. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55811. * As an example, all you have to do is to create the post-process:
  55812. * var mb = new BABYLON.MotionBlurPostProcess(
  55813. * 'mb', // The name of the effect.
  55814. * scene, // The scene containing the objects to blur according to their velocity.
  55815. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55816. * camera // The camera to apply the render pass to.
  55817. * );
  55818. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55819. */
  55820. export class MotionBlurPostProcess extends PostProcess {
  55821. /**
  55822. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55823. */
  55824. motionStrength: number;
  55825. /**
  55826. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55827. */
  55828. /**
  55829. * Sets the number of iterations to be used for motion blur quality
  55830. */
  55831. motionBlurSamples: number;
  55832. private _motionBlurSamples;
  55833. private _geometryBufferRenderer;
  55834. /**
  55835. * Creates a new instance MotionBlurPostProcess
  55836. * @param name The name of the effect.
  55837. * @param scene The scene containing the objects to blur according to their velocity.
  55838. * @param options The required width/height ratio to downsize to before computing the render pass.
  55839. * @param camera The camera to apply the render pass to.
  55840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55841. * @param engine The engine which the post process will be applied. (default: current engine)
  55842. * @param reusable If the post process can be reused on the same frame. (default: false)
  55843. * @param textureType Type of textures used when performing the post process. (default: 0)
  55844. * @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)
  55845. */
  55846. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55847. /**
  55848. * Excludes the given skinned mesh from computing bones velocities.
  55849. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  55850. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  55851. */
  55852. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55853. /**
  55854. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  55855. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  55856. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  55857. */
  55858. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55859. /**
  55860. * Disposes the post process.
  55861. * @param camera The camera to dispose the post process on.
  55862. */
  55863. dispose(camera?: Camera): void;
  55864. }
  55865. }
  55866. declare module "babylonjs/Shaders/refraction.fragment" {
  55867. /** @hidden */
  55868. export var refractionPixelShader: {
  55869. name: string;
  55870. shader: string;
  55871. };
  55872. }
  55873. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55874. import { Color3 } from "babylonjs/Maths/math";
  55875. import { Camera } from "babylonjs/Cameras/camera";
  55876. import { Texture } from "babylonjs/Materials/Textures/texture";
  55877. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55878. import { Engine } from "babylonjs/Engines/engine";
  55879. import "babylonjs/Shaders/refraction.fragment";
  55880. /**
  55881. * Post process which applies a refractin texture
  55882. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55883. */
  55884. export class RefractionPostProcess extends PostProcess {
  55885. /** the base color of the refraction (used to taint the rendering) */
  55886. color: Color3;
  55887. /** simulated refraction depth */
  55888. depth: number;
  55889. /** the coefficient of the base color (0 to remove base color tainting) */
  55890. colorLevel: number;
  55891. private _refTexture;
  55892. private _ownRefractionTexture;
  55893. /**
  55894. * Gets or sets the refraction texture
  55895. * Please note that you are responsible for disposing the texture if you set it manually
  55896. */
  55897. refractionTexture: Texture;
  55898. /**
  55899. * Initializes the RefractionPostProcess
  55900. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55901. * @param name The name of the effect.
  55902. * @param refractionTextureUrl Url of the refraction texture to use
  55903. * @param color the base color of the refraction (used to taint the rendering)
  55904. * @param depth simulated refraction depth
  55905. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55906. * @param camera The camera to apply the render pass to.
  55907. * @param options The required width/height ratio to downsize to before computing the render pass.
  55908. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55909. * @param engine The engine which the post process will be applied. (default: current engine)
  55910. * @param reusable If the post process can be reused on the same frame. (default: false)
  55911. */
  55912. constructor(name: string, refractionTextureUrl: string,
  55913. /** the base color of the refraction (used to taint the rendering) */
  55914. color: Color3,
  55915. /** simulated refraction depth */
  55916. depth: number,
  55917. /** the coefficient of the base color (0 to remove base color tainting) */
  55918. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55919. /**
  55920. * Disposes of the post process
  55921. * @param camera Camera to dispose post process on
  55922. */
  55923. dispose(camera: Camera): void;
  55924. }
  55925. }
  55926. declare module "babylonjs/Shaders/sharpen.fragment" {
  55927. /** @hidden */
  55928. export var sharpenPixelShader: {
  55929. name: string;
  55930. shader: string;
  55931. };
  55932. }
  55933. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55934. import { Nullable } from "babylonjs/types";
  55935. import { Camera } from "babylonjs/Cameras/camera";
  55936. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55937. import "babylonjs/Shaders/sharpen.fragment";
  55938. import { Engine } from "babylonjs/Engines/engine";
  55939. /**
  55940. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55941. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55942. */
  55943. export class SharpenPostProcess extends PostProcess {
  55944. /**
  55945. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55946. */
  55947. colorAmount: number;
  55948. /**
  55949. * How much sharpness should be applied (default: 0.3)
  55950. */
  55951. edgeAmount: number;
  55952. /**
  55953. * Creates a new instance ConvolutionPostProcess
  55954. * @param name The name of the effect.
  55955. * @param options The required width/height ratio to downsize to before computing the render pass.
  55956. * @param camera The camera to apply the render pass to.
  55957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55958. * @param engine The engine which the post process will be applied. (default: current engine)
  55959. * @param reusable If the post process can be reused on the same frame. (default: false)
  55960. * @param textureType Type of textures used when performing the post process. (default: 0)
  55961. * @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)
  55962. */
  55963. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55964. }
  55965. }
  55966. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55967. import { Nullable } from "babylonjs/types";
  55968. import { Camera } from "babylonjs/Cameras/camera";
  55969. import { Engine } from "babylonjs/Engines/engine";
  55970. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55971. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55972. /**
  55973. * PostProcessRenderPipeline
  55974. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55975. */
  55976. export class PostProcessRenderPipeline {
  55977. private engine;
  55978. private _renderEffects;
  55979. private _renderEffectsForIsolatedPass;
  55980. /**
  55981. * List of inspectable custom properties (used by the Inspector)
  55982. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55983. */
  55984. inspectableCustomProperties: IInspectable[];
  55985. /**
  55986. * @hidden
  55987. */
  55988. protected _cameras: Camera[];
  55989. /** @hidden */
  55990. _name: string;
  55991. /**
  55992. * Gets pipeline name
  55993. */
  55994. readonly name: string;
  55995. /**
  55996. * Initializes a PostProcessRenderPipeline
  55997. * @param engine engine to add the pipeline to
  55998. * @param name name of the pipeline
  55999. */
  56000. constructor(engine: Engine, name: string);
  56001. /**
  56002. * Gets the class name
  56003. * @returns "PostProcessRenderPipeline"
  56004. */
  56005. getClassName(): string;
  56006. /**
  56007. * If all the render effects in the pipeline are supported
  56008. */
  56009. readonly isSupported: boolean;
  56010. /**
  56011. * Adds an effect to the pipeline
  56012. * @param renderEffect the effect to add
  56013. */
  56014. addEffect(renderEffect: PostProcessRenderEffect): void;
  56015. /** @hidden */
  56016. _rebuild(): void;
  56017. /** @hidden */
  56018. _enableEffect(renderEffectName: string, cameras: Camera): void;
  56019. /** @hidden */
  56020. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  56021. /** @hidden */
  56022. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56023. /** @hidden */
  56024. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56025. /** @hidden */
  56026. _attachCameras(cameras: Camera, unique: boolean): void;
  56027. /** @hidden */
  56028. _attachCameras(cameras: Camera[], unique: boolean): void;
  56029. /** @hidden */
  56030. _detachCameras(cameras: Camera): void;
  56031. /** @hidden */
  56032. _detachCameras(cameras: Nullable<Camera[]>): void;
  56033. /** @hidden */
  56034. _update(): void;
  56035. /** @hidden */
  56036. _reset(): void;
  56037. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  56038. /**
  56039. * Disposes of the pipeline
  56040. */
  56041. dispose(): void;
  56042. }
  56043. }
  56044. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  56045. import { Camera } from "babylonjs/Cameras/camera";
  56046. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56047. /**
  56048. * PostProcessRenderPipelineManager class
  56049. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56050. */
  56051. export class PostProcessRenderPipelineManager {
  56052. private _renderPipelines;
  56053. /**
  56054. * Initializes a PostProcessRenderPipelineManager
  56055. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56056. */
  56057. constructor();
  56058. /**
  56059. * Gets the list of supported render pipelines
  56060. */
  56061. readonly supportedPipelines: PostProcessRenderPipeline[];
  56062. /**
  56063. * Adds a pipeline to the manager
  56064. * @param renderPipeline The pipeline to add
  56065. */
  56066. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  56067. /**
  56068. * Attaches a camera to the pipeline
  56069. * @param renderPipelineName The name of the pipeline to attach to
  56070. * @param cameras the camera to attach
  56071. * @param unique if the camera can be attached multiple times to the pipeline
  56072. */
  56073. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  56074. /**
  56075. * Detaches a camera from the pipeline
  56076. * @param renderPipelineName The name of the pipeline to detach from
  56077. * @param cameras the camera to detach
  56078. */
  56079. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  56080. /**
  56081. * Enables an effect by name on a pipeline
  56082. * @param renderPipelineName the name of the pipeline to enable the effect in
  56083. * @param renderEffectName the name of the effect to enable
  56084. * @param cameras the cameras that the effect should be enabled on
  56085. */
  56086. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56087. /**
  56088. * Disables an effect by name on a pipeline
  56089. * @param renderPipelineName the name of the pipeline to disable the effect in
  56090. * @param renderEffectName the name of the effect to disable
  56091. * @param cameras the cameras that the effect should be disabled on
  56092. */
  56093. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56094. /**
  56095. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  56096. */
  56097. update(): void;
  56098. /** @hidden */
  56099. _rebuild(): void;
  56100. /**
  56101. * Disposes of the manager and pipelines
  56102. */
  56103. dispose(): void;
  56104. }
  56105. }
  56106. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  56107. import { ISceneComponent } from "babylonjs/sceneComponent";
  56108. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56109. import { Scene } from "babylonjs/scene";
  56110. module "babylonjs/scene" {
  56111. interface Scene {
  56112. /** @hidden (Backing field) */
  56113. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56114. /**
  56115. * Gets the postprocess render pipeline manager
  56116. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56117. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56118. */
  56119. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56120. }
  56121. }
  56122. /**
  56123. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56124. */
  56125. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56126. /**
  56127. * The component name helpfull to identify the component in the list of scene components.
  56128. */
  56129. readonly name: string;
  56130. /**
  56131. * The scene the component belongs to.
  56132. */
  56133. scene: Scene;
  56134. /**
  56135. * Creates a new instance of the component for the given scene
  56136. * @param scene Defines the scene to register the component in
  56137. */
  56138. constructor(scene: Scene);
  56139. /**
  56140. * Registers the component in a given scene
  56141. */
  56142. register(): void;
  56143. /**
  56144. * Rebuilds the elements related to this component in case of
  56145. * context lost for instance.
  56146. */
  56147. rebuild(): void;
  56148. /**
  56149. * Disposes the component and the associated ressources
  56150. */
  56151. dispose(): void;
  56152. private _gatherRenderTargets;
  56153. }
  56154. }
  56155. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  56156. import { Nullable } from "babylonjs/types";
  56157. import { IAnimatable } from "babylonjs/Misc/tools";
  56158. import { Camera } from "babylonjs/Cameras/camera";
  56159. import { IDisposable } from "babylonjs/scene";
  56160. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  56161. import { Scene } from "babylonjs/scene";
  56162. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  56163. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56164. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56165. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  56166. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56167. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56168. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  56169. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56170. import { Animation } from "babylonjs/Animations/animation";
  56171. /**
  56172. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56173. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56174. */
  56175. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56176. private _scene;
  56177. private _camerasToBeAttached;
  56178. /**
  56179. * ID of the sharpen post process,
  56180. */
  56181. private readonly SharpenPostProcessId;
  56182. /**
  56183. * @ignore
  56184. * ID of the image processing post process;
  56185. */
  56186. readonly ImageProcessingPostProcessId: string;
  56187. /**
  56188. * @ignore
  56189. * ID of the Fast Approximate Anti-Aliasing post process;
  56190. */
  56191. readonly FxaaPostProcessId: string;
  56192. /**
  56193. * ID of the chromatic aberration post process,
  56194. */
  56195. private readonly ChromaticAberrationPostProcessId;
  56196. /**
  56197. * ID of the grain post process
  56198. */
  56199. private readonly GrainPostProcessId;
  56200. /**
  56201. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56202. */
  56203. sharpen: SharpenPostProcess;
  56204. private _sharpenEffect;
  56205. private bloom;
  56206. /**
  56207. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56208. */
  56209. depthOfField: DepthOfFieldEffect;
  56210. /**
  56211. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56212. */
  56213. fxaa: FxaaPostProcess;
  56214. /**
  56215. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56216. */
  56217. imageProcessing: ImageProcessingPostProcess;
  56218. /**
  56219. * Chromatic aberration post process which will shift rgb colors in the image
  56220. */
  56221. chromaticAberration: ChromaticAberrationPostProcess;
  56222. private _chromaticAberrationEffect;
  56223. /**
  56224. * Grain post process which add noise to the image
  56225. */
  56226. grain: GrainPostProcess;
  56227. private _grainEffect;
  56228. /**
  56229. * Glow post process which adds a glow to emissive areas of the image
  56230. */
  56231. private _glowLayer;
  56232. /**
  56233. * Animations which can be used to tweak settings over a period of time
  56234. */
  56235. animations: Animation[];
  56236. private _imageProcessingConfigurationObserver;
  56237. private _sharpenEnabled;
  56238. private _bloomEnabled;
  56239. private _depthOfFieldEnabled;
  56240. private _depthOfFieldBlurLevel;
  56241. private _fxaaEnabled;
  56242. private _imageProcessingEnabled;
  56243. private _defaultPipelineTextureType;
  56244. private _bloomScale;
  56245. private _chromaticAberrationEnabled;
  56246. private _grainEnabled;
  56247. private _buildAllowed;
  56248. /**
  56249. * Gets active scene
  56250. */
  56251. readonly scene: Scene;
  56252. /**
  56253. * Enable or disable the sharpen process from the pipeline
  56254. */
  56255. sharpenEnabled: boolean;
  56256. private _resizeObserver;
  56257. private _hardwareScaleLevel;
  56258. private _bloomKernel;
  56259. /**
  56260. * Specifies the size of the bloom blur kernel, relative to the final output size
  56261. */
  56262. bloomKernel: number;
  56263. /**
  56264. * Specifies the weight of the bloom in the final rendering
  56265. */
  56266. private _bloomWeight;
  56267. /**
  56268. * Specifies the luma threshold for the area that will be blurred by the bloom
  56269. */
  56270. private _bloomThreshold;
  56271. private _hdr;
  56272. /**
  56273. * The strength of the bloom.
  56274. */
  56275. bloomWeight: number;
  56276. /**
  56277. * The strength of the bloom.
  56278. */
  56279. bloomThreshold: number;
  56280. /**
  56281. * The scale of the bloom, lower value will provide better performance.
  56282. */
  56283. bloomScale: number;
  56284. /**
  56285. * Enable or disable the bloom from the pipeline
  56286. */
  56287. bloomEnabled: boolean;
  56288. private _rebuildBloom;
  56289. /**
  56290. * If the depth of field is enabled.
  56291. */
  56292. depthOfFieldEnabled: boolean;
  56293. /**
  56294. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56295. */
  56296. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56297. /**
  56298. * If the anti aliasing is enabled.
  56299. */
  56300. fxaaEnabled: boolean;
  56301. private _samples;
  56302. /**
  56303. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56304. */
  56305. samples: number;
  56306. /**
  56307. * If image processing is enabled.
  56308. */
  56309. imageProcessingEnabled: boolean;
  56310. /**
  56311. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56312. */
  56313. glowLayerEnabled: boolean;
  56314. /**
  56315. * Gets the glow layer (or null if not defined)
  56316. */
  56317. readonly glowLayer: Nullable<GlowLayer>;
  56318. /**
  56319. * Enable or disable the chromaticAberration process from the pipeline
  56320. */
  56321. chromaticAberrationEnabled: boolean;
  56322. /**
  56323. * Enable or disable the grain process from the pipeline
  56324. */
  56325. grainEnabled: boolean;
  56326. /**
  56327. * @constructor
  56328. * @param name - The rendering pipeline name (default: "")
  56329. * @param hdr - If high dynamic range textures should be used (default: true)
  56330. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56331. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56332. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56333. */
  56334. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56335. /**
  56336. * Get the class name
  56337. * @returns "DefaultRenderingPipeline"
  56338. */
  56339. getClassName(): string;
  56340. /**
  56341. * Force the compilation of the entire pipeline.
  56342. */
  56343. prepare(): void;
  56344. private _hasCleared;
  56345. private _prevPostProcess;
  56346. private _prevPrevPostProcess;
  56347. private _setAutoClearAndTextureSharing;
  56348. private _depthOfFieldSceneObserver;
  56349. private _buildPipeline;
  56350. private _disposePostProcesses;
  56351. /**
  56352. * Adds a camera to the pipeline
  56353. * @param camera the camera to be added
  56354. */
  56355. addCamera(camera: Camera): void;
  56356. /**
  56357. * Removes a camera from the pipeline
  56358. * @param camera the camera to remove
  56359. */
  56360. removeCamera(camera: Camera): void;
  56361. /**
  56362. * Dispose of the pipeline and stop all post processes
  56363. */
  56364. dispose(): void;
  56365. /**
  56366. * Serialize the rendering pipeline (Used when exporting)
  56367. * @returns the serialized object
  56368. */
  56369. serialize(): any;
  56370. /**
  56371. * Parse the serialized pipeline
  56372. * @param source Source pipeline.
  56373. * @param scene The scene to load the pipeline to.
  56374. * @param rootUrl The URL of the serialized pipeline.
  56375. * @returns An instantiated pipeline from the serialized object.
  56376. */
  56377. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56378. }
  56379. }
  56380. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  56381. /** @hidden */
  56382. export var lensHighlightsPixelShader: {
  56383. name: string;
  56384. shader: string;
  56385. };
  56386. }
  56387. declare module "babylonjs/Shaders/depthOfField.fragment" {
  56388. /** @hidden */
  56389. export var depthOfFieldPixelShader: {
  56390. name: string;
  56391. shader: string;
  56392. };
  56393. }
  56394. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  56395. import { Camera } from "babylonjs/Cameras/camera";
  56396. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56397. import { Scene } from "babylonjs/scene";
  56398. import "babylonjs/Shaders/chromaticAberration.fragment";
  56399. import "babylonjs/Shaders/lensHighlights.fragment";
  56400. import "babylonjs/Shaders/depthOfField.fragment";
  56401. /**
  56402. * BABYLON.JS Chromatic Aberration GLSL Shader
  56403. * Author: Olivier Guyot
  56404. * Separates very slightly R, G and B colors on the edges of the screen
  56405. * Inspired by Francois Tarlier & Martins Upitis
  56406. */
  56407. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56408. /**
  56409. * @ignore
  56410. * The chromatic aberration PostProcess id in the pipeline
  56411. */
  56412. LensChromaticAberrationEffect: string;
  56413. /**
  56414. * @ignore
  56415. * The highlights enhancing PostProcess id in the pipeline
  56416. */
  56417. HighlightsEnhancingEffect: string;
  56418. /**
  56419. * @ignore
  56420. * The depth-of-field PostProcess id in the pipeline
  56421. */
  56422. LensDepthOfFieldEffect: string;
  56423. private _scene;
  56424. private _depthTexture;
  56425. private _grainTexture;
  56426. private _chromaticAberrationPostProcess;
  56427. private _highlightsPostProcess;
  56428. private _depthOfFieldPostProcess;
  56429. private _edgeBlur;
  56430. private _grainAmount;
  56431. private _chromaticAberration;
  56432. private _distortion;
  56433. private _highlightsGain;
  56434. private _highlightsThreshold;
  56435. private _dofDistance;
  56436. private _dofAperture;
  56437. private _dofDarken;
  56438. private _dofPentagon;
  56439. private _blurNoise;
  56440. /**
  56441. * @constructor
  56442. *
  56443. * Effect parameters are as follow:
  56444. * {
  56445. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56446. * edge_blur: number; // from 0 to x (1 for realism)
  56447. * distortion: number; // from 0 to x (1 for realism)
  56448. * grain_amount: number; // from 0 to 1
  56449. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56450. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56451. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56452. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56453. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56454. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56455. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56456. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56457. * }
  56458. * Note: if an effect parameter is unset, effect is disabled
  56459. *
  56460. * @param name The rendering pipeline name
  56461. * @param parameters - An object containing all parameters (see above)
  56462. * @param scene The scene linked to this pipeline
  56463. * @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)
  56464. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56465. */
  56466. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56467. /**
  56468. * Get the class name
  56469. * @returns "LensRenderingPipeline"
  56470. */
  56471. getClassName(): string;
  56472. /**
  56473. * Gets associated scene
  56474. */
  56475. readonly scene: Scene;
  56476. /**
  56477. * Gets or sets the edge blur
  56478. */
  56479. edgeBlur: number;
  56480. /**
  56481. * Gets or sets the grain amount
  56482. */
  56483. grainAmount: number;
  56484. /**
  56485. * Gets or sets the chromatic aberration amount
  56486. */
  56487. chromaticAberration: number;
  56488. /**
  56489. * Gets or sets the depth of field aperture
  56490. */
  56491. dofAperture: number;
  56492. /**
  56493. * Gets or sets the edge distortion
  56494. */
  56495. edgeDistortion: number;
  56496. /**
  56497. * Gets or sets the depth of field distortion
  56498. */
  56499. dofDistortion: number;
  56500. /**
  56501. * Gets or sets the darken out of focus amount
  56502. */
  56503. darkenOutOfFocus: number;
  56504. /**
  56505. * Gets or sets a boolean indicating if blur noise is enabled
  56506. */
  56507. blurNoise: boolean;
  56508. /**
  56509. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56510. */
  56511. pentagonBokeh: boolean;
  56512. /**
  56513. * Gets or sets the highlight grain amount
  56514. */
  56515. highlightsGain: number;
  56516. /**
  56517. * Gets or sets the highlight threshold
  56518. */
  56519. highlightsThreshold: number;
  56520. /**
  56521. * Sets the amount of blur at the edges
  56522. * @param amount blur amount
  56523. */
  56524. setEdgeBlur(amount: number): void;
  56525. /**
  56526. * Sets edge blur to 0
  56527. */
  56528. disableEdgeBlur(): void;
  56529. /**
  56530. * Sets the amout of grain
  56531. * @param amount Amount of grain
  56532. */
  56533. setGrainAmount(amount: number): void;
  56534. /**
  56535. * Set grain amount to 0
  56536. */
  56537. disableGrain(): void;
  56538. /**
  56539. * Sets the chromatic aberration amount
  56540. * @param amount amount of chromatic aberration
  56541. */
  56542. setChromaticAberration(amount: number): void;
  56543. /**
  56544. * Sets chromatic aberration amount to 0
  56545. */
  56546. disableChromaticAberration(): void;
  56547. /**
  56548. * Sets the EdgeDistortion amount
  56549. * @param amount amount of EdgeDistortion
  56550. */
  56551. setEdgeDistortion(amount: number): void;
  56552. /**
  56553. * Sets edge distortion to 0
  56554. */
  56555. disableEdgeDistortion(): void;
  56556. /**
  56557. * Sets the FocusDistance amount
  56558. * @param amount amount of FocusDistance
  56559. */
  56560. setFocusDistance(amount: number): void;
  56561. /**
  56562. * Disables depth of field
  56563. */
  56564. disableDepthOfField(): void;
  56565. /**
  56566. * Sets the Aperture amount
  56567. * @param amount amount of Aperture
  56568. */
  56569. setAperture(amount: number): void;
  56570. /**
  56571. * Sets the DarkenOutOfFocus amount
  56572. * @param amount amount of DarkenOutOfFocus
  56573. */
  56574. setDarkenOutOfFocus(amount: number): void;
  56575. private _pentagonBokehIsEnabled;
  56576. /**
  56577. * Creates a pentagon bokeh effect
  56578. */
  56579. enablePentagonBokeh(): void;
  56580. /**
  56581. * Disables the pentagon bokeh effect
  56582. */
  56583. disablePentagonBokeh(): void;
  56584. /**
  56585. * Enables noise blur
  56586. */
  56587. enableNoiseBlur(): void;
  56588. /**
  56589. * Disables noise blur
  56590. */
  56591. disableNoiseBlur(): void;
  56592. /**
  56593. * Sets the HighlightsGain amount
  56594. * @param amount amount of HighlightsGain
  56595. */
  56596. setHighlightsGain(amount: number): void;
  56597. /**
  56598. * Sets the HighlightsThreshold amount
  56599. * @param amount amount of HighlightsThreshold
  56600. */
  56601. setHighlightsThreshold(amount: number): void;
  56602. /**
  56603. * Disables highlights
  56604. */
  56605. disableHighlights(): void;
  56606. /**
  56607. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56608. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56609. */
  56610. dispose(disableDepthRender?: boolean): void;
  56611. private _createChromaticAberrationPostProcess;
  56612. private _createHighlightsPostProcess;
  56613. private _createDepthOfFieldPostProcess;
  56614. private _createGrainTexture;
  56615. }
  56616. }
  56617. declare module "babylonjs/Shaders/ssao2.fragment" {
  56618. /** @hidden */
  56619. export var ssao2PixelShader: {
  56620. name: string;
  56621. shader: string;
  56622. };
  56623. }
  56624. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  56625. /** @hidden */
  56626. export var ssaoCombinePixelShader: {
  56627. name: string;
  56628. shader: string;
  56629. };
  56630. }
  56631. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  56632. import { Camera } from "babylonjs/Cameras/camera";
  56633. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56634. import { Scene } from "babylonjs/scene";
  56635. import "babylonjs/Shaders/ssao2.fragment";
  56636. import "babylonjs/Shaders/ssaoCombine.fragment";
  56637. /**
  56638. * Render pipeline to produce ssao effect
  56639. */
  56640. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56641. /**
  56642. * @ignore
  56643. * The PassPostProcess id in the pipeline that contains the original scene color
  56644. */
  56645. SSAOOriginalSceneColorEffect: string;
  56646. /**
  56647. * @ignore
  56648. * The SSAO PostProcess id in the pipeline
  56649. */
  56650. SSAORenderEffect: string;
  56651. /**
  56652. * @ignore
  56653. * The horizontal blur PostProcess id in the pipeline
  56654. */
  56655. SSAOBlurHRenderEffect: string;
  56656. /**
  56657. * @ignore
  56658. * The vertical blur PostProcess id in the pipeline
  56659. */
  56660. SSAOBlurVRenderEffect: string;
  56661. /**
  56662. * @ignore
  56663. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56664. */
  56665. SSAOCombineRenderEffect: string;
  56666. /**
  56667. * The output strength of the SSAO post-process. Default value is 1.0.
  56668. */
  56669. totalStrength: number;
  56670. /**
  56671. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56672. */
  56673. maxZ: number;
  56674. /**
  56675. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56676. */
  56677. minZAspect: number;
  56678. private _samples;
  56679. /**
  56680. * Number of samples used for the SSAO calculations. Default value is 8
  56681. */
  56682. samples: number;
  56683. private _textureSamples;
  56684. /**
  56685. * Number of samples to use for antialiasing
  56686. */
  56687. textureSamples: number;
  56688. /**
  56689. * Ratio object used for SSAO ratio and blur ratio
  56690. */
  56691. private _ratio;
  56692. /**
  56693. * Dynamically generated sphere sampler.
  56694. */
  56695. private _sampleSphere;
  56696. /**
  56697. * Blur filter offsets
  56698. */
  56699. private _samplerOffsets;
  56700. private _expensiveBlur;
  56701. /**
  56702. * If bilateral blur should be used
  56703. */
  56704. expensiveBlur: boolean;
  56705. /**
  56706. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56707. */
  56708. radius: number;
  56709. /**
  56710. * The base color of the SSAO post-process
  56711. * The final result is "base + ssao" between [0, 1]
  56712. */
  56713. base: number;
  56714. /**
  56715. * Support test.
  56716. */
  56717. static readonly IsSupported: boolean;
  56718. private _scene;
  56719. private _depthTexture;
  56720. private _normalTexture;
  56721. private _randomTexture;
  56722. private _originalColorPostProcess;
  56723. private _ssaoPostProcess;
  56724. private _blurHPostProcess;
  56725. private _blurVPostProcess;
  56726. private _ssaoCombinePostProcess;
  56727. private _firstUpdate;
  56728. /**
  56729. * Gets active scene
  56730. */
  56731. readonly scene: Scene;
  56732. /**
  56733. * @constructor
  56734. * @param name The rendering pipeline name
  56735. * @param scene The scene linked to this pipeline
  56736. * @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 }
  56737. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56738. */
  56739. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56740. /**
  56741. * Get the class name
  56742. * @returns "SSAO2RenderingPipeline"
  56743. */
  56744. getClassName(): string;
  56745. /**
  56746. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56747. */
  56748. dispose(disableGeometryBufferRenderer?: boolean): void;
  56749. private _createBlurPostProcess;
  56750. /** @hidden */
  56751. _rebuild(): void;
  56752. private _bits;
  56753. private _radicalInverse_VdC;
  56754. private _hammersley;
  56755. private _hemisphereSample_uniform;
  56756. private _generateHemisphere;
  56757. private _createSSAOPostProcess;
  56758. private _createSSAOCombinePostProcess;
  56759. private _createRandomTexture;
  56760. /**
  56761. * Serialize the rendering pipeline (Used when exporting)
  56762. * @returns the serialized object
  56763. */
  56764. serialize(): any;
  56765. /**
  56766. * Parse the serialized pipeline
  56767. * @param source Source pipeline.
  56768. * @param scene The scene to load the pipeline to.
  56769. * @param rootUrl The URL of the serialized pipeline.
  56770. * @returns An instantiated pipeline from the serialized object.
  56771. */
  56772. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56773. }
  56774. }
  56775. declare module "babylonjs/Shaders/ssao.fragment" {
  56776. /** @hidden */
  56777. export var ssaoPixelShader: {
  56778. name: string;
  56779. shader: string;
  56780. };
  56781. }
  56782. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56783. import { Camera } from "babylonjs/Cameras/camera";
  56784. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56785. import { Scene } from "babylonjs/scene";
  56786. import "babylonjs/Shaders/ssao.fragment";
  56787. import "babylonjs/Shaders/ssaoCombine.fragment";
  56788. /**
  56789. * Render pipeline to produce ssao effect
  56790. */
  56791. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56792. /**
  56793. * @ignore
  56794. * The PassPostProcess id in the pipeline that contains the original scene color
  56795. */
  56796. SSAOOriginalSceneColorEffect: string;
  56797. /**
  56798. * @ignore
  56799. * The SSAO PostProcess id in the pipeline
  56800. */
  56801. SSAORenderEffect: string;
  56802. /**
  56803. * @ignore
  56804. * The horizontal blur PostProcess id in the pipeline
  56805. */
  56806. SSAOBlurHRenderEffect: string;
  56807. /**
  56808. * @ignore
  56809. * The vertical blur PostProcess id in the pipeline
  56810. */
  56811. SSAOBlurVRenderEffect: string;
  56812. /**
  56813. * @ignore
  56814. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56815. */
  56816. SSAOCombineRenderEffect: string;
  56817. /**
  56818. * The output strength of the SSAO post-process. Default value is 1.0.
  56819. */
  56820. totalStrength: number;
  56821. /**
  56822. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56823. */
  56824. radius: number;
  56825. /**
  56826. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56827. * Must not be equal to fallOff and superior to fallOff.
  56828. * Default value is 0.0075
  56829. */
  56830. area: number;
  56831. /**
  56832. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56833. * Must not be equal to area and inferior to area.
  56834. * Default value is 0.000001
  56835. */
  56836. fallOff: number;
  56837. /**
  56838. * The base color of the SSAO post-process
  56839. * The final result is "base + ssao" between [0, 1]
  56840. */
  56841. base: number;
  56842. private _scene;
  56843. private _depthTexture;
  56844. private _randomTexture;
  56845. private _originalColorPostProcess;
  56846. private _ssaoPostProcess;
  56847. private _blurHPostProcess;
  56848. private _blurVPostProcess;
  56849. private _ssaoCombinePostProcess;
  56850. private _firstUpdate;
  56851. /**
  56852. * Gets active scene
  56853. */
  56854. readonly scene: Scene;
  56855. /**
  56856. * @constructor
  56857. * @param name - The rendering pipeline name
  56858. * @param scene - The scene linked to this pipeline
  56859. * @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 }
  56860. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56861. */
  56862. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56863. /**
  56864. * Get the class name
  56865. * @returns "SSAORenderingPipeline"
  56866. */
  56867. getClassName(): string;
  56868. /**
  56869. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56870. */
  56871. dispose(disableDepthRender?: boolean): void;
  56872. private _createBlurPostProcess;
  56873. /** @hidden */
  56874. _rebuild(): void;
  56875. private _createSSAOPostProcess;
  56876. private _createSSAOCombinePostProcess;
  56877. private _createRandomTexture;
  56878. }
  56879. }
  56880. declare module "babylonjs/Shaders/standard.fragment" {
  56881. /** @hidden */
  56882. export var standardPixelShader: {
  56883. name: string;
  56884. shader: string;
  56885. };
  56886. }
  56887. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56888. import { Nullable } from "babylonjs/types";
  56889. import { IAnimatable } from "babylonjs/Misc/tools";
  56890. import { Camera } from "babylonjs/Cameras/camera";
  56891. import { Texture } from "babylonjs/Materials/Textures/texture";
  56892. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56893. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56894. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56895. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56896. import { IDisposable } from "babylonjs/scene";
  56897. import { SpotLight } from "babylonjs/Lights/spotLight";
  56898. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56899. import { Scene } from "babylonjs/scene";
  56900. import { Animation } from "babylonjs/Animations/animation";
  56901. import "babylonjs/Shaders/standard.fragment";
  56902. /**
  56903. * Standard rendering pipeline
  56904. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56905. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56906. */
  56907. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56908. /**
  56909. * Public members
  56910. */
  56911. /**
  56912. * Post-process which contains the original scene color before the pipeline applies all the effects
  56913. */
  56914. originalPostProcess: Nullable<PostProcess>;
  56915. /**
  56916. * Post-process used to down scale an image x4
  56917. */
  56918. downSampleX4PostProcess: Nullable<PostProcess>;
  56919. /**
  56920. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56921. */
  56922. brightPassPostProcess: Nullable<PostProcess>;
  56923. /**
  56924. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56925. */
  56926. blurHPostProcesses: PostProcess[];
  56927. /**
  56928. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56929. */
  56930. blurVPostProcesses: PostProcess[];
  56931. /**
  56932. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56933. */
  56934. textureAdderPostProcess: Nullable<PostProcess>;
  56935. /**
  56936. * Post-process used to create volumetric lighting effect
  56937. */
  56938. volumetricLightPostProcess: Nullable<PostProcess>;
  56939. /**
  56940. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56941. */
  56942. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56943. /**
  56944. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56945. */
  56946. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56947. /**
  56948. * Post-process used to merge the volumetric light effect and the real scene color
  56949. */
  56950. volumetricLightMergePostProces: Nullable<PostProcess>;
  56951. /**
  56952. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56953. */
  56954. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56955. /**
  56956. * Base post-process used to calculate the average luminance of the final image for HDR
  56957. */
  56958. luminancePostProcess: Nullable<PostProcess>;
  56959. /**
  56960. * Post-processes used to create down sample post-processes in order to get
  56961. * the average luminance of the final image for HDR
  56962. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56963. */
  56964. luminanceDownSamplePostProcesses: PostProcess[];
  56965. /**
  56966. * Post-process used to create a HDR effect (light adaptation)
  56967. */
  56968. hdrPostProcess: Nullable<PostProcess>;
  56969. /**
  56970. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56971. */
  56972. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56973. /**
  56974. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56975. */
  56976. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56977. /**
  56978. * Post-process used to merge the final HDR post-process and the real scene color
  56979. */
  56980. hdrFinalPostProcess: Nullable<PostProcess>;
  56981. /**
  56982. * Post-process used to create a lens flare effect
  56983. */
  56984. lensFlarePostProcess: Nullable<PostProcess>;
  56985. /**
  56986. * Post-process that merges the result of the lens flare post-process and the real scene color
  56987. */
  56988. lensFlareComposePostProcess: Nullable<PostProcess>;
  56989. /**
  56990. * Post-process used to create a motion blur effect
  56991. */
  56992. motionBlurPostProcess: Nullable<PostProcess>;
  56993. /**
  56994. * Post-process used to create a depth of field effect
  56995. */
  56996. depthOfFieldPostProcess: Nullable<PostProcess>;
  56997. /**
  56998. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56999. */
  57000. fxaaPostProcess: Nullable<FxaaPostProcess>;
  57001. /**
  57002. * Represents the brightness threshold in order to configure the illuminated surfaces
  57003. */
  57004. brightThreshold: number;
  57005. /**
  57006. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  57007. */
  57008. blurWidth: number;
  57009. /**
  57010. * Sets if the blur for highlighted surfaces must be only horizontal
  57011. */
  57012. horizontalBlur: boolean;
  57013. /**
  57014. * Gets the overall exposure used by the pipeline
  57015. */
  57016. /**
  57017. * Sets the overall exposure used by the pipeline
  57018. */
  57019. exposure: number;
  57020. /**
  57021. * Texture used typically to simulate "dirty" on camera lens
  57022. */
  57023. lensTexture: Nullable<Texture>;
  57024. /**
  57025. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  57026. */
  57027. volumetricLightCoefficient: number;
  57028. /**
  57029. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  57030. */
  57031. volumetricLightPower: number;
  57032. /**
  57033. * Used the set the blur intensity to smooth the volumetric lights
  57034. */
  57035. volumetricLightBlurScale: number;
  57036. /**
  57037. * Light (spot or directional) used to generate the volumetric lights rays
  57038. * The source light must have a shadow generate so the pipeline can get its
  57039. * depth map
  57040. */
  57041. sourceLight: Nullable<SpotLight | DirectionalLight>;
  57042. /**
  57043. * For eye adaptation, represents the minimum luminance the eye can see
  57044. */
  57045. hdrMinimumLuminance: number;
  57046. /**
  57047. * For eye adaptation, represents the decrease luminance speed
  57048. */
  57049. hdrDecreaseRate: number;
  57050. /**
  57051. * For eye adaptation, represents the increase luminance speed
  57052. */
  57053. hdrIncreaseRate: number;
  57054. /**
  57055. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57056. */
  57057. /**
  57058. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57059. */
  57060. hdrAutoExposure: boolean;
  57061. /**
  57062. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  57063. */
  57064. lensColorTexture: Nullable<Texture>;
  57065. /**
  57066. * The overall strengh for the lens flare effect
  57067. */
  57068. lensFlareStrength: number;
  57069. /**
  57070. * Dispersion coefficient for lens flare ghosts
  57071. */
  57072. lensFlareGhostDispersal: number;
  57073. /**
  57074. * Main lens flare halo width
  57075. */
  57076. lensFlareHaloWidth: number;
  57077. /**
  57078. * Based on the lens distortion effect, defines how much the lens flare result
  57079. * is distorted
  57080. */
  57081. lensFlareDistortionStrength: number;
  57082. /**
  57083. * Lens star texture must be used to simulate rays on the flares and is available
  57084. * in the documentation
  57085. */
  57086. lensStarTexture: Nullable<Texture>;
  57087. /**
  57088. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  57089. * flare effect by taking account of the dirt texture
  57090. */
  57091. lensFlareDirtTexture: Nullable<Texture>;
  57092. /**
  57093. * Represents the focal length for the depth of field effect
  57094. */
  57095. depthOfFieldDistance: number;
  57096. /**
  57097. * Represents the blur intensity for the blurred part of the depth of field effect
  57098. */
  57099. depthOfFieldBlurWidth: number;
  57100. /**
  57101. * For motion blur, defines how much the image is blurred by the movement
  57102. */
  57103. motionStrength: number;
  57104. /**
  57105. * List of animations for the pipeline (IAnimatable implementation)
  57106. */
  57107. animations: Animation[];
  57108. /**
  57109. * Private members
  57110. */
  57111. private _scene;
  57112. private _currentDepthOfFieldSource;
  57113. private _basePostProcess;
  57114. private _fixedExposure;
  57115. private _currentExposure;
  57116. private _hdrAutoExposure;
  57117. private _hdrCurrentLuminance;
  57118. private _floatTextureType;
  57119. private _ratio;
  57120. private _bloomEnabled;
  57121. private _depthOfFieldEnabled;
  57122. private _vlsEnabled;
  57123. private _lensFlareEnabled;
  57124. private _hdrEnabled;
  57125. private _motionBlurEnabled;
  57126. private _fxaaEnabled;
  57127. private _motionBlurSamples;
  57128. private _volumetricLightStepsCount;
  57129. private _samples;
  57130. /**
  57131. * @ignore
  57132. * Specifies if the bloom pipeline is enabled
  57133. */
  57134. BloomEnabled: boolean;
  57135. /**
  57136. * @ignore
  57137. * Specifies if the depth of field pipeline is enabed
  57138. */
  57139. DepthOfFieldEnabled: boolean;
  57140. /**
  57141. * @ignore
  57142. * Specifies if the lens flare pipeline is enabed
  57143. */
  57144. LensFlareEnabled: boolean;
  57145. /**
  57146. * @ignore
  57147. * Specifies if the HDR pipeline is enabled
  57148. */
  57149. HDREnabled: boolean;
  57150. /**
  57151. * @ignore
  57152. * Specifies if the volumetric lights scattering effect is enabled
  57153. */
  57154. VLSEnabled: boolean;
  57155. /**
  57156. * @ignore
  57157. * Specifies if the motion blur effect is enabled
  57158. */
  57159. MotionBlurEnabled: boolean;
  57160. /**
  57161. * Specifies if anti-aliasing is enabled
  57162. */
  57163. fxaaEnabled: boolean;
  57164. /**
  57165. * Specifies the number of steps used to calculate the volumetric lights
  57166. * Typically in interval [50, 200]
  57167. */
  57168. volumetricLightStepsCount: number;
  57169. /**
  57170. * Specifies the number of samples used for the motion blur effect
  57171. * Typically in interval [16, 64]
  57172. */
  57173. motionBlurSamples: number;
  57174. /**
  57175. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57176. */
  57177. samples: number;
  57178. /**
  57179. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57180. * @constructor
  57181. * @param name The rendering pipeline name
  57182. * @param scene The scene linked to this pipeline
  57183. * @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)
  57184. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57185. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57186. */
  57187. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57188. private _buildPipeline;
  57189. private _createDownSampleX4PostProcess;
  57190. private _createBrightPassPostProcess;
  57191. private _createBlurPostProcesses;
  57192. private _createTextureAdderPostProcess;
  57193. private _createVolumetricLightPostProcess;
  57194. private _createLuminancePostProcesses;
  57195. private _createHdrPostProcess;
  57196. private _createLensFlarePostProcess;
  57197. private _createDepthOfFieldPostProcess;
  57198. private _createMotionBlurPostProcess;
  57199. private _getDepthTexture;
  57200. private _disposePostProcesses;
  57201. /**
  57202. * Dispose of the pipeline and stop all post processes
  57203. */
  57204. dispose(): void;
  57205. /**
  57206. * Serialize the rendering pipeline (Used when exporting)
  57207. * @returns the serialized object
  57208. */
  57209. serialize(): any;
  57210. /**
  57211. * Parse the serialized pipeline
  57212. * @param source Source pipeline.
  57213. * @param scene The scene to load the pipeline to.
  57214. * @param rootUrl The URL of the serialized pipeline.
  57215. * @returns An instantiated pipeline from the serialized object.
  57216. */
  57217. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57218. /**
  57219. * Luminance steps
  57220. */
  57221. static LuminanceSteps: number;
  57222. }
  57223. }
  57224. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  57225. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  57226. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  57227. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  57228. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  57229. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  57230. }
  57231. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  57232. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  57233. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57234. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  57235. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  57236. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  57237. }
  57238. declare module "babylonjs/Shaders/tonemap.fragment" {
  57239. /** @hidden */
  57240. export var tonemapPixelShader: {
  57241. name: string;
  57242. shader: string;
  57243. };
  57244. }
  57245. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  57246. import { Camera } from "babylonjs/Cameras/camera";
  57247. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57248. import "babylonjs/Shaders/tonemap.fragment";
  57249. import { Engine } from "babylonjs/Engines/engine";
  57250. /** Defines operator used for tonemapping */
  57251. export enum TonemappingOperator {
  57252. /** Hable */
  57253. Hable = 0,
  57254. /** Reinhard */
  57255. Reinhard = 1,
  57256. /** HejiDawson */
  57257. HejiDawson = 2,
  57258. /** Photographic */
  57259. Photographic = 3
  57260. }
  57261. /**
  57262. * Defines a post process to apply tone mapping
  57263. */
  57264. export class TonemapPostProcess extends PostProcess {
  57265. private _operator;
  57266. /** Defines the required exposure adjustement */
  57267. exposureAdjustment: number;
  57268. /**
  57269. * Creates a new TonemapPostProcess
  57270. * @param name defines the name of the postprocess
  57271. * @param _operator defines the operator to use
  57272. * @param exposureAdjustment defines the required exposure adjustement
  57273. * @param camera defines the camera to use (can be null)
  57274. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57275. * @param engine defines the hosting engine (can be ignore if camera is set)
  57276. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57277. */
  57278. constructor(name: string, _operator: TonemappingOperator,
  57279. /** Defines the required exposure adjustement */
  57280. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57281. }
  57282. }
  57283. declare module "babylonjs/Shaders/depth.vertex" {
  57284. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57285. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57286. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57287. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57288. /** @hidden */
  57289. export var depthVertexShader: {
  57290. name: string;
  57291. shader: string;
  57292. };
  57293. }
  57294. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  57295. /** @hidden */
  57296. export var volumetricLightScatteringPixelShader: {
  57297. name: string;
  57298. shader: string;
  57299. };
  57300. }
  57301. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  57302. /** @hidden */
  57303. export var volumetricLightScatteringPassPixelShader: {
  57304. name: string;
  57305. shader: string;
  57306. };
  57307. }
  57308. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  57309. import { Vector3 } from "babylonjs/Maths/math";
  57310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57311. import { Mesh } from "babylonjs/Meshes/mesh";
  57312. import { Camera } from "babylonjs/Cameras/camera";
  57313. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57314. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57315. import { Scene } from "babylonjs/scene";
  57316. import "babylonjs/Meshes/Builders/planeBuilder";
  57317. import "babylonjs/Shaders/depth.vertex";
  57318. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  57319. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  57320. import { Engine } from "babylonjs/Engines/engine";
  57321. /**
  57322. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57323. */
  57324. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57325. private _volumetricLightScatteringPass;
  57326. private _volumetricLightScatteringRTT;
  57327. private _viewPort;
  57328. private _screenCoordinates;
  57329. private _cachedDefines;
  57330. /**
  57331. * If not undefined, the mesh position is computed from the attached node position
  57332. */
  57333. attachedNode: {
  57334. position: Vector3;
  57335. };
  57336. /**
  57337. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57338. */
  57339. customMeshPosition: Vector3;
  57340. /**
  57341. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57342. */
  57343. useCustomMeshPosition: boolean;
  57344. /**
  57345. * If the post-process should inverse the light scattering direction
  57346. */
  57347. invert: boolean;
  57348. /**
  57349. * The internal mesh used by the post-process
  57350. */
  57351. mesh: Mesh;
  57352. /**
  57353. * @hidden
  57354. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57355. */
  57356. useDiffuseColor: boolean;
  57357. /**
  57358. * Array containing the excluded meshes not rendered in the internal pass
  57359. */
  57360. excludedMeshes: AbstractMesh[];
  57361. /**
  57362. * Controls the overall intensity of the post-process
  57363. */
  57364. exposure: number;
  57365. /**
  57366. * Dissipates each sample's contribution in range [0, 1]
  57367. */
  57368. decay: number;
  57369. /**
  57370. * Controls the overall intensity of each sample
  57371. */
  57372. weight: number;
  57373. /**
  57374. * Controls the density of each sample
  57375. */
  57376. density: number;
  57377. /**
  57378. * @constructor
  57379. * @param name The post-process name
  57380. * @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)
  57381. * @param camera The camera that the post-process will be attached to
  57382. * @param mesh The mesh used to create the light scattering
  57383. * @param samples The post-process quality, default 100
  57384. * @param samplingModeThe post-process filtering mode
  57385. * @param engine The babylon engine
  57386. * @param reusable If the post-process is reusable
  57387. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57388. */
  57389. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57390. /**
  57391. * Returns the string "VolumetricLightScatteringPostProcess"
  57392. * @returns "VolumetricLightScatteringPostProcess"
  57393. */
  57394. getClassName(): string;
  57395. private _isReady;
  57396. /**
  57397. * Sets the new light position for light scattering effect
  57398. * @param position The new custom light position
  57399. */
  57400. setCustomMeshPosition(position: Vector3): void;
  57401. /**
  57402. * Returns the light position for light scattering effect
  57403. * @return Vector3 The custom light position
  57404. */
  57405. getCustomMeshPosition(): Vector3;
  57406. /**
  57407. * Disposes the internal assets and detaches the post-process from the camera
  57408. */
  57409. dispose(camera: Camera): void;
  57410. /**
  57411. * Returns the render target texture used by the post-process
  57412. * @return the render target texture used by the post-process
  57413. */
  57414. getPass(): RenderTargetTexture;
  57415. private _meshExcluded;
  57416. private _createPass;
  57417. private _updateMeshScreenCoordinates;
  57418. /**
  57419. * Creates a default mesh for the Volumeric Light Scattering post-process
  57420. * @param name The mesh name
  57421. * @param scene The scene where to create the mesh
  57422. * @return the default mesh
  57423. */
  57424. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57425. }
  57426. }
  57427. declare module "babylonjs/PostProcesses/index" {
  57428. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  57429. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  57430. export * from "babylonjs/PostProcesses/bloomEffect";
  57431. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  57432. export * from "babylonjs/PostProcesses/blurPostProcess";
  57433. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  57434. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  57435. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  57436. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  57437. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57438. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  57439. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  57440. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  57441. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57442. export * from "babylonjs/PostProcesses/filterPostProcess";
  57443. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  57444. export * from "babylonjs/PostProcesses/grainPostProcess";
  57445. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  57446. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  57447. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  57448. export * from "babylonjs/PostProcesses/passPostProcess";
  57449. export * from "babylonjs/PostProcesses/postProcess";
  57450. export * from "babylonjs/PostProcesses/postProcessManager";
  57451. export * from "babylonjs/PostProcesses/refractionPostProcess";
  57452. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  57453. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  57454. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  57455. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  57456. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  57457. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  57458. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  57459. }
  57460. declare module "babylonjs/Probes/index" {
  57461. export * from "babylonjs/Probes/reflectionProbe";
  57462. }
  57463. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  57464. import { Scene } from "babylonjs/scene";
  57465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57466. import { Color3 } from "babylonjs/Maths/math";
  57467. import { SmartArray } from "babylonjs/Misc/smartArray";
  57468. import { ISceneComponent } from "babylonjs/sceneComponent";
  57469. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  57470. import "babylonjs/Meshes/Builders/boxBuilder";
  57471. import "babylonjs/Shaders/color.fragment";
  57472. import "babylonjs/Shaders/color.vertex";
  57473. module "babylonjs/scene" {
  57474. interface Scene {
  57475. /** @hidden (Backing field) */
  57476. _boundingBoxRenderer: BoundingBoxRenderer;
  57477. /** @hidden (Backing field) */
  57478. _forceShowBoundingBoxes: boolean;
  57479. /**
  57480. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57481. */
  57482. forceShowBoundingBoxes: boolean;
  57483. /**
  57484. * Gets the bounding box renderer associated with the scene
  57485. * @returns a BoundingBoxRenderer
  57486. */
  57487. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57488. }
  57489. }
  57490. module "babylonjs/Meshes/abstractMesh" {
  57491. interface AbstractMesh {
  57492. /** @hidden (Backing field) */
  57493. _showBoundingBox: boolean;
  57494. /**
  57495. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57496. */
  57497. showBoundingBox: boolean;
  57498. }
  57499. }
  57500. /**
  57501. * Component responsible of rendering the bounding box of the meshes in a scene.
  57502. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57503. */
  57504. export class BoundingBoxRenderer implements ISceneComponent {
  57505. /**
  57506. * The component name helpfull to identify the component in the list of scene components.
  57507. */
  57508. readonly name: string;
  57509. /**
  57510. * The scene the component belongs to.
  57511. */
  57512. scene: Scene;
  57513. /**
  57514. * Color of the bounding box lines placed in front of an object
  57515. */
  57516. frontColor: Color3;
  57517. /**
  57518. * Color of the bounding box lines placed behind an object
  57519. */
  57520. backColor: Color3;
  57521. /**
  57522. * Defines if the renderer should show the back lines or not
  57523. */
  57524. showBackLines: boolean;
  57525. /**
  57526. * @hidden
  57527. */
  57528. renderList: SmartArray<BoundingBox>;
  57529. private _colorShader;
  57530. private _vertexBuffers;
  57531. private _indexBuffer;
  57532. /**
  57533. * Instantiates a new bounding box renderer in a scene.
  57534. * @param scene the scene the renderer renders in
  57535. */
  57536. constructor(scene: Scene);
  57537. /**
  57538. * Registers the component in a given scene
  57539. */
  57540. register(): void;
  57541. private _evaluateSubMesh;
  57542. private _activeMesh;
  57543. private _prepareRessources;
  57544. private _createIndexBuffer;
  57545. /**
  57546. * Rebuilds the elements related to this component in case of
  57547. * context lost for instance.
  57548. */
  57549. rebuild(): void;
  57550. /**
  57551. * @hidden
  57552. */
  57553. reset(): void;
  57554. /**
  57555. * Render the bounding boxes of a specific rendering group
  57556. * @param renderingGroupId defines the rendering group to render
  57557. */
  57558. render(renderingGroupId: number): void;
  57559. /**
  57560. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57561. * @param mesh Define the mesh to render the occlusion bounding box for
  57562. */
  57563. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57564. /**
  57565. * Dispose and release the resources attached to this renderer.
  57566. */
  57567. dispose(): void;
  57568. }
  57569. }
  57570. declare module "babylonjs/Shaders/depth.fragment" {
  57571. /** @hidden */
  57572. export var depthPixelShader: {
  57573. name: string;
  57574. shader: string;
  57575. };
  57576. }
  57577. declare module "babylonjs/Rendering/depthRenderer" {
  57578. import { Nullable } from "babylonjs/types";
  57579. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57580. import { Scene } from "babylonjs/scene";
  57581. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57582. import { Camera } from "babylonjs/Cameras/camera";
  57583. import "babylonjs/Shaders/depth.fragment";
  57584. import "babylonjs/Shaders/depth.vertex";
  57585. /**
  57586. * This represents a depth renderer in Babylon.
  57587. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57588. */
  57589. export class DepthRenderer {
  57590. private _scene;
  57591. private _depthMap;
  57592. private _effect;
  57593. private _cachedDefines;
  57594. private _camera;
  57595. /**
  57596. * Specifiess that the depth renderer will only be used within
  57597. * the camera it is created for.
  57598. * This can help forcing its rendering during the camera processing.
  57599. */
  57600. useOnlyInActiveCamera: boolean;
  57601. /** @hidden */
  57602. static _SceneComponentInitialization: (scene: Scene) => void;
  57603. /**
  57604. * Instantiates a depth renderer
  57605. * @param scene The scene the renderer belongs to
  57606. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57607. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57608. */
  57609. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57610. /**
  57611. * Creates the depth rendering effect and checks if the effect is ready.
  57612. * @param subMesh The submesh to be used to render the depth map of
  57613. * @param useInstances If multiple world instances should be used
  57614. * @returns if the depth renderer is ready to render the depth map
  57615. */
  57616. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57617. /**
  57618. * Gets the texture which the depth map will be written to.
  57619. * @returns The depth map texture
  57620. */
  57621. getDepthMap(): RenderTargetTexture;
  57622. /**
  57623. * Disposes of the depth renderer.
  57624. */
  57625. dispose(): void;
  57626. }
  57627. }
  57628. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  57629. import { Nullable } from "babylonjs/types";
  57630. import { Scene } from "babylonjs/scene";
  57631. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57632. import { Camera } from "babylonjs/Cameras/camera";
  57633. import { ISceneComponent } from "babylonjs/sceneComponent";
  57634. module "babylonjs/scene" {
  57635. interface Scene {
  57636. /** @hidden (Backing field) */
  57637. _depthRenderer: {
  57638. [id: string]: DepthRenderer;
  57639. };
  57640. /**
  57641. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57642. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57643. * @returns the created depth renderer
  57644. */
  57645. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57646. /**
  57647. * Disables a depth renderer for a given camera
  57648. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57649. */
  57650. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57651. }
  57652. }
  57653. /**
  57654. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57655. * in several rendering techniques.
  57656. */
  57657. export class DepthRendererSceneComponent implements ISceneComponent {
  57658. /**
  57659. * The component name helpfull to identify the component in the list of scene components.
  57660. */
  57661. readonly name: string;
  57662. /**
  57663. * The scene the component belongs to.
  57664. */
  57665. scene: Scene;
  57666. /**
  57667. * Creates a new instance of the component for the given scene
  57668. * @param scene Defines the scene to register the component in
  57669. */
  57670. constructor(scene: Scene);
  57671. /**
  57672. * Registers the component in a given scene
  57673. */
  57674. register(): void;
  57675. /**
  57676. * Rebuilds the elements related to this component in case of
  57677. * context lost for instance.
  57678. */
  57679. rebuild(): void;
  57680. /**
  57681. * Disposes the component and the associated ressources
  57682. */
  57683. dispose(): void;
  57684. private _gatherRenderTargets;
  57685. private _gatherActiveCameraRenderTargets;
  57686. }
  57687. }
  57688. declare module "babylonjs/Shaders/outline.fragment" {
  57689. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57690. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57691. /** @hidden */
  57692. export var outlinePixelShader: {
  57693. name: string;
  57694. shader: string;
  57695. };
  57696. }
  57697. declare module "babylonjs/Shaders/outline.vertex" {
  57698. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57699. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57700. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57701. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57702. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57703. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57704. /** @hidden */
  57705. export var outlineVertexShader: {
  57706. name: string;
  57707. shader: string;
  57708. };
  57709. }
  57710. declare module "babylonjs/Rendering/outlineRenderer" {
  57711. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57712. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57713. import { Scene } from "babylonjs/scene";
  57714. import { ISceneComponent } from "babylonjs/sceneComponent";
  57715. import "babylonjs/Shaders/outline.fragment";
  57716. import "babylonjs/Shaders/outline.vertex";
  57717. module "babylonjs/scene" {
  57718. interface Scene {
  57719. /** @hidden */
  57720. _outlineRenderer: OutlineRenderer;
  57721. /**
  57722. * Gets the outline renderer associated with the scene
  57723. * @returns a OutlineRenderer
  57724. */
  57725. getOutlineRenderer(): OutlineRenderer;
  57726. }
  57727. }
  57728. module "babylonjs/Meshes/abstractMesh" {
  57729. interface AbstractMesh {
  57730. /** @hidden (Backing field) */
  57731. _renderOutline: boolean;
  57732. /**
  57733. * Gets or sets a boolean indicating if the outline must be rendered as well
  57734. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57735. */
  57736. renderOutline: boolean;
  57737. /** @hidden (Backing field) */
  57738. _renderOverlay: boolean;
  57739. /**
  57740. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57741. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57742. */
  57743. renderOverlay: boolean;
  57744. }
  57745. }
  57746. /**
  57747. * This class is responsible to draw bothe outline/overlay of meshes.
  57748. * It should not be used directly but through the available method on mesh.
  57749. */
  57750. export class OutlineRenderer implements ISceneComponent {
  57751. /**
  57752. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57753. */
  57754. private static _StencilReference;
  57755. /**
  57756. * The name of the component. Each component must have a unique name.
  57757. */
  57758. name: string;
  57759. /**
  57760. * The scene the component belongs to.
  57761. */
  57762. scene: Scene;
  57763. /**
  57764. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57765. */
  57766. zOffset: number;
  57767. private _engine;
  57768. private _effect;
  57769. private _cachedDefines;
  57770. private _savedDepthWrite;
  57771. /**
  57772. * Instantiates a new outline renderer. (There could be only one per scene).
  57773. * @param scene Defines the scene it belongs to
  57774. */
  57775. constructor(scene: Scene);
  57776. /**
  57777. * Register the component to one instance of a scene.
  57778. */
  57779. register(): void;
  57780. /**
  57781. * Rebuilds the elements related to this component in case of
  57782. * context lost for instance.
  57783. */
  57784. rebuild(): void;
  57785. /**
  57786. * Disposes the component and the associated ressources.
  57787. */
  57788. dispose(): void;
  57789. /**
  57790. * Renders the outline in the canvas.
  57791. * @param subMesh Defines the sumesh to render
  57792. * @param batch Defines the batch of meshes in case of instances
  57793. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57794. */
  57795. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57796. /**
  57797. * Returns whether or not the outline renderer is ready for a given submesh.
  57798. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57799. * @param subMesh Defines the submesh to check readyness for
  57800. * @param useInstances Defines wheter wee are trying to render instances or not
  57801. * @returns true if ready otherwise false
  57802. */
  57803. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57804. private _beforeRenderingMesh;
  57805. private _afterRenderingMesh;
  57806. }
  57807. }
  57808. declare module "babylonjs/Rendering/index" {
  57809. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57810. export * from "babylonjs/Rendering/depthRenderer";
  57811. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57812. export * from "babylonjs/Rendering/edgesRenderer";
  57813. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57814. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57815. export * from "babylonjs/Rendering/outlineRenderer";
  57816. export * from "babylonjs/Rendering/renderingGroup";
  57817. export * from "babylonjs/Rendering/renderingManager";
  57818. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57819. }
  57820. declare module "babylonjs/Sprites/index" {
  57821. export * from "babylonjs/Sprites/sprite";
  57822. export * from "babylonjs/Sprites/spriteManager";
  57823. export * from "babylonjs/Sprites/spriteSceneComponent";
  57824. }
  57825. declare module "babylonjs/Misc/assetsManager" {
  57826. import { Scene } from "babylonjs/scene";
  57827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57828. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57829. import { Skeleton } from "babylonjs/Bones/skeleton";
  57830. import { Observable } from "babylonjs/Misc/observable";
  57831. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57832. import { Texture } from "babylonjs/Materials/Textures/texture";
  57833. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57834. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57835. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57836. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57837. /**
  57838. * Defines the list of states available for a task inside a AssetsManager
  57839. */
  57840. export enum AssetTaskState {
  57841. /**
  57842. * Initialization
  57843. */
  57844. INIT = 0,
  57845. /**
  57846. * Running
  57847. */
  57848. RUNNING = 1,
  57849. /**
  57850. * Done
  57851. */
  57852. DONE = 2,
  57853. /**
  57854. * Error
  57855. */
  57856. ERROR = 3
  57857. }
  57858. /**
  57859. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57860. */
  57861. export abstract class AbstractAssetTask {
  57862. /**
  57863. * Task name
  57864. */ name: string;
  57865. /**
  57866. * Callback called when the task is successful
  57867. */
  57868. onSuccess: (task: any) => void;
  57869. /**
  57870. * Callback called when the task is not successful
  57871. */
  57872. onError: (task: any, message?: string, exception?: any) => void;
  57873. /**
  57874. * Creates a new AssetsManager
  57875. * @param name defines the name of the task
  57876. */
  57877. constructor(
  57878. /**
  57879. * Task name
  57880. */ name: string);
  57881. private _isCompleted;
  57882. private _taskState;
  57883. private _errorObject;
  57884. /**
  57885. * Get if the task is completed
  57886. */
  57887. readonly isCompleted: boolean;
  57888. /**
  57889. * Gets the current state of the task
  57890. */
  57891. readonly taskState: AssetTaskState;
  57892. /**
  57893. * Gets the current error object (if task is in error)
  57894. */
  57895. readonly errorObject: {
  57896. message?: string;
  57897. exception?: any;
  57898. };
  57899. /**
  57900. * Internal only
  57901. * @hidden
  57902. */
  57903. _setErrorObject(message?: string, exception?: any): void;
  57904. /**
  57905. * Execute the current task
  57906. * @param scene defines the scene where you want your assets to be loaded
  57907. * @param onSuccess is a callback called when the task is successfully executed
  57908. * @param onError is a callback called if an error occurs
  57909. */
  57910. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57911. /**
  57912. * Execute the current task
  57913. * @param scene defines the scene where you want your assets to be loaded
  57914. * @param onSuccess is a callback called when the task is successfully executed
  57915. * @param onError is a callback called if an error occurs
  57916. */
  57917. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57918. /**
  57919. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57920. * This can be used with failed tasks that have the reason for failure fixed.
  57921. */
  57922. reset(): void;
  57923. private onErrorCallback;
  57924. private onDoneCallback;
  57925. }
  57926. /**
  57927. * Define the interface used by progress events raised during assets loading
  57928. */
  57929. export interface IAssetsProgressEvent {
  57930. /**
  57931. * Defines the number of remaining tasks to process
  57932. */
  57933. remainingCount: number;
  57934. /**
  57935. * Defines the total number of tasks
  57936. */
  57937. totalCount: number;
  57938. /**
  57939. * Defines the task that was just processed
  57940. */
  57941. task: AbstractAssetTask;
  57942. }
  57943. /**
  57944. * Class used to share progress information about assets loading
  57945. */
  57946. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57947. /**
  57948. * Defines the number of remaining tasks to process
  57949. */
  57950. remainingCount: number;
  57951. /**
  57952. * Defines the total number of tasks
  57953. */
  57954. totalCount: number;
  57955. /**
  57956. * Defines the task that was just processed
  57957. */
  57958. task: AbstractAssetTask;
  57959. /**
  57960. * Creates a AssetsProgressEvent
  57961. * @param remainingCount defines the number of remaining tasks to process
  57962. * @param totalCount defines the total number of tasks
  57963. * @param task defines the task that was just processed
  57964. */
  57965. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57966. }
  57967. /**
  57968. * Define a task used by AssetsManager to load meshes
  57969. */
  57970. export class MeshAssetTask extends AbstractAssetTask {
  57971. /**
  57972. * Defines the name of the task
  57973. */
  57974. name: string;
  57975. /**
  57976. * Defines the list of mesh's names you want to load
  57977. */
  57978. meshesNames: any;
  57979. /**
  57980. * Defines the root url to use as a base to load your meshes and associated resources
  57981. */
  57982. rootUrl: string;
  57983. /**
  57984. * Defines the filename of the scene to load from
  57985. */
  57986. sceneFilename: string;
  57987. /**
  57988. * Gets the list of loaded meshes
  57989. */
  57990. loadedMeshes: Array<AbstractMesh>;
  57991. /**
  57992. * Gets the list of loaded particle systems
  57993. */
  57994. loadedParticleSystems: Array<IParticleSystem>;
  57995. /**
  57996. * Gets the list of loaded skeletons
  57997. */
  57998. loadedSkeletons: Array<Skeleton>;
  57999. /**
  58000. * Gets the list of loaded animation groups
  58001. */
  58002. loadedAnimationGroups: Array<AnimationGroup>;
  58003. /**
  58004. * Callback called when the task is successful
  58005. */
  58006. onSuccess: (task: MeshAssetTask) => void;
  58007. /**
  58008. * Callback called when the task is successful
  58009. */
  58010. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  58011. /**
  58012. * Creates a new MeshAssetTask
  58013. * @param name defines the name of the task
  58014. * @param meshesNames defines the list of mesh's names you want to load
  58015. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  58016. * @param sceneFilename defines the filename of the scene to load from
  58017. */
  58018. constructor(
  58019. /**
  58020. * Defines the name of the task
  58021. */
  58022. name: string,
  58023. /**
  58024. * Defines the list of mesh's names you want to load
  58025. */
  58026. meshesNames: any,
  58027. /**
  58028. * Defines the root url to use as a base to load your meshes and associated resources
  58029. */
  58030. rootUrl: string,
  58031. /**
  58032. * Defines the filename of the scene to load from
  58033. */
  58034. sceneFilename: string);
  58035. /**
  58036. * Execute the current task
  58037. * @param scene defines the scene where you want your assets to be loaded
  58038. * @param onSuccess is a callback called when the task is successfully executed
  58039. * @param onError is a callback called if an error occurs
  58040. */
  58041. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58042. }
  58043. /**
  58044. * Define a task used by AssetsManager to load text content
  58045. */
  58046. export class TextFileAssetTask extends AbstractAssetTask {
  58047. /**
  58048. * Defines the name of the task
  58049. */
  58050. name: string;
  58051. /**
  58052. * Defines the location of the file to load
  58053. */
  58054. url: string;
  58055. /**
  58056. * Gets the loaded text string
  58057. */
  58058. text: string;
  58059. /**
  58060. * Callback called when the task is successful
  58061. */
  58062. onSuccess: (task: TextFileAssetTask) => void;
  58063. /**
  58064. * Callback called when the task is successful
  58065. */
  58066. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  58067. /**
  58068. * Creates a new TextFileAssetTask object
  58069. * @param name defines the name of the task
  58070. * @param url defines the location of the file to load
  58071. */
  58072. constructor(
  58073. /**
  58074. * Defines the name of the task
  58075. */
  58076. name: string,
  58077. /**
  58078. * Defines the location of the file to load
  58079. */
  58080. url: string);
  58081. /**
  58082. * Execute the current task
  58083. * @param scene defines the scene where you want your assets to be loaded
  58084. * @param onSuccess is a callback called when the task is successfully executed
  58085. * @param onError is a callback called if an error occurs
  58086. */
  58087. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58088. }
  58089. /**
  58090. * Define a task used by AssetsManager to load binary data
  58091. */
  58092. export class BinaryFileAssetTask extends AbstractAssetTask {
  58093. /**
  58094. * Defines the name of the task
  58095. */
  58096. name: string;
  58097. /**
  58098. * Defines the location of the file to load
  58099. */
  58100. url: string;
  58101. /**
  58102. * Gets the lodaded data (as an array buffer)
  58103. */
  58104. data: ArrayBuffer;
  58105. /**
  58106. * Callback called when the task is successful
  58107. */
  58108. onSuccess: (task: BinaryFileAssetTask) => void;
  58109. /**
  58110. * Callback called when the task is successful
  58111. */
  58112. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  58113. /**
  58114. * Creates a new BinaryFileAssetTask object
  58115. * @param name defines the name of the new task
  58116. * @param url defines the location of the file to load
  58117. */
  58118. constructor(
  58119. /**
  58120. * Defines the name of the task
  58121. */
  58122. name: string,
  58123. /**
  58124. * Defines the location of the file to load
  58125. */
  58126. url: string);
  58127. /**
  58128. * Execute the current task
  58129. * @param scene defines the scene where you want your assets to be loaded
  58130. * @param onSuccess is a callback called when the task is successfully executed
  58131. * @param onError is a callback called if an error occurs
  58132. */
  58133. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58134. }
  58135. /**
  58136. * Define a task used by AssetsManager to load images
  58137. */
  58138. export class ImageAssetTask extends AbstractAssetTask {
  58139. /**
  58140. * Defines the name of the task
  58141. */
  58142. name: string;
  58143. /**
  58144. * Defines the location of the image to load
  58145. */
  58146. url: string;
  58147. /**
  58148. * Gets the loaded images
  58149. */
  58150. image: HTMLImageElement;
  58151. /**
  58152. * Callback called when the task is successful
  58153. */
  58154. onSuccess: (task: ImageAssetTask) => void;
  58155. /**
  58156. * Callback called when the task is successful
  58157. */
  58158. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58159. /**
  58160. * Creates a new ImageAssetTask
  58161. * @param name defines the name of the task
  58162. * @param url defines the location of the image to load
  58163. */
  58164. constructor(
  58165. /**
  58166. * Defines the name of the task
  58167. */
  58168. name: string,
  58169. /**
  58170. * Defines the location of the image to load
  58171. */
  58172. url: string);
  58173. /**
  58174. * Execute the current task
  58175. * @param scene defines the scene where you want your assets to be loaded
  58176. * @param onSuccess is a callback called when the task is successfully executed
  58177. * @param onError is a callback called if an error occurs
  58178. */
  58179. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58180. }
  58181. /**
  58182. * Defines the interface used by texture loading tasks
  58183. */
  58184. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58185. /**
  58186. * Gets the loaded texture
  58187. */
  58188. texture: TEX;
  58189. }
  58190. /**
  58191. * Define a task used by AssetsManager to load 2D textures
  58192. */
  58193. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58194. /**
  58195. * Defines the name of the task
  58196. */
  58197. name: string;
  58198. /**
  58199. * Defines the location of the file to load
  58200. */
  58201. url: string;
  58202. /**
  58203. * Defines if mipmap should not be generated (default is false)
  58204. */
  58205. noMipmap?: boolean | undefined;
  58206. /**
  58207. * Defines if texture must be inverted on Y axis (default is false)
  58208. */
  58209. invertY?: boolean | undefined;
  58210. /**
  58211. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58212. */
  58213. samplingMode: number;
  58214. /**
  58215. * Gets the loaded texture
  58216. */
  58217. texture: Texture;
  58218. /**
  58219. * Callback called when the task is successful
  58220. */
  58221. onSuccess: (task: TextureAssetTask) => void;
  58222. /**
  58223. * Callback called when the task is successful
  58224. */
  58225. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58226. /**
  58227. * Creates a new TextureAssetTask object
  58228. * @param name defines the name of the task
  58229. * @param url defines the location of the file to load
  58230. * @param noMipmap defines if mipmap should not be generated (default is false)
  58231. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58232. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58233. */
  58234. constructor(
  58235. /**
  58236. * Defines the name of the task
  58237. */
  58238. name: string,
  58239. /**
  58240. * Defines the location of the file to load
  58241. */
  58242. url: string,
  58243. /**
  58244. * Defines if mipmap should not be generated (default is false)
  58245. */
  58246. noMipmap?: boolean | undefined,
  58247. /**
  58248. * Defines if texture must be inverted on Y axis (default is false)
  58249. */
  58250. invertY?: boolean | undefined,
  58251. /**
  58252. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58253. */
  58254. samplingMode?: number);
  58255. /**
  58256. * Execute the current task
  58257. * @param scene defines the scene where you want your assets to be loaded
  58258. * @param onSuccess is a callback called when the task is successfully executed
  58259. * @param onError is a callback called if an error occurs
  58260. */
  58261. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58262. }
  58263. /**
  58264. * Define a task used by AssetsManager to load cube textures
  58265. */
  58266. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58267. /**
  58268. * Defines the name of the task
  58269. */
  58270. name: string;
  58271. /**
  58272. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58273. */
  58274. url: string;
  58275. /**
  58276. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58277. */
  58278. extensions?: string[] | undefined;
  58279. /**
  58280. * Defines if mipmaps should not be generated (default is false)
  58281. */
  58282. noMipmap?: boolean | undefined;
  58283. /**
  58284. * Defines the explicit list of files (undefined by default)
  58285. */
  58286. files?: string[] | undefined;
  58287. /**
  58288. * Gets the loaded texture
  58289. */
  58290. texture: CubeTexture;
  58291. /**
  58292. * Callback called when the task is successful
  58293. */
  58294. onSuccess: (task: CubeTextureAssetTask) => void;
  58295. /**
  58296. * Callback called when the task is successful
  58297. */
  58298. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58299. /**
  58300. * Creates a new CubeTextureAssetTask
  58301. * @param name defines the name of the task
  58302. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58303. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58304. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58305. * @param files defines the explicit list of files (undefined by default)
  58306. */
  58307. constructor(
  58308. /**
  58309. * Defines the name of the task
  58310. */
  58311. name: string,
  58312. /**
  58313. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58314. */
  58315. url: string,
  58316. /**
  58317. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58318. */
  58319. extensions?: string[] | undefined,
  58320. /**
  58321. * Defines if mipmaps should not be generated (default is false)
  58322. */
  58323. noMipmap?: boolean | undefined,
  58324. /**
  58325. * Defines the explicit list of files (undefined by default)
  58326. */
  58327. files?: string[] | undefined);
  58328. /**
  58329. * Execute the current task
  58330. * @param scene defines the scene where you want your assets to be loaded
  58331. * @param onSuccess is a callback called when the task is successfully executed
  58332. * @param onError is a callback called if an error occurs
  58333. */
  58334. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58335. }
  58336. /**
  58337. * Define a task used by AssetsManager to load HDR cube textures
  58338. */
  58339. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58340. /**
  58341. * Defines the name of the task
  58342. */
  58343. name: string;
  58344. /**
  58345. * Defines the location of the file to load
  58346. */
  58347. url: string;
  58348. /**
  58349. * Defines the desired size (the more it increases the longer the generation will be)
  58350. */
  58351. size: number;
  58352. /**
  58353. * Defines if mipmaps should not be generated (default is false)
  58354. */
  58355. noMipmap: boolean;
  58356. /**
  58357. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58358. */
  58359. generateHarmonics: boolean;
  58360. /**
  58361. * 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)
  58362. */
  58363. gammaSpace: boolean;
  58364. /**
  58365. * Internal Use Only
  58366. */
  58367. reserved: boolean;
  58368. /**
  58369. * Gets the loaded texture
  58370. */
  58371. texture: HDRCubeTexture;
  58372. /**
  58373. * Callback called when the task is successful
  58374. */
  58375. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58376. /**
  58377. * Callback called when the task is successful
  58378. */
  58379. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58380. /**
  58381. * Creates a new HDRCubeTextureAssetTask object
  58382. * @param name defines the name of the task
  58383. * @param url defines the location of the file to load
  58384. * @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.
  58385. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58386. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58387. * @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)
  58388. * @param reserved Internal use only
  58389. */
  58390. constructor(
  58391. /**
  58392. * Defines the name of the task
  58393. */
  58394. name: string,
  58395. /**
  58396. * Defines the location of the file to load
  58397. */
  58398. url: string,
  58399. /**
  58400. * Defines the desired size (the more it increases the longer the generation will be)
  58401. */
  58402. size: number,
  58403. /**
  58404. * Defines if mipmaps should not be generated (default is false)
  58405. */
  58406. noMipmap?: boolean,
  58407. /**
  58408. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58409. */
  58410. generateHarmonics?: boolean,
  58411. /**
  58412. * 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)
  58413. */
  58414. gammaSpace?: boolean,
  58415. /**
  58416. * Internal Use Only
  58417. */
  58418. reserved?: boolean);
  58419. /**
  58420. * Execute the current task
  58421. * @param scene defines the scene where you want your assets to be loaded
  58422. * @param onSuccess is a callback called when the task is successfully executed
  58423. * @param onError is a callback called if an error occurs
  58424. */
  58425. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58426. }
  58427. /**
  58428. * Define a task used by AssetsManager to load Equirectangular cube textures
  58429. */
  58430. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58431. /**
  58432. * Defines the name of the task
  58433. */
  58434. name: string;
  58435. /**
  58436. * Defines the location of the file to load
  58437. */
  58438. url: string;
  58439. /**
  58440. * Defines the desired size (the more it increases the longer the generation will be)
  58441. */
  58442. size: number;
  58443. /**
  58444. * Defines if mipmaps should not be generated (default is false)
  58445. */
  58446. noMipmap: boolean;
  58447. /**
  58448. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58449. * but the standard material would require them in Gamma space) (default is true)
  58450. */
  58451. gammaSpace: boolean;
  58452. /**
  58453. * Gets the loaded texture
  58454. */
  58455. texture: EquiRectangularCubeTexture;
  58456. /**
  58457. * Callback called when the task is successful
  58458. */
  58459. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58460. /**
  58461. * Callback called when the task is successful
  58462. */
  58463. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58464. /**
  58465. * Creates a new EquiRectangularCubeTextureAssetTask object
  58466. * @param name defines the name of the task
  58467. * @param url defines the location of the file to load
  58468. * @param size defines the desired size (the more it increases the longer the generation will be)
  58469. * If the size is omitted this implies you are using a preprocessed cubemap.
  58470. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58471. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58472. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58473. * (default is true)
  58474. */
  58475. constructor(
  58476. /**
  58477. * Defines the name of the task
  58478. */
  58479. name: string,
  58480. /**
  58481. * Defines the location of the file to load
  58482. */
  58483. url: string,
  58484. /**
  58485. * Defines the desired size (the more it increases the longer the generation will be)
  58486. */
  58487. size: number,
  58488. /**
  58489. * Defines if mipmaps should not be generated (default is false)
  58490. */
  58491. noMipmap?: boolean,
  58492. /**
  58493. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58494. * but the standard material would require them in Gamma space) (default is true)
  58495. */
  58496. gammaSpace?: boolean);
  58497. /**
  58498. * Execute the current task
  58499. * @param scene defines the scene where you want your assets to be loaded
  58500. * @param onSuccess is a callback called when the task is successfully executed
  58501. * @param onError is a callback called if an error occurs
  58502. */
  58503. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58504. }
  58505. /**
  58506. * This class can be used to easily import assets into a scene
  58507. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58508. */
  58509. export class AssetsManager {
  58510. private _scene;
  58511. private _isLoading;
  58512. protected _tasks: AbstractAssetTask[];
  58513. protected _waitingTasksCount: number;
  58514. protected _totalTasksCount: number;
  58515. /**
  58516. * Callback called when all tasks are processed
  58517. */
  58518. onFinish: (tasks: AbstractAssetTask[]) => void;
  58519. /**
  58520. * Callback called when a task is successful
  58521. */
  58522. onTaskSuccess: (task: AbstractAssetTask) => void;
  58523. /**
  58524. * Callback called when a task had an error
  58525. */
  58526. onTaskError: (task: AbstractAssetTask) => void;
  58527. /**
  58528. * Callback called when a task is done (whatever the result is)
  58529. */
  58530. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58531. /**
  58532. * Observable called when all tasks are processed
  58533. */
  58534. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58535. /**
  58536. * Observable called when a task had an error
  58537. */
  58538. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58539. /**
  58540. * Observable called when all tasks were executed
  58541. */
  58542. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58543. /**
  58544. * Observable called when a task is done (whatever the result is)
  58545. */
  58546. onProgressObservable: Observable<IAssetsProgressEvent>;
  58547. /**
  58548. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58549. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58550. */
  58551. useDefaultLoadingScreen: boolean;
  58552. /**
  58553. * Creates a new AssetsManager
  58554. * @param scene defines the scene to work on
  58555. */
  58556. constructor(scene: Scene);
  58557. /**
  58558. * Add a MeshAssetTask to the list of active tasks
  58559. * @param taskName defines the name of the new task
  58560. * @param meshesNames defines the name of meshes to load
  58561. * @param rootUrl defines the root url to use to locate files
  58562. * @param sceneFilename defines the filename of the scene file
  58563. * @returns a new MeshAssetTask object
  58564. */
  58565. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58566. /**
  58567. * Add a TextFileAssetTask to the list of active tasks
  58568. * @param taskName defines the name of the new task
  58569. * @param url defines the url of the file to load
  58570. * @returns a new TextFileAssetTask object
  58571. */
  58572. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58573. /**
  58574. * Add a BinaryFileAssetTask to the list of active tasks
  58575. * @param taskName defines the name of the new task
  58576. * @param url defines the url of the file to load
  58577. * @returns a new BinaryFileAssetTask object
  58578. */
  58579. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58580. /**
  58581. * Add a ImageAssetTask to the list of active tasks
  58582. * @param taskName defines the name of the new task
  58583. * @param url defines the url of the file to load
  58584. * @returns a new ImageAssetTask object
  58585. */
  58586. addImageTask(taskName: string, url: string): ImageAssetTask;
  58587. /**
  58588. * Add a TextureAssetTask to the list of active tasks
  58589. * @param taskName defines the name of the new task
  58590. * @param url defines the url of the file to load
  58591. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58592. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58593. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58594. * @returns a new TextureAssetTask object
  58595. */
  58596. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58597. /**
  58598. * Add a CubeTextureAssetTask to the list of active tasks
  58599. * @param taskName defines the name of the new task
  58600. * @param url defines the url of the file to load
  58601. * @param extensions defines the extension to use to load the cube map (can be null)
  58602. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58603. * @param files defines the list of files to load (can be null)
  58604. * @returns a new CubeTextureAssetTask object
  58605. */
  58606. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58607. /**
  58608. *
  58609. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58610. * @param taskName defines the name of the new task
  58611. * @param url defines the url of the file to load
  58612. * @param size defines the size you want for the cubemap (can be null)
  58613. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58614. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58615. * @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)
  58616. * @param reserved Internal use only
  58617. * @returns a new HDRCubeTextureAssetTask object
  58618. */
  58619. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58620. /**
  58621. *
  58622. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58623. * @param taskName defines the name of the new task
  58624. * @param url defines the url of the file to load
  58625. * @param size defines the size you want for the cubemap (can be null)
  58626. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58627. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58628. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58629. * @returns a new EquiRectangularCubeTextureAssetTask object
  58630. */
  58631. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58632. /**
  58633. * Remove a task from the assets manager.
  58634. * @param task the task to remove
  58635. */
  58636. removeTask(task: AbstractAssetTask): void;
  58637. private _decreaseWaitingTasksCount;
  58638. private _runTask;
  58639. /**
  58640. * Reset the AssetsManager and remove all tasks
  58641. * @return the current instance of the AssetsManager
  58642. */
  58643. reset(): AssetsManager;
  58644. /**
  58645. * Start the loading process
  58646. * @return the current instance of the AssetsManager
  58647. */
  58648. load(): AssetsManager;
  58649. /**
  58650. * Start the loading process as an async operation
  58651. * @return a promise returning the list of failed tasks
  58652. */
  58653. loadAsync(): Promise<void>;
  58654. }
  58655. }
  58656. declare module "babylonjs/Misc/deferred" {
  58657. /**
  58658. * Wrapper class for promise with external resolve and reject.
  58659. */
  58660. export class Deferred<T> {
  58661. /**
  58662. * The promise associated with this deferred object.
  58663. */
  58664. readonly promise: Promise<T>;
  58665. private _resolve;
  58666. private _reject;
  58667. /**
  58668. * The resolve method of the promise associated with this deferred object.
  58669. */
  58670. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58671. /**
  58672. * The reject method of the promise associated with this deferred object.
  58673. */
  58674. readonly reject: (reason?: any) => void;
  58675. /**
  58676. * Constructor for this deferred object.
  58677. */
  58678. constructor();
  58679. }
  58680. }
  58681. declare module "babylonjs/Misc/meshExploder" {
  58682. import { Mesh } from "babylonjs/Meshes/mesh";
  58683. /**
  58684. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58685. */
  58686. export class MeshExploder {
  58687. private _centerMesh;
  58688. private _meshes;
  58689. private _meshesOrigins;
  58690. private _toCenterVectors;
  58691. private _scaledDirection;
  58692. private _newPosition;
  58693. private _centerPosition;
  58694. /**
  58695. * Explodes meshes from a center mesh.
  58696. * @param meshes The meshes to explode.
  58697. * @param centerMesh The mesh to be center of explosion.
  58698. */
  58699. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58700. private _setCenterMesh;
  58701. /**
  58702. * Get class name
  58703. * @returns "MeshExploder"
  58704. */
  58705. getClassName(): string;
  58706. /**
  58707. * "Exploded meshes"
  58708. * @returns Array of meshes with the centerMesh at index 0.
  58709. */
  58710. getMeshes(): Array<Mesh>;
  58711. /**
  58712. * Explodes meshes giving a specific direction
  58713. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58714. */
  58715. explode(direction?: number): void;
  58716. }
  58717. }
  58718. declare module "babylonjs/Misc/filesInput" {
  58719. import { Engine } from "babylonjs/Engines/engine";
  58720. import { Scene } from "babylonjs/scene";
  58721. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58722. /**
  58723. * Class used to help managing file picking and drag'n'drop
  58724. */
  58725. export class FilesInput {
  58726. /**
  58727. * List of files ready to be loaded
  58728. */
  58729. static readonly FilesToLoad: {
  58730. [key: string]: File;
  58731. };
  58732. /**
  58733. * Callback called when a file is processed
  58734. */
  58735. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58736. private _engine;
  58737. private _currentScene;
  58738. private _sceneLoadedCallback;
  58739. private _progressCallback;
  58740. private _additionalRenderLoopLogicCallback;
  58741. private _textureLoadingCallback;
  58742. private _startingProcessingFilesCallback;
  58743. private _onReloadCallback;
  58744. private _errorCallback;
  58745. private _elementToMonitor;
  58746. private _sceneFileToLoad;
  58747. private _filesToLoad;
  58748. /**
  58749. * Creates a new FilesInput
  58750. * @param engine defines the rendering engine
  58751. * @param scene defines the hosting scene
  58752. * @param sceneLoadedCallback callback called when scene is loaded
  58753. * @param progressCallback callback called to track progress
  58754. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58755. * @param textureLoadingCallback callback called when a texture is loading
  58756. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58757. * @param onReloadCallback callback called when a reload is requested
  58758. * @param errorCallback callback call if an error occurs
  58759. */
  58760. 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);
  58761. private _dragEnterHandler;
  58762. private _dragOverHandler;
  58763. private _dropHandler;
  58764. /**
  58765. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58766. * @param elementToMonitor defines the DOM element to track
  58767. */
  58768. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58769. /**
  58770. * Release all associated resources
  58771. */
  58772. dispose(): void;
  58773. private renderFunction;
  58774. private drag;
  58775. private drop;
  58776. private _traverseFolder;
  58777. private _processFiles;
  58778. /**
  58779. * Load files from a drop event
  58780. * @param event defines the drop event to use as source
  58781. */
  58782. loadFiles(event: any): void;
  58783. private _processReload;
  58784. /**
  58785. * Reload the current scene from the loaded files
  58786. */
  58787. reload(): void;
  58788. }
  58789. }
  58790. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58791. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58792. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58793. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58794. }
  58795. declare module "babylonjs/Misc/sceneOptimizer" {
  58796. import { Scene, IDisposable } from "babylonjs/scene";
  58797. import { Observable } from "babylonjs/Misc/observable";
  58798. /**
  58799. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58800. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58801. */
  58802. export class SceneOptimization {
  58803. /**
  58804. * Defines the priority of this optimization (0 by default which means first in the list)
  58805. */
  58806. priority: number;
  58807. /**
  58808. * Gets a string describing the action executed by the current optimization
  58809. * @returns description string
  58810. */
  58811. getDescription(): string;
  58812. /**
  58813. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58814. * @param scene defines the current scene where to apply this optimization
  58815. * @param optimizer defines the current optimizer
  58816. * @returns true if everything that can be done was applied
  58817. */
  58818. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58819. /**
  58820. * Creates the SceneOptimization object
  58821. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58822. * @param desc defines the description associated with the optimization
  58823. */
  58824. constructor(
  58825. /**
  58826. * Defines the priority of this optimization (0 by default which means first in the list)
  58827. */
  58828. priority?: number);
  58829. }
  58830. /**
  58831. * Defines an optimization used to reduce the size of render target textures
  58832. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58833. */
  58834. export class TextureOptimization extends SceneOptimization {
  58835. /**
  58836. * Defines the priority of this optimization (0 by default which means first in the list)
  58837. */
  58838. priority: number;
  58839. /**
  58840. * 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
  58841. */
  58842. maximumSize: number;
  58843. /**
  58844. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58845. */
  58846. step: number;
  58847. /**
  58848. * Gets a string describing the action executed by the current optimization
  58849. * @returns description string
  58850. */
  58851. getDescription(): string;
  58852. /**
  58853. * Creates the TextureOptimization object
  58854. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58855. * @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
  58856. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58857. */
  58858. constructor(
  58859. /**
  58860. * Defines the priority of this optimization (0 by default which means first in the list)
  58861. */
  58862. priority?: number,
  58863. /**
  58864. * 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
  58865. */
  58866. maximumSize?: number,
  58867. /**
  58868. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58869. */
  58870. step?: number);
  58871. /**
  58872. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58873. * @param scene defines the current scene where to apply this optimization
  58874. * @param optimizer defines the current optimizer
  58875. * @returns true if everything that can be done was applied
  58876. */
  58877. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58878. }
  58879. /**
  58880. * Defines an optimization used to increase or decrease the rendering resolution
  58881. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58882. */
  58883. export class HardwareScalingOptimization extends SceneOptimization {
  58884. /**
  58885. * Defines the priority of this optimization (0 by default which means first in the list)
  58886. */
  58887. priority: number;
  58888. /**
  58889. * Defines the maximum scale to use (2 by default)
  58890. */
  58891. maximumScale: number;
  58892. /**
  58893. * Defines the step to use between two passes (0.5 by default)
  58894. */
  58895. step: number;
  58896. private _currentScale;
  58897. private _directionOffset;
  58898. /**
  58899. * Gets a string describing the action executed by the current optimization
  58900. * @return description string
  58901. */
  58902. getDescription(): string;
  58903. /**
  58904. * Creates the HardwareScalingOptimization object
  58905. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58906. * @param maximumScale defines the maximum scale to use (2 by default)
  58907. * @param step defines the step to use between two passes (0.5 by default)
  58908. */
  58909. constructor(
  58910. /**
  58911. * Defines the priority of this optimization (0 by default which means first in the list)
  58912. */
  58913. priority?: number,
  58914. /**
  58915. * Defines the maximum scale to use (2 by default)
  58916. */
  58917. maximumScale?: number,
  58918. /**
  58919. * Defines the step to use between two passes (0.5 by default)
  58920. */
  58921. step?: number);
  58922. /**
  58923. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58924. * @param scene defines the current scene where to apply this optimization
  58925. * @param optimizer defines the current optimizer
  58926. * @returns true if everything that can be done was applied
  58927. */
  58928. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58929. }
  58930. /**
  58931. * Defines an optimization used to remove shadows
  58932. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58933. */
  58934. export class ShadowsOptimization extends SceneOptimization {
  58935. /**
  58936. * Gets a string describing the action executed by the current optimization
  58937. * @return description string
  58938. */
  58939. getDescription(): string;
  58940. /**
  58941. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58942. * @param scene defines the current scene where to apply this optimization
  58943. * @param optimizer defines the current optimizer
  58944. * @returns true if everything that can be done was applied
  58945. */
  58946. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58947. }
  58948. /**
  58949. * Defines an optimization used to turn post-processes off
  58950. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58951. */
  58952. export class PostProcessesOptimization extends SceneOptimization {
  58953. /**
  58954. * Gets a string describing the action executed by the current optimization
  58955. * @return description string
  58956. */
  58957. getDescription(): string;
  58958. /**
  58959. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58960. * @param scene defines the current scene where to apply this optimization
  58961. * @param optimizer defines the current optimizer
  58962. * @returns true if everything that can be done was applied
  58963. */
  58964. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58965. }
  58966. /**
  58967. * Defines an optimization used to turn lens flares off
  58968. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58969. */
  58970. export class LensFlaresOptimization extends SceneOptimization {
  58971. /**
  58972. * Gets a string describing the action executed by the current optimization
  58973. * @return description string
  58974. */
  58975. getDescription(): string;
  58976. /**
  58977. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58978. * @param scene defines the current scene where to apply this optimization
  58979. * @param optimizer defines the current optimizer
  58980. * @returns true if everything that can be done was applied
  58981. */
  58982. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58983. }
  58984. /**
  58985. * Defines an optimization based on user defined callback.
  58986. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58987. */
  58988. export class CustomOptimization extends SceneOptimization {
  58989. /**
  58990. * Callback called to apply the custom optimization.
  58991. */
  58992. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58993. /**
  58994. * Callback called to get custom description
  58995. */
  58996. onGetDescription: () => string;
  58997. /**
  58998. * Gets a string describing the action executed by the current optimization
  58999. * @returns description string
  59000. */
  59001. getDescription(): string;
  59002. /**
  59003. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59004. * @param scene defines the current scene where to apply this optimization
  59005. * @param optimizer defines the current optimizer
  59006. * @returns true if everything that can be done was applied
  59007. */
  59008. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59009. }
  59010. /**
  59011. * Defines an optimization used to turn particles off
  59012. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59013. */
  59014. export class ParticlesOptimization extends SceneOptimization {
  59015. /**
  59016. * Gets a string describing the action executed by the current optimization
  59017. * @return description string
  59018. */
  59019. getDescription(): string;
  59020. /**
  59021. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59022. * @param scene defines the current scene where to apply this optimization
  59023. * @param optimizer defines the current optimizer
  59024. * @returns true if everything that can be done was applied
  59025. */
  59026. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59027. }
  59028. /**
  59029. * Defines an optimization used to turn render targets off
  59030. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59031. */
  59032. export class RenderTargetsOptimization extends SceneOptimization {
  59033. /**
  59034. * Gets a string describing the action executed by the current optimization
  59035. * @return description string
  59036. */
  59037. getDescription(): string;
  59038. /**
  59039. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59040. * @param scene defines the current scene where to apply this optimization
  59041. * @param optimizer defines the current optimizer
  59042. * @returns true if everything that can be done was applied
  59043. */
  59044. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59045. }
  59046. /**
  59047. * Defines an optimization used to merge meshes with compatible materials
  59048. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59049. */
  59050. export class MergeMeshesOptimization extends SceneOptimization {
  59051. private static _UpdateSelectionTree;
  59052. /**
  59053. * Gets or sets a boolean which defines if optimization octree has to be updated
  59054. */
  59055. /**
  59056. * Gets or sets a boolean which defines if optimization octree has to be updated
  59057. */
  59058. static UpdateSelectionTree: boolean;
  59059. /**
  59060. * Gets a string describing the action executed by the current optimization
  59061. * @return description string
  59062. */
  59063. getDescription(): string;
  59064. private _canBeMerged;
  59065. /**
  59066. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59067. * @param scene defines the current scene where to apply this optimization
  59068. * @param optimizer defines the current optimizer
  59069. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  59070. * @returns true if everything that can be done was applied
  59071. */
  59072. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  59073. }
  59074. /**
  59075. * Defines a list of options used by SceneOptimizer
  59076. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59077. */
  59078. export class SceneOptimizerOptions {
  59079. /**
  59080. * Defines the target frame rate to reach (60 by default)
  59081. */
  59082. targetFrameRate: number;
  59083. /**
  59084. * Defines the interval between two checkes (2000ms by default)
  59085. */
  59086. trackerDuration: number;
  59087. /**
  59088. * Gets the list of optimizations to apply
  59089. */
  59090. optimizations: SceneOptimization[];
  59091. /**
  59092. * Creates a new list of options used by SceneOptimizer
  59093. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  59094. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  59095. */
  59096. constructor(
  59097. /**
  59098. * Defines the target frame rate to reach (60 by default)
  59099. */
  59100. targetFrameRate?: number,
  59101. /**
  59102. * Defines the interval between two checkes (2000ms by default)
  59103. */
  59104. trackerDuration?: number);
  59105. /**
  59106. * Add a new optimization
  59107. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  59108. * @returns the current SceneOptimizerOptions
  59109. */
  59110. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  59111. /**
  59112. * Add a new custom optimization
  59113. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  59114. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  59115. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59116. * @returns the current SceneOptimizerOptions
  59117. */
  59118. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59119. /**
  59120. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59121. * @param targetFrameRate defines the target frame rate (60 by default)
  59122. * @returns a SceneOptimizerOptions object
  59123. */
  59124. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59125. /**
  59126. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59127. * @param targetFrameRate defines the target frame rate (60 by default)
  59128. * @returns a SceneOptimizerOptions object
  59129. */
  59130. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59131. /**
  59132. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59133. * @param targetFrameRate defines the target frame rate (60 by default)
  59134. * @returns a SceneOptimizerOptions object
  59135. */
  59136. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59137. }
  59138. /**
  59139. * Class used to run optimizations in order to reach a target frame rate
  59140. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59141. */
  59142. export class SceneOptimizer implements IDisposable {
  59143. private _isRunning;
  59144. private _options;
  59145. private _scene;
  59146. private _currentPriorityLevel;
  59147. private _targetFrameRate;
  59148. private _trackerDuration;
  59149. private _currentFrameRate;
  59150. private _sceneDisposeObserver;
  59151. private _improvementMode;
  59152. /**
  59153. * Defines an observable called when the optimizer reaches the target frame rate
  59154. */
  59155. onSuccessObservable: Observable<SceneOptimizer>;
  59156. /**
  59157. * Defines an observable called when the optimizer enables an optimization
  59158. */
  59159. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59160. /**
  59161. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59162. */
  59163. onFailureObservable: Observable<SceneOptimizer>;
  59164. /**
  59165. * Gets a boolean indicating if the optimizer is in improvement mode
  59166. */
  59167. readonly isInImprovementMode: boolean;
  59168. /**
  59169. * Gets the current priority level (0 at start)
  59170. */
  59171. readonly currentPriorityLevel: number;
  59172. /**
  59173. * Gets the current frame rate checked by the SceneOptimizer
  59174. */
  59175. readonly currentFrameRate: number;
  59176. /**
  59177. * Gets or sets the current target frame rate (60 by default)
  59178. */
  59179. /**
  59180. * Gets or sets the current target frame rate (60 by default)
  59181. */
  59182. targetFrameRate: number;
  59183. /**
  59184. * Gets or sets the current interval between two checks (every 2000ms by default)
  59185. */
  59186. /**
  59187. * Gets or sets the current interval between two checks (every 2000ms by default)
  59188. */
  59189. trackerDuration: number;
  59190. /**
  59191. * Gets the list of active optimizations
  59192. */
  59193. readonly optimizations: SceneOptimization[];
  59194. /**
  59195. * Creates a new SceneOptimizer
  59196. * @param scene defines the scene to work on
  59197. * @param options defines the options to use with the SceneOptimizer
  59198. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59199. * @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)
  59200. */
  59201. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59202. /**
  59203. * Stops the current optimizer
  59204. */
  59205. stop(): void;
  59206. /**
  59207. * Reset the optimizer to initial step (current priority level = 0)
  59208. */
  59209. reset(): void;
  59210. /**
  59211. * Start the optimizer. By default it will try to reach a specific framerate
  59212. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59213. */
  59214. start(): void;
  59215. private _checkCurrentState;
  59216. /**
  59217. * Release all resources
  59218. */
  59219. dispose(): void;
  59220. /**
  59221. * Helper function to create a SceneOptimizer with one single line of code
  59222. * @param scene defines the scene to work on
  59223. * @param options defines the options to use with the SceneOptimizer
  59224. * @param onSuccess defines a callback to call on success
  59225. * @param onFailure defines a callback to call on failure
  59226. * @returns the new SceneOptimizer object
  59227. */
  59228. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59229. }
  59230. }
  59231. declare module "babylonjs/Misc/sceneSerializer" {
  59232. import { Scene } from "babylonjs/scene";
  59233. /**
  59234. * Class used to serialize a scene into a string
  59235. */
  59236. export class SceneSerializer {
  59237. /**
  59238. * Clear cache used by a previous serialization
  59239. */
  59240. static ClearCache(): void;
  59241. /**
  59242. * Serialize a scene into a JSON compatible object
  59243. * @param scene defines the scene to serialize
  59244. * @returns a JSON compatible object
  59245. */
  59246. static Serialize(scene: Scene): any;
  59247. /**
  59248. * Serialize a mesh into a JSON compatible object
  59249. * @param toSerialize defines the mesh to serialize
  59250. * @param withParents defines if parents must be serialized as well
  59251. * @param withChildren defines if children must be serialized as well
  59252. * @returns a JSON compatible object
  59253. */
  59254. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59255. }
  59256. }
  59257. declare module "babylonjs/Misc/textureTools" {
  59258. import { Texture } from "babylonjs/Materials/Textures/texture";
  59259. /**
  59260. * Class used to host texture specific utilities
  59261. */
  59262. export class TextureTools {
  59263. /**
  59264. * Uses the GPU to create a copy texture rescaled at a given size
  59265. * @param texture Texture to copy from
  59266. * @param width defines the desired width
  59267. * @param height defines the desired height
  59268. * @param useBilinearMode defines if bilinear mode has to be used
  59269. * @return the generated texture
  59270. */
  59271. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59272. }
  59273. }
  59274. declare module "babylonjs/Misc/videoRecorder" {
  59275. import { Nullable } from "babylonjs/types";
  59276. import { Engine } from "babylonjs/Engines/engine";
  59277. /**
  59278. * This represents the different options avilable for the video capture.
  59279. */
  59280. export interface VideoRecorderOptions {
  59281. /** Defines the mime type of the video */
  59282. mimeType: string;
  59283. /** Defines the video the video should be recorded at */
  59284. fps: number;
  59285. /** Defines the chunk size for the recording data */
  59286. recordChunckSize: number;
  59287. /** The audio tracks to attach to the record */
  59288. audioTracks?: MediaStreamTrack[];
  59289. }
  59290. /**
  59291. * This can helps recording videos from BabylonJS.
  59292. * This is based on the available WebRTC functionalities of the browser.
  59293. *
  59294. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59295. */
  59296. export class VideoRecorder {
  59297. private static readonly _defaultOptions;
  59298. /**
  59299. * Returns wehther or not the VideoRecorder is available in your browser.
  59300. * @param engine Defines the Babylon Engine to check the support for
  59301. * @returns true if supported otherwise false
  59302. */
  59303. static IsSupported(engine: Engine): boolean;
  59304. private readonly _options;
  59305. private _canvas;
  59306. private _mediaRecorder;
  59307. private _recordedChunks;
  59308. private _fileName;
  59309. private _resolve;
  59310. private _reject;
  59311. /**
  59312. * True wether a recording is already in progress.
  59313. */
  59314. readonly isRecording: boolean;
  59315. /**
  59316. * Create a new VideoCapture object which can help converting what you see in Babylon to
  59317. * a video file.
  59318. * @param engine Defines the BabylonJS Engine you wish to record
  59319. * @param options Defines options that can be used to customized the capture
  59320. */
  59321. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59322. /**
  59323. * Stops the current recording before the default capture timeout passed in the startRecording
  59324. * functions.
  59325. */
  59326. stopRecording(): void;
  59327. /**
  59328. * Starts recording the canvas for a max duration specified in parameters.
  59329. * @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.
  59330. * @param maxDuration Defines the maximum recording time in seconds.
  59331. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59332. * @return a promise callback at the end of the recording with the video data in Blob.
  59333. */
  59334. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59335. /**
  59336. * Releases internal resources used during the recording.
  59337. */
  59338. dispose(): void;
  59339. private _handleDataAvailable;
  59340. private _handleError;
  59341. private _handleStop;
  59342. }
  59343. }
  59344. declare module "babylonjs/Misc/screenshotTools" {
  59345. import { Camera } from "babylonjs/Cameras/camera";
  59346. import { Engine } from "babylonjs/Engines/engine";
  59347. /**
  59348. * Class containing a set of static utilities functions for screenshots
  59349. */
  59350. export class ScreenshotTools {
  59351. /**
  59352. * Captures a screenshot of the current rendering
  59353. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59354. * @param engine defines the rendering engine
  59355. * @param camera defines the source camera
  59356. * @param size This parameter can be set to a single number or to an object with the
  59357. * following (optional) properties: precision, width, height. If a single number is passed,
  59358. * it will be used for both width and height. If an object is passed, the screenshot size
  59359. * will be derived from the parameters. The precision property is a multiplier allowing
  59360. * rendering at a higher or lower resolution
  59361. * @param successCallback defines the callback receives a single parameter which contains the
  59362. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59363. * src parameter of an <img> to display it
  59364. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59365. * Check your browser for supported MIME types
  59366. */
  59367. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59368. /**
  59369. * Generates an image screenshot from the specified camera.
  59370. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59371. * @param engine The engine to use for rendering
  59372. * @param camera The camera to use for rendering
  59373. * @param size This parameter can be set to a single number or to an object with the
  59374. * following (optional) properties: precision, width, height. If a single number is passed,
  59375. * it will be used for both width and height. If an object is passed, the screenshot size
  59376. * will be derived from the parameters. The precision property is a multiplier allowing
  59377. * rendering at a higher or lower resolution
  59378. * @param successCallback The callback receives a single parameter which contains the
  59379. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59380. * src parameter of an <img> to display it
  59381. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59382. * Check your browser for supported MIME types
  59383. * @param samples Texture samples (default: 1)
  59384. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59385. * @param fileName A name for for the downloaded file.
  59386. */
  59387. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59388. }
  59389. }
  59390. declare module "babylonjs/Misc/index" {
  59391. export * from "babylonjs/Misc/andOrNotEvaluator";
  59392. export * from "babylonjs/Misc/assetsManager";
  59393. export * from "babylonjs/Misc/dds";
  59394. export * from "babylonjs/Misc/decorators";
  59395. export * from "babylonjs/Misc/deferred";
  59396. export * from "babylonjs/Misc/environmentTextureTools";
  59397. export * from "babylonjs/Misc/meshExploder";
  59398. export * from "babylonjs/Misc/filesInput";
  59399. export * from "babylonjs/Misc/HighDynamicRange/index";
  59400. export * from "babylonjs/Misc/khronosTextureContainer";
  59401. export * from "babylonjs/Misc/observable";
  59402. export * from "babylonjs/Misc/performanceMonitor";
  59403. export * from "babylonjs/Misc/promise";
  59404. export * from "babylonjs/Misc/sceneOptimizer";
  59405. export * from "babylonjs/Misc/sceneSerializer";
  59406. export * from "babylonjs/Misc/smartArray";
  59407. export * from "babylonjs/Misc/stringDictionary";
  59408. export * from "babylonjs/Misc/tags";
  59409. export * from "babylonjs/Misc/textureTools";
  59410. export * from "babylonjs/Misc/tga";
  59411. export * from "babylonjs/Misc/tools";
  59412. export * from "babylonjs/Misc/videoRecorder";
  59413. export * from "babylonjs/Misc/virtualJoystick";
  59414. export * from "babylonjs/Misc/workerPool";
  59415. export * from "babylonjs/Misc/logger";
  59416. export * from "babylonjs/Misc/typeStore";
  59417. export * from "babylonjs/Misc/filesInputStore";
  59418. export * from "babylonjs/Misc/deepCopier";
  59419. export * from "babylonjs/Misc/pivotTools";
  59420. export * from "babylonjs/Misc/precisionDate";
  59421. export * from "babylonjs/Misc/screenshotTools";
  59422. export * from "babylonjs/Misc/typeStore";
  59423. export * from "babylonjs/Misc/webRequest";
  59424. export * from "babylonjs/Misc/iInspectable";
  59425. }
  59426. declare module "babylonjs/index" {
  59427. export * from "babylonjs/abstractScene";
  59428. export * from "babylonjs/Actions/index";
  59429. export * from "babylonjs/Animations/index";
  59430. export * from "babylonjs/assetContainer";
  59431. export * from "babylonjs/Audio/index";
  59432. export * from "babylonjs/Behaviors/index";
  59433. export * from "babylonjs/Bones/index";
  59434. export * from "babylonjs/Cameras/index";
  59435. export * from "babylonjs/Collisions/index";
  59436. export * from "babylonjs/Culling/index";
  59437. export * from "babylonjs/Debug/index";
  59438. export * from "babylonjs/Engines/index";
  59439. export * from "babylonjs/Events/index";
  59440. export * from "babylonjs/Gamepads/index";
  59441. export * from "babylonjs/Gizmos/index";
  59442. export * from "babylonjs/Helpers/index";
  59443. export * from "babylonjs/Instrumentation/index";
  59444. export * from "babylonjs/Layers/index";
  59445. export * from "babylonjs/LensFlares/index";
  59446. export * from "babylonjs/Lights/index";
  59447. export * from "babylonjs/Loading/index";
  59448. export * from "babylonjs/Materials/index";
  59449. export * from "babylonjs/Maths/index";
  59450. export * from "babylonjs/Meshes/index";
  59451. export * from "babylonjs/Morph/index";
  59452. export * from "babylonjs/node";
  59453. export * from "babylonjs/Offline/index";
  59454. export * from "babylonjs/Particles/index";
  59455. export * from "babylonjs/Physics/index";
  59456. export * from "babylonjs/PostProcesses/index";
  59457. export * from "babylonjs/Probes/index";
  59458. export * from "babylonjs/Rendering/index";
  59459. export * from "babylonjs/scene";
  59460. export * from "babylonjs/sceneComponent";
  59461. export * from "babylonjs/Sprites/index";
  59462. export * from "babylonjs/States/index";
  59463. export * from "babylonjs/Misc/index";
  59464. export * from "babylonjs/types";
  59465. }
  59466. declare module "babylonjs/Animations/pathCursor" {
  59467. import { Path2, Vector3 } from "babylonjs/Maths/math";
  59468. /**
  59469. * A cursor which tracks a point on a path
  59470. */
  59471. export class PathCursor {
  59472. private path;
  59473. /**
  59474. * Stores path cursor callbacks for when an onchange event is triggered
  59475. */
  59476. private _onchange;
  59477. /**
  59478. * The value of the path cursor
  59479. */
  59480. value: number;
  59481. /**
  59482. * The animation array of the path cursor
  59483. */
  59484. animations: Animation[];
  59485. /**
  59486. * Initializes the path cursor
  59487. * @param path The path to track
  59488. */
  59489. constructor(path: Path2);
  59490. /**
  59491. * Gets the cursor point on the path
  59492. * @returns A point on the path cursor at the cursor location
  59493. */
  59494. getPoint(): Vector3;
  59495. /**
  59496. * Moves the cursor ahead by the step amount
  59497. * @param step The amount to move the cursor forward
  59498. * @returns This path cursor
  59499. */
  59500. moveAhead(step?: number): PathCursor;
  59501. /**
  59502. * Moves the cursor behind by the step amount
  59503. * @param step The amount to move the cursor back
  59504. * @returns This path cursor
  59505. */
  59506. moveBack(step?: number): PathCursor;
  59507. /**
  59508. * Moves the cursor by the step amount
  59509. * If the step amount is greater than one, an exception is thrown
  59510. * @param step The amount to move the cursor
  59511. * @returns This path cursor
  59512. */
  59513. move(step: number): PathCursor;
  59514. /**
  59515. * Ensures that the value is limited between zero and one
  59516. * @returns This path cursor
  59517. */
  59518. private ensureLimits;
  59519. /**
  59520. * Runs onchange callbacks on change (used by the animation engine)
  59521. * @returns This path cursor
  59522. */
  59523. private raiseOnChange;
  59524. /**
  59525. * Executes a function on change
  59526. * @param f A path cursor onchange callback
  59527. * @returns This path cursor
  59528. */
  59529. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59530. }
  59531. }
  59532. declare module "babylonjs/Legacy/legacy" {
  59533. import * as Babylon from "babylonjs/index";
  59534. export * from "babylonjs/index";
  59535. }
  59536. declare module "babylonjs/Shaders/blur.fragment" {
  59537. /** @hidden */
  59538. export var blurPixelShader: {
  59539. name: string;
  59540. shader: string;
  59541. };
  59542. }
  59543. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  59544. /** @hidden */
  59545. export var bones300Declaration: {
  59546. name: string;
  59547. shader: string;
  59548. };
  59549. }
  59550. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  59551. /** @hidden */
  59552. export var instances300Declaration: {
  59553. name: string;
  59554. shader: string;
  59555. };
  59556. }
  59557. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  59558. /** @hidden */
  59559. export var pointCloudVertexDeclaration: {
  59560. name: string;
  59561. shader: string;
  59562. };
  59563. }
  59564. // Mixins
  59565. interface Window {
  59566. mozIndexedDB: IDBFactory;
  59567. webkitIndexedDB: IDBFactory;
  59568. msIndexedDB: IDBFactory;
  59569. webkitURL: typeof URL;
  59570. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59571. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59572. WebGLRenderingContext: WebGLRenderingContext;
  59573. MSGesture: MSGesture;
  59574. CANNON: any;
  59575. AudioContext: AudioContext;
  59576. webkitAudioContext: AudioContext;
  59577. PointerEvent: any;
  59578. Math: Math;
  59579. Uint8Array: Uint8ArrayConstructor;
  59580. Float32Array: Float32ArrayConstructor;
  59581. mozURL: typeof URL;
  59582. msURL: typeof URL;
  59583. VRFrameData: any; // WebVR, from specs 1.1
  59584. DracoDecoderModule: any;
  59585. setImmediate(handler: (...args: any[]) => void): number;
  59586. }
  59587. interface HTMLCanvasElement {
  59588. requestPointerLock(): void;
  59589. msRequestPointerLock?(): void;
  59590. mozRequestPointerLock?(): void;
  59591. webkitRequestPointerLock?(): void;
  59592. /** Track wether a record is in progress */
  59593. isRecording: boolean;
  59594. /** Capture Stream method defined by some browsers */
  59595. captureStream(fps?: number): MediaStream;
  59596. }
  59597. interface CanvasRenderingContext2D {
  59598. msImageSmoothingEnabled: boolean;
  59599. }
  59600. interface MouseEvent {
  59601. mozMovementX: number;
  59602. mozMovementY: number;
  59603. webkitMovementX: number;
  59604. webkitMovementY: number;
  59605. msMovementX: number;
  59606. msMovementY: number;
  59607. }
  59608. interface Navigator {
  59609. mozGetVRDevices: (any: any) => any;
  59610. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59611. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59612. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59613. webkitGetGamepads(): Gamepad[];
  59614. msGetGamepads(): Gamepad[];
  59615. webkitGamepads(): Gamepad[];
  59616. }
  59617. interface HTMLVideoElement {
  59618. mozSrcObject: any;
  59619. }
  59620. interface Math {
  59621. fround(x: number): number;
  59622. imul(a: number, b: number): number;
  59623. }
  59624. interface WebGLRenderingContext {
  59625. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59626. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59627. vertexAttribDivisor(index: number, divisor: number): void;
  59628. createVertexArray(): any;
  59629. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59630. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59631. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59632. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59633. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59634. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59635. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59636. // Queries
  59637. createQuery(): WebGLQuery;
  59638. deleteQuery(query: WebGLQuery): void;
  59639. beginQuery(target: number, query: WebGLQuery): void;
  59640. endQuery(target: number): void;
  59641. getQueryParameter(query: WebGLQuery, pname: number): any;
  59642. getQuery(target: number, pname: number): any;
  59643. MAX_SAMPLES: number;
  59644. RGBA8: number;
  59645. READ_FRAMEBUFFER: number;
  59646. DRAW_FRAMEBUFFER: number;
  59647. UNIFORM_BUFFER: number;
  59648. HALF_FLOAT_OES: number;
  59649. RGBA16F: number;
  59650. RGBA32F: number;
  59651. R32F: number;
  59652. RG32F: number;
  59653. RGB32F: number;
  59654. R16F: number;
  59655. RG16F: number;
  59656. RGB16F: number;
  59657. RED: number;
  59658. RG: number;
  59659. R8: number;
  59660. RG8: number;
  59661. UNSIGNED_INT_24_8: number;
  59662. DEPTH24_STENCIL8: number;
  59663. /* Multiple Render Targets */
  59664. drawBuffers(buffers: number[]): void;
  59665. readBuffer(src: number): void;
  59666. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59667. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59668. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59669. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59670. // Occlusion Query
  59671. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59672. ANY_SAMPLES_PASSED: number;
  59673. QUERY_RESULT_AVAILABLE: number;
  59674. QUERY_RESULT: number;
  59675. }
  59676. interface WebGLProgram {
  59677. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59678. }
  59679. interface EXT_disjoint_timer_query {
  59680. QUERY_COUNTER_BITS_EXT: number;
  59681. TIME_ELAPSED_EXT: number;
  59682. TIMESTAMP_EXT: number;
  59683. GPU_DISJOINT_EXT: number;
  59684. QUERY_RESULT_EXT: number;
  59685. QUERY_RESULT_AVAILABLE_EXT: number;
  59686. queryCounterEXT(query: WebGLQuery, target: number): void;
  59687. createQueryEXT(): WebGLQuery;
  59688. beginQueryEXT(target: number, query: WebGLQuery): void;
  59689. endQueryEXT(target: number): void;
  59690. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59691. deleteQueryEXT(query: WebGLQuery): void;
  59692. }
  59693. interface WebGLUniformLocation {
  59694. _currentState: any;
  59695. }
  59696. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59697. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59698. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59699. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59700. interface WebGLRenderingContext {
  59701. readonly RASTERIZER_DISCARD: number;
  59702. readonly DEPTH_COMPONENT24: number;
  59703. readonly TEXTURE_3D: number;
  59704. readonly TEXTURE_2D_ARRAY: number;
  59705. readonly TEXTURE_COMPARE_FUNC: number;
  59706. readonly TEXTURE_COMPARE_MODE: number;
  59707. readonly COMPARE_REF_TO_TEXTURE: number;
  59708. readonly TEXTURE_WRAP_R: number;
  59709. readonly HALF_FLOAT: number;
  59710. readonly RGB8: number;
  59711. readonly RED_INTEGER: number;
  59712. readonly RG_INTEGER: number;
  59713. readonly RGB_INTEGER: number;
  59714. readonly RGBA_INTEGER: number;
  59715. readonly R8_SNORM: number;
  59716. readonly RG8_SNORM: number;
  59717. readonly RGB8_SNORM: number;
  59718. readonly RGBA8_SNORM: number;
  59719. readonly R8I: number;
  59720. readonly RG8I: number;
  59721. readonly RGB8I: number;
  59722. readonly RGBA8I: number;
  59723. readonly R8UI: number;
  59724. readonly RG8UI: number;
  59725. readonly RGB8UI: number;
  59726. readonly RGBA8UI: number;
  59727. readonly R16I: number;
  59728. readonly RG16I: number;
  59729. readonly RGB16I: number;
  59730. readonly RGBA16I: number;
  59731. readonly R16UI: number;
  59732. readonly RG16UI: number;
  59733. readonly RGB16UI: number;
  59734. readonly RGBA16UI: number;
  59735. readonly R32I: number;
  59736. readonly RG32I: number;
  59737. readonly RGB32I: number;
  59738. readonly RGBA32I: number;
  59739. readonly R32UI: number;
  59740. readonly RG32UI: number;
  59741. readonly RGB32UI: number;
  59742. readonly RGBA32UI: number;
  59743. readonly RGB10_A2UI: number;
  59744. readonly R11F_G11F_B10F: number;
  59745. readonly RGB9_E5: number;
  59746. readonly RGB10_A2: number;
  59747. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59748. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59749. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59750. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59751. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59752. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59753. 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;
  59754. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59755. readonly TRANSFORM_FEEDBACK: number;
  59756. readonly INTERLEAVED_ATTRIBS: number;
  59757. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59758. createTransformFeedback(): WebGLTransformFeedback;
  59759. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59760. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59761. beginTransformFeedback(primitiveMode: number): void;
  59762. endTransformFeedback(): void;
  59763. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59764. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59765. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59766. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59767. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59768. }
  59769. interface ImageBitmap {
  59770. readonly width: number;
  59771. readonly height: number;
  59772. close(): void;
  59773. }
  59774. interface WebGLQuery extends WebGLObject {
  59775. }
  59776. declare var WebGLQuery: {
  59777. prototype: WebGLQuery;
  59778. new(): WebGLQuery;
  59779. };
  59780. interface WebGLSampler extends WebGLObject {
  59781. }
  59782. declare var WebGLSampler: {
  59783. prototype: WebGLSampler;
  59784. new(): WebGLSampler;
  59785. };
  59786. interface WebGLSync extends WebGLObject {
  59787. }
  59788. declare var WebGLSync: {
  59789. prototype: WebGLSync;
  59790. new(): WebGLSync;
  59791. };
  59792. interface WebGLTransformFeedback extends WebGLObject {
  59793. }
  59794. declare var WebGLTransformFeedback: {
  59795. prototype: WebGLTransformFeedback;
  59796. new(): WebGLTransformFeedback;
  59797. };
  59798. interface WebGLVertexArrayObject extends WebGLObject {
  59799. }
  59800. declare var WebGLVertexArrayObject: {
  59801. prototype: WebGLVertexArrayObject;
  59802. new(): WebGLVertexArrayObject;
  59803. };
  59804. // Type definitions for WebVR API
  59805. // Project: https://w3c.github.io/webvr/
  59806. // Definitions by: six a <https://github.com/lostfictions>
  59807. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59808. interface VRDisplay extends EventTarget {
  59809. /**
  59810. * Dictionary of capabilities describing the VRDisplay.
  59811. */
  59812. readonly capabilities: VRDisplayCapabilities;
  59813. /**
  59814. * z-depth defining the far plane of the eye view frustum
  59815. * enables mapping of values in the render target depth
  59816. * attachment to scene coordinates. Initially set to 10000.0.
  59817. */
  59818. depthFar: number;
  59819. /**
  59820. * z-depth defining the near plane of the eye view frustum
  59821. * enables mapping of values in the render target depth
  59822. * attachment to scene coordinates. Initially set to 0.01.
  59823. */
  59824. depthNear: number;
  59825. /**
  59826. * An identifier for this distinct VRDisplay. Used as an
  59827. * association point in the Gamepad API.
  59828. */
  59829. readonly displayId: number;
  59830. /**
  59831. * A display name, a user-readable name identifying it.
  59832. */
  59833. readonly displayName: string;
  59834. readonly isConnected: boolean;
  59835. readonly isPresenting: boolean;
  59836. /**
  59837. * If this VRDisplay supports room-scale experiences, the optional
  59838. * stage attribute contains details on the room-scale parameters.
  59839. */
  59840. readonly stageParameters: VRStageParameters | null;
  59841. /**
  59842. * Passing the value returned by `requestAnimationFrame` to
  59843. * `cancelAnimationFrame` will unregister the callback.
  59844. * @param handle Define the hanle of the request to cancel
  59845. */
  59846. cancelAnimationFrame(handle: number): void;
  59847. /**
  59848. * Stops presenting to the VRDisplay.
  59849. * @returns a promise to know when it stopped
  59850. */
  59851. exitPresent(): Promise<void>;
  59852. /**
  59853. * Return the current VREyeParameters for the given eye.
  59854. * @param whichEye Define the eye we want the parameter for
  59855. * @returns the eye parameters
  59856. */
  59857. getEyeParameters(whichEye: string): VREyeParameters;
  59858. /**
  59859. * Populates the passed VRFrameData with the information required to render
  59860. * the current frame.
  59861. * @param frameData Define the data structure to populate
  59862. * @returns true if ok otherwise false
  59863. */
  59864. getFrameData(frameData: VRFrameData): boolean;
  59865. /**
  59866. * Get the layers currently being presented.
  59867. * @returns the list of VR layers
  59868. */
  59869. getLayers(): VRLayer[];
  59870. /**
  59871. * Return a VRPose containing the future predicted pose of the VRDisplay
  59872. * when the current frame will be presented. The value returned will not
  59873. * change until JavaScript has returned control to the browser.
  59874. *
  59875. * The VRPose will contain the position, orientation, velocity,
  59876. * and acceleration of each of these properties.
  59877. * @returns the pose object
  59878. */
  59879. getPose(): VRPose;
  59880. /**
  59881. * Return the current instantaneous pose of the VRDisplay, with no
  59882. * prediction applied.
  59883. * @returns the current instantaneous pose
  59884. */
  59885. getImmediatePose(): VRPose;
  59886. /**
  59887. * The callback passed to `requestAnimationFrame` will be called
  59888. * any time a new frame should be rendered. When the VRDisplay is
  59889. * presenting the callback will be called at the native refresh
  59890. * rate of the HMD. When not presenting this function acts
  59891. * identically to how window.requestAnimationFrame acts. Content should
  59892. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59893. * asynchronously from other displays and at differing refresh rates.
  59894. * @param callback Define the eaction to run next frame
  59895. * @returns the request handle it
  59896. */
  59897. requestAnimationFrame(callback: FrameRequestCallback): number;
  59898. /**
  59899. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59900. * Repeat calls while already presenting will update the VRLayers being displayed.
  59901. * @param layers Define the list of layer to present
  59902. * @returns a promise to know when the request has been fulfilled
  59903. */
  59904. requestPresent(layers: VRLayer[]): Promise<void>;
  59905. /**
  59906. * Reset the pose for this display, treating its current position and
  59907. * orientation as the "origin/zero" values. VRPose.position,
  59908. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59909. * updated when calling resetPose(). This should be called in only
  59910. * sitting-space experiences.
  59911. */
  59912. resetPose(): void;
  59913. /**
  59914. * The VRLayer provided to the VRDisplay will be captured and presented
  59915. * in the HMD. Calling this function has the same effect on the source
  59916. * canvas as any other operation that uses its source image, and canvases
  59917. * created without preserveDrawingBuffer set to true will be cleared.
  59918. * @param pose Define the pose to submit
  59919. */
  59920. submitFrame(pose?: VRPose): void;
  59921. }
  59922. declare var VRDisplay: {
  59923. prototype: VRDisplay;
  59924. new(): VRDisplay;
  59925. };
  59926. interface VRLayer {
  59927. leftBounds?: number[] | Float32Array | null;
  59928. rightBounds?: number[] | Float32Array | null;
  59929. source?: HTMLCanvasElement | null;
  59930. }
  59931. interface VRDisplayCapabilities {
  59932. readonly canPresent: boolean;
  59933. readonly hasExternalDisplay: boolean;
  59934. readonly hasOrientation: boolean;
  59935. readonly hasPosition: boolean;
  59936. readonly maxLayers: number;
  59937. }
  59938. interface VREyeParameters {
  59939. /** @deprecated */
  59940. readonly fieldOfView: VRFieldOfView;
  59941. readonly offset: Float32Array;
  59942. readonly renderHeight: number;
  59943. readonly renderWidth: number;
  59944. }
  59945. interface VRFieldOfView {
  59946. readonly downDegrees: number;
  59947. readonly leftDegrees: number;
  59948. readonly rightDegrees: number;
  59949. readonly upDegrees: number;
  59950. }
  59951. interface VRFrameData {
  59952. readonly leftProjectionMatrix: Float32Array;
  59953. readonly leftViewMatrix: Float32Array;
  59954. readonly pose: VRPose;
  59955. readonly rightProjectionMatrix: Float32Array;
  59956. readonly rightViewMatrix: Float32Array;
  59957. readonly timestamp: number;
  59958. }
  59959. interface VRPose {
  59960. readonly angularAcceleration: Float32Array | null;
  59961. readonly angularVelocity: Float32Array | null;
  59962. readonly linearAcceleration: Float32Array | null;
  59963. readonly linearVelocity: Float32Array | null;
  59964. readonly orientation: Float32Array | null;
  59965. readonly position: Float32Array | null;
  59966. readonly timestamp: number;
  59967. }
  59968. interface VRStageParameters {
  59969. sittingToStandingTransform?: Float32Array;
  59970. sizeX?: number;
  59971. sizeY?: number;
  59972. }
  59973. interface Navigator {
  59974. getVRDisplays(): Promise<VRDisplay[]>;
  59975. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59976. }
  59977. interface Window {
  59978. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59979. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59980. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59981. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59982. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59983. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59984. }
  59985. interface Gamepad {
  59986. readonly displayId: number;
  59987. }
  59988. interface XRDevice {
  59989. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59990. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59991. }
  59992. interface XRSession {
  59993. getInputSources(): Array<any>;
  59994. baseLayer: XRWebGLLayer;
  59995. requestFrameOfReference(type: string): Promise<void>;
  59996. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59997. end(): Promise<void>;
  59998. requestAnimationFrame: Function;
  59999. addEventListener: Function;
  60000. }
  60001. interface XRSessionCreationOptions {
  60002. outputContext?: WebGLRenderingContext | null;
  60003. immersive?: boolean;
  60004. environmentIntegration?: boolean;
  60005. }
  60006. interface XRLayer {
  60007. getViewport: Function;
  60008. framebufferWidth: number;
  60009. framebufferHeight: number;
  60010. }
  60011. interface XRView {
  60012. projectionMatrix: Float32Array;
  60013. }
  60014. interface XRFrame {
  60015. getDevicePose: Function;
  60016. getInputPose: Function;
  60017. views: Array<XRView>;
  60018. baseLayer: XRLayer;
  60019. }
  60020. interface XRFrameOfReference {
  60021. }
  60022. interface XRWebGLLayer extends XRLayer {
  60023. framebuffer: WebGLFramebuffer;
  60024. }
  60025. declare var XRWebGLLayer: {
  60026. prototype: XRWebGLLayer;
  60027. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  60028. };
  60029. declare module "babylonjs" {
  60030. export * from "babylonjs/Legacy/legacy";
  60031. }
  60032. declare module BABYLON {
  60033. /** Alias type for value that can be null */
  60034. export type Nullable<T> = T | null;
  60035. /**
  60036. * Alias type for number that are floats
  60037. * @ignorenaming
  60038. */
  60039. export type float = number;
  60040. /**
  60041. * Alias type for number that are doubles.
  60042. * @ignorenaming
  60043. */
  60044. export type double = number;
  60045. /**
  60046. * Alias type for number that are integer
  60047. * @ignorenaming
  60048. */
  60049. export type int = number;
  60050. /** Alias type for number array or Float32Array */
  60051. export type FloatArray = number[] | Float32Array;
  60052. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  60053. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  60054. /**
  60055. * Alias for types that can be used by a Buffer or VertexBuffer.
  60056. */
  60057. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  60058. /**
  60059. * Alias type for primitive types
  60060. * @ignorenaming
  60061. */
  60062. type Primitive = undefined | null | boolean | string | number | Function;
  60063. /**
  60064. * Type modifier to make all the properties of an object Readonly
  60065. */
  60066. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  60067. /**
  60068. * Type modifier to make all the properties of an object Readonly recursively
  60069. */
  60070. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  60071. /** @hidden */
  60072. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  60073. }
  60074. /** @hidden */
  60075. /** @hidden */
  60076. type DeepImmutableObject<T> = {
  60077. readonly [K in keyof T]: DeepImmutable<T[K]>;
  60078. };
  60079. }
  60080. declare module BABYLON {
  60081. /**
  60082. * Class containing a set of static utilities functions for arrays.
  60083. */
  60084. export class ArrayTools {
  60085. /**
  60086. * Returns an array of the given size filled with element built from the given constructor and the paramters
  60087. * @param size the number of element to construct and put in the array
  60088. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  60089. * @returns a new array filled with new objects
  60090. */
  60091. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  60092. }
  60093. }
  60094. declare module BABYLON {
  60095. /**
  60096. * Scalar computation library
  60097. */
  60098. export class Scalar {
  60099. /**
  60100. * Two pi constants convenient for computation.
  60101. */
  60102. static TwoPi: number;
  60103. /**
  60104. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  60105. * @param a number
  60106. * @param b number
  60107. * @param epsilon (default = 1.401298E-45)
  60108. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  60109. */
  60110. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  60111. /**
  60112. * Returns a string : the upper case translation of the number i to hexadecimal.
  60113. * @param i number
  60114. * @returns the upper case translation of the number i to hexadecimal.
  60115. */
  60116. static ToHex(i: number): string;
  60117. /**
  60118. * Returns -1 if value is negative and +1 is value is positive.
  60119. * @param value the value
  60120. * @returns the value itself if it's equal to zero.
  60121. */
  60122. static Sign(value: number): number;
  60123. /**
  60124. * Returns the value itself if it's between min and max.
  60125. * Returns min if the value is lower than min.
  60126. * Returns max if the value is greater than max.
  60127. * @param value the value to clmap
  60128. * @param min the min value to clamp to (default: 0)
  60129. * @param max the max value to clamp to (default: 1)
  60130. * @returns the clamped value
  60131. */
  60132. static Clamp(value: number, min?: number, max?: number): number;
  60133. /**
  60134. * the log2 of value.
  60135. * @param value the value to compute log2 of
  60136. * @returns the log2 of value.
  60137. */
  60138. static Log2(value: number): number;
  60139. /**
  60140. * Loops the value, so that it is never larger than length and never smaller than 0.
  60141. *
  60142. * This is similar to the modulo operator but it works with floating point numbers.
  60143. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  60144. * With t = 5 and length = 2.5, the result would be 0.0.
  60145. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  60146. * @param value the value
  60147. * @param length the length
  60148. * @returns the looped value
  60149. */
  60150. static Repeat(value: number, length: number): number;
  60151. /**
  60152. * Normalize the value between 0.0 and 1.0 using min and max values
  60153. * @param value value to normalize
  60154. * @param min max to normalize between
  60155. * @param max min to normalize between
  60156. * @returns the normalized value
  60157. */
  60158. static Normalize(value: number, min: number, max: number): number;
  60159. /**
  60160. * Denormalize the value from 0.0 and 1.0 using min and max values
  60161. * @param normalized value to denormalize
  60162. * @param min max to denormalize between
  60163. * @param max min to denormalize between
  60164. * @returns the denormalized value
  60165. */
  60166. static Denormalize(normalized: number, min: number, max: number): number;
  60167. /**
  60168. * Calculates the shortest difference between two given angles given in degrees.
  60169. * @param current current angle in degrees
  60170. * @param target target angle in degrees
  60171. * @returns the delta
  60172. */
  60173. static DeltaAngle(current: number, target: number): number;
  60174. /**
  60175. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  60176. * @param tx value
  60177. * @param length length
  60178. * @returns The returned value will move back and forth between 0 and length
  60179. */
  60180. static PingPong(tx: number, length: number): number;
  60181. /**
  60182. * Interpolates between min and max with smoothing at the limits.
  60183. *
  60184. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  60185. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  60186. * @param from from
  60187. * @param to to
  60188. * @param tx value
  60189. * @returns the smooth stepped value
  60190. */
  60191. static SmoothStep(from: number, to: number, tx: number): number;
  60192. /**
  60193. * Moves a value current towards target.
  60194. *
  60195. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  60196. * Negative values of maxDelta pushes the value away from target.
  60197. * @param current current value
  60198. * @param target target value
  60199. * @param maxDelta max distance to move
  60200. * @returns resulting value
  60201. */
  60202. static MoveTowards(current: number, target: number, maxDelta: number): number;
  60203. /**
  60204. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60205. *
  60206. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  60207. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  60208. * @param current current value
  60209. * @param target target value
  60210. * @param maxDelta max distance to move
  60211. * @returns resulting angle
  60212. */
  60213. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  60214. /**
  60215. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  60216. * @param start start value
  60217. * @param end target value
  60218. * @param amount amount to lerp between
  60219. * @returns the lerped value
  60220. */
  60221. static Lerp(start: number, end: number, amount: number): number;
  60222. /**
  60223. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60224. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  60225. * @param start start value
  60226. * @param end target value
  60227. * @param amount amount to lerp between
  60228. * @returns the lerped value
  60229. */
  60230. static LerpAngle(start: number, end: number, amount: number): number;
  60231. /**
  60232. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  60233. * @param a start value
  60234. * @param b target value
  60235. * @param value value between a and b
  60236. * @returns the inverseLerp value
  60237. */
  60238. static InverseLerp(a: number, b: number, value: number): number;
  60239. /**
  60240. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  60241. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  60242. * @param value1 spline value
  60243. * @param tangent1 spline value
  60244. * @param value2 spline value
  60245. * @param tangent2 spline value
  60246. * @param amount input value
  60247. * @returns hermite result
  60248. */
  60249. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  60250. /**
  60251. * Returns a random float number between and min and max values
  60252. * @param min min value of random
  60253. * @param max max value of random
  60254. * @returns random value
  60255. */
  60256. static RandomRange(min: number, max: number): number;
  60257. /**
  60258. * This function returns percentage of a number in a given range.
  60259. *
  60260. * RangeToPercent(40,20,60) will return 0.5 (50%)
  60261. * RangeToPercent(34,0,100) will return 0.34 (34%)
  60262. * @param number to convert to percentage
  60263. * @param min min range
  60264. * @param max max range
  60265. * @returns the percentage
  60266. */
  60267. static RangeToPercent(number: number, min: number, max: number): number;
  60268. /**
  60269. * This function returns number that corresponds to the percentage in a given range.
  60270. *
  60271. * PercentToRange(0.34,0,100) will return 34.
  60272. * @param percent to convert to number
  60273. * @param min min range
  60274. * @param max max range
  60275. * @returns the number
  60276. */
  60277. static PercentToRange(percent: number, min: number, max: number): number;
  60278. /**
  60279. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  60280. * @param angle The angle to normalize in radian.
  60281. * @return The converted angle.
  60282. */
  60283. static NormalizeRadians(angle: number): number;
  60284. }
  60285. }
  60286. declare module BABYLON {
  60287. /**
  60288. * Constant used to convert a value to gamma space
  60289. * @ignorenaming
  60290. */
  60291. export const ToGammaSpace: number;
  60292. /**
  60293. * Constant used to convert a value to linear space
  60294. * @ignorenaming
  60295. */
  60296. export const ToLinearSpace = 2.2;
  60297. /**
  60298. * Constant used to define the minimal number value in Babylon.js
  60299. * @ignorenaming
  60300. */
  60301. let Epsilon: number;
  60302. /**
  60303. * Class used to hold a RBG color
  60304. */
  60305. export class Color3 {
  60306. /**
  60307. * Defines the red component (between 0 and 1, default is 0)
  60308. */
  60309. r: number;
  60310. /**
  60311. * Defines the green component (between 0 and 1, default is 0)
  60312. */
  60313. g: number;
  60314. /**
  60315. * Defines the blue component (between 0 and 1, default is 0)
  60316. */
  60317. b: number;
  60318. /**
  60319. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  60320. * @param r defines the red component (between 0 and 1, default is 0)
  60321. * @param g defines the green component (between 0 and 1, default is 0)
  60322. * @param b defines the blue component (between 0 and 1, default is 0)
  60323. */
  60324. constructor(
  60325. /**
  60326. * Defines the red component (between 0 and 1, default is 0)
  60327. */
  60328. r?: number,
  60329. /**
  60330. * Defines the green component (between 0 and 1, default is 0)
  60331. */
  60332. g?: number,
  60333. /**
  60334. * Defines the blue component (between 0 and 1, default is 0)
  60335. */
  60336. b?: number);
  60337. /**
  60338. * Creates a string with the Color3 current values
  60339. * @returns the string representation of the Color3 object
  60340. */
  60341. toString(): string;
  60342. /**
  60343. * Returns the string "Color3"
  60344. * @returns "Color3"
  60345. */
  60346. getClassName(): string;
  60347. /**
  60348. * Compute the Color3 hash code
  60349. * @returns an unique number that can be used to hash Color3 objects
  60350. */
  60351. getHashCode(): number;
  60352. /**
  60353. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  60354. * @param array defines the array where to store the r,g,b components
  60355. * @param index defines an optional index in the target array to define where to start storing values
  60356. * @returns the current Color3 object
  60357. */
  60358. toArray(array: FloatArray, index?: number): Color3;
  60359. /**
  60360. * Returns a new Color4 object from the current Color3 and the given alpha
  60361. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  60362. * @returns a new Color4 object
  60363. */
  60364. toColor4(alpha?: number): Color4;
  60365. /**
  60366. * Returns a new array populated with 3 numeric elements : red, green and blue values
  60367. * @returns the new array
  60368. */
  60369. asArray(): number[];
  60370. /**
  60371. * Returns the luminance value
  60372. * @returns a float value
  60373. */
  60374. toLuminance(): number;
  60375. /**
  60376. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  60377. * @param otherColor defines the second operand
  60378. * @returns the new Color3 object
  60379. */
  60380. multiply(otherColor: DeepImmutable<Color3>): Color3;
  60381. /**
  60382. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  60383. * @param otherColor defines the second operand
  60384. * @param result defines the Color3 object where to store the result
  60385. * @returns the current Color3
  60386. */
  60387. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60388. /**
  60389. * Determines equality between Color3 objects
  60390. * @param otherColor defines the second operand
  60391. * @returns true if the rgb values are equal to the given ones
  60392. */
  60393. equals(otherColor: DeepImmutable<Color3>): boolean;
  60394. /**
  60395. * Determines equality between the current Color3 object and a set of r,b,g values
  60396. * @param r defines the red component to check
  60397. * @param g defines the green component to check
  60398. * @param b defines the blue component to check
  60399. * @returns true if the rgb values are equal to the given ones
  60400. */
  60401. equalsFloats(r: number, g: number, b: number): boolean;
  60402. /**
  60403. * Multiplies in place each rgb value by scale
  60404. * @param scale defines the scaling factor
  60405. * @returns the updated Color3
  60406. */
  60407. scale(scale: number): Color3;
  60408. /**
  60409. * Multiplies the rgb values by scale and stores the result into "result"
  60410. * @param scale defines the scaling factor
  60411. * @param result defines the Color3 object where to store the result
  60412. * @returns the unmodified current Color3
  60413. */
  60414. scaleToRef(scale: number, result: Color3): Color3;
  60415. /**
  60416. * Scale the current Color3 values by a factor and add the result to a given Color3
  60417. * @param scale defines the scale factor
  60418. * @param result defines color to store the result into
  60419. * @returns the unmodified current Color3
  60420. */
  60421. scaleAndAddToRef(scale: number, result: Color3): Color3;
  60422. /**
  60423. * Clamps the rgb values by the min and max values and stores the result into "result"
  60424. * @param min defines minimum clamping value (default is 0)
  60425. * @param max defines maximum clamping value (default is 1)
  60426. * @param result defines color to store the result into
  60427. * @returns the original Color3
  60428. */
  60429. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  60430. /**
  60431. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  60432. * @param otherColor defines the second operand
  60433. * @returns the new Color3
  60434. */
  60435. add(otherColor: DeepImmutable<Color3>): Color3;
  60436. /**
  60437. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  60438. * @param otherColor defines the second operand
  60439. * @param result defines Color3 object to store the result into
  60440. * @returns the unmodified current Color3
  60441. */
  60442. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60443. /**
  60444. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  60445. * @param otherColor defines the second operand
  60446. * @returns the new Color3
  60447. */
  60448. subtract(otherColor: DeepImmutable<Color3>): Color3;
  60449. /**
  60450. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  60451. * @param otherColor defines the second operand
  60452. * @param result defines Color3 object to store the result into
  60453. * @returns the unmodified current Color3
  60454. */
  60455. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60456. /**
  60457. * Copy the current object
  60458. * @returns a new Color3 copied the current one
  60459. */
  60460. clone(): Color3;
  60461. /**
  60462. * Copies the rgb values from the source in the current Color3
  60463. * @param source defines the source Color3 object
  60464. * @returns the updated Color3 object
  60465. */
  60466. copyFrom(source: DeepImmutable<Color3>): Color3;
  60467. /**
  60468. * Updates the Color3 rgb values from the given floats
  60469. * @param r defines the red component to read from
  60470. * @param g defines the green component to read from
  60471. * @param b defines the blue component to read from
  60472. * @returns the current Color3 object
  60473. */
  60474. copyFromFloats(r: number, g: number, b: number): Color3;
  60475. /**
  60476. * Updates the Color3 rgb values from the given floats
  60477. * @param r defines the red component to read from
  60478. * @param g defines the green component to read from
  60479. * @param b defines the blue component to read from
  60480. * @returns the current Color3 object
  60481. */
  60482. set(r: number, g: number, b: number): Color3;
  60483. /**
  60484. * Compute the Color3 hexadecimal code as a string
  60485. * @returns a string containing the hexadecimal representation of the Color3 object
  60486. */
  60487. toHexString(): string;
  60488. /**
  60489. * Computes a new Color3 converted from the current one to linear space
  60490. * @returns a new Color3 object
  60491. */
  60492. toLinearSpace(): Color3;
  60493. /**
  60494. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  60495. * @param convertedColor defines the Color3 object where to store the linear space version
  60496. * @returns the unmodified Color3
  60497. */
  60498. toLinearSpaceToRef(convertedColor: Color3): Color3;
  60499. /**
  60500. * Computes a new Color3 converted from the current one to gamma space
  60501. * @returns a new Color3 object
  60502. */
  60503. toGammaSpace(): Color3;
  60504. /**
  60505. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  60506. * @param convertedColor defines the Color3 object where to store the gamma space version
  60507. * @returns the unmodified Color3
  60508. */
  60509. toGammaSpaceToRef(convertedColor: Color3): Color3;
  60510. private static _BlackReadOnly;
  60511. /**
  60512. * Creates a new Color3 from the string containing valid hexadecimal values
  60513. * @param hex defines a string containing valid hexadecimal values
  60514. * @returns a new Color3 object
  60515. */
  60516. static FromHexString(hex: string): Color3;
  60517. /**
  60518. * Creates a new Color3 from the starting index of the given array
  60519. * @param array defines the source array
  60520. * @param offset defines an offset in the source array
  60521. * @returns a new Color3 object
  60522. */
  60523. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  60524. /**
  60525. * Creates a new Color3 from integer values (< 256)
  60526. * @param r defines the red component to read from (value between 0 and 255)
  60527. * @param g defines the green component to read from (value between 0 and 255)
  60528. * @param b defines the blue component to read from (value between 0 and 255)
  60529. * @returns a new Color3 object
  60530. */
  60531. static FromInts(r: number, g: number, b: number): Color3;
  60532. /**
  60533. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60534. * @param start defines the start Color3 value
  60535. * @param end defines the end Color3 value
  60536. * @param amount defines the gradient value between start and end
  60537. * @returns a new Color3 object
  60538. */
  60539. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  60540. /**
  60541. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60542. * @param left defines the start value
  60543. * @param right defines the end value
  60544. * @param amount defines the gradient factor
  60545. * @param result defines the Color3 object where to store the result
  60546. */
  60547. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  60548. /**
  60549. * Returns a Color3 value containing a red color
  60550. * @returns a new Color3 object
  60551. */
  60552. static Red(): Color3;
  60553. /**
  60554. * Returns a Color3 value containing a green color
  60555. * @returns a new Color3 object
  60556. */
  60557. static Green(): Color3;
  60558. /**
  60559. * Returns a Color3 value containing a blue color
  60560. * @returns a new Color3 object
  60561. */
  60562. static Blue(): Color3;
  60563. /**
  60564. * Returns a Color3 value containing a black color
  60565. * @returns a new Color3 object
  60566. */
  60567. static Black(): Color3;
  60568. /**
  60569. * Gets a Color3 value containing a black color that must not be updated
  60570. */
  60571. static readonly BlackReadOnly: DeepImmutable<Color3>;
  60572. /**
  60573. * Returns a Color3 value containing a white color
  60574. * @returns a new Color3 object
  60575. */
  60576. static White(): Color3;
  60577. /**
  60578. * Returns a Color3 value containing a purple color
  60579. * @returns a new Color3 object
  60580. */
  60581. static Purple(): Color3;
  60582. /**
  60583. * Returns a Color3 value containing a magenta color
  60584. * @returns a new Color3 object
  60585. */
  60586. static Magenta(): Color3;
  60587. /**
  60588. * Returns a Color3 value containing a yellow color
  60589. * @returns a new Color3 object
  60590. */
  60591. static Yellow(): Color3;
  60592. /**
  60593. * Returns a Color3 value containing a gray color
  60594. * @returns a new Color3 object
  60595. */
  60596. static Gray(): Color3;
  60597. /**
  60598. * Returns a Color3 value containing a teal color
  60599. * @returns a new Color3 object
  60600. */
  60601. static Teal(): Color3;
  60602. /**
  60603. * Returns a Color3 value containing a random color
  60604. * @returns a new Color3 object
  60605. */
  60606. static Random(): Color3;
  60607. }
  60608. /**
  60609. * Class used to hold a RBGA color
  60610. */
  60611. export class Color4 {
  60612. /**
  60613. * Defines the red component (between 0 and 1, default is 0)
  60614. */
  60615. r: number;
  60616. /**
  60617. * Defines the green component (between 0 and 1, default is 0)
  60618. */
  60619. g: number;
  60620. /**
  60621. * Defines the blue component (between 0 and 1, default is 0)
  60622. */
  60623. b: number;
  60624. /**
  60625. * Defines the alpha component (between 0 and 1, default is 1)
  60626. */
  60627. a: number;
  60628. /**
  60629. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  60630. * @param r defines the red component (between 0 and 1, default is 0)
  60631. * @param g defines the green component (between 0 and 1, default is 0)
  60632. * @param b defines the blue component (between 0 and 1, default is 0)
  60633. * @param a defines the alpha component (between 0 and 1, default is 1)
  60634. */
  60635. constructor(
  60636. /**
  60637. * Defines the red component (between 0 and 1, default is 0)
  60638. */
  60639. r?: number,
  60640. /**
  60641. * Defines the green component (between 0 and 1, default is 0)
  60642. */
  60643. g?: number,
  60644. /**
  60645. * Defines the blue component (between 0 and 1, default is 0)
  60646. */
  60647. b?: number,
  60648. /**
  60649. * Defines the alpha component (between 0 and 1, default is 1)
  60650. */
  60651. a?: number);
  60652. /**
  60653. * Adds in place the given Color4 values to the current Color4 object
  60654. * @param right defines the second operand
  60655. * @returns the current updated Color4 object
  60656. */
  60657. addInPlace(right: DeepImmutable<Color4>): Color4;
  60658. /**
  60659. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  60660. * @returns the new array
  60661. */
  60662. asArray(): number[];
  60663. /**
  60664. * Stores from the starting index in the given array the Color4 successive values
  60665. * @param array defines the array where to store the r,g,b components
  60666. * @param index defines an optional index in the target array to define where to start storing values
  60667. * @returns the current Color4 object
  60668. */
  60669. toArray(array: number[], index?: number): Color4;
  60670. /**
  60671. * Determines equality between Color4 objects
  60672. * @param otherColor defines the second operand
  60673. * @returns true if the rgba values are equal to the given ones
  60674. */
  60675. equals(otherColor: DeepImmutable<Color4>): boolean;
  60676. /**
  60677. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60678. * @param right defines the second operand
  60679. * @returns a new Color4 object
  60680. */
  60681. add(right: DeepImmutable<Color4>): Color4;
  60682. /**
  60683. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60684. * @param right defines the second operand
  60685. * @returns a new Color4 object
  60686. */
  60687. subtract(right: DeepImmutable<Color4>): Color4;
  60688. /**
  60689. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60690. * @param right defines the second operand
  60691. * @param result defines the Color4 object where to store the result
  60692. * @returns the current Color4 object
  60693. */
  60694. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60695. /**
  60696. * Creates a new Color4 with the current Color4 values multiplied by scale
  60697. * @param scale defines the scaling factor to apply
  60698. * @returns a new Color4 object
  60699. */
  60700. scale(scale: number): Color4;
  60701. /**
  60702. * Multiplies the current Color4 values by scale and stores the result in "result"
  60703. * @param scale defines the scaling factor to apply
  60704. * @param result defines the Color4 object where to store the result
  60705. * @returns the current unmodified Color4
  60706. */
  60707. scaleToRef(scale: number, result: Color4): Color4;
  60708. /**
  60709. * Scale the current Color4 values by a factor and add the result to a given Color4
  60710. * @param scale defines the scale factor
  60711. * @param result defines the Color4 object where to store the result
  60712. * @returns the unmodified current Color4
  60713. */
  60714. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60715. /**
  60716. * Clamps the rgb values by the min and max values and stores the result into "result"
  60717. * @param min defines minimum clamping value (default is 0)
  60718. * @param max defines maximum clamping value (default is 1)
  60719. * @param result defines color to store the result into.
  60720. * @returns the cuurent Color4
  60721. */
  60722. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60723. /**
  60724. * Multipy an Color4 value by another and return a new Color4 object
  60725. * @param color defines the Color4 value to multiply by
  60726. * @returns a new Color4 object
  60727. */
  60728. multiply(color: Color4): Color4;
  60729. /**
  60730. * Multipy a Color4 value by another and push the result in a reference value
  60731. * @param color defines the Color4 value to multiply by
  60732. * @param result defines the Color4 to fill the result in
  60733. * @returns the result Color4
  60734. */
  60735. multiplyToRef(color: Color4, result: Color4): Color4;
  60736. /**
  60737. * Creates a string with the Color4 current values
  60738. * @returns the string representation of the Color4 object
  60739. */
  60740. toString(): string;
  60741. /**
  60742. * Returns the string "Color4"
  60743. * @returns "Color4"
  60744. */
  60745. getClassName(): string;
  60746. /**
  60747. * Compute the Color4 hash code
  60748. * @returns an unique number that can be used to hash Color4 objects
  60749. */
  60750. getHashCode(): number;
  60751. /**
  60752. * Creates a new Color4 copied from the current one
  60753. * @returns a new Color4 object
  60754. */
  60755. clone(): Color4;
  60756. /**
  60757. * Copies the given Color4 values into the current one
  60758. * @param source defines the source Color4 object
  60759. * @returns the current updated Color4 object
  60760. */
  60761. copyFrom(source: Color4): Color4;
  60762. /**
  60763. * Copies the given float values into the current one
  60764. * @param r defines the red component to read from
  60765. * @param g defines the green component to read from
  60766. * @param b defines the blue component to read from
  60767. * @param a defines the alpha component to read from
  60768. * @returns the current updated Color4 object
  60769. */
  60770. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60771. /**
  60772. * Copies the given float values into the current one
  60773. * @param r defines the red component to read from
  60774. * @param g defines the green component to read from
  60775. * @param b defines the blue component to read from
  60776. * @param a defines the alpha component to read from
  60777. * @returns the current updated Color4 object
  60778. */
  60779. set(r: number, g: number, b: number, a: number): Color4;
  60780. /**
  60781. * Compute the Color4 hexadecimal code as a string
  60782. * @returns a string containing the hexadecimal representation of the Color4 object
  60783. */
  60784. toHexString(): string;
  60785. /**
  60786. * Computes a new Color4 converted from the current one to linear space
  60787. * @returns a new Color4 object
  60788. */
  60789. toLinearSpace(): Color4;
  60790. /**
  60791. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60792. * @param convertedColor defines the Color4 object where to store the linear space version
  60793. * @returns the unmodified Color4
  60794. */
  60795. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60796. /**
  60797. * Computes a new Color4 converted from the current one to gamma space
  60798. * @returns a new Color4 object
  60799. */
  60800. toGammaSpace(): Color4;
  60801. /**
  60802. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60803. * @param convertedColor defines the Color4 object where to store the gamma space version
  60804. * @returns the unmodified Color4
  60805. */
  60806. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60807. /**
  60808. * Creates a new Color4 from the string containing valid hexadecimal values
  60809. * @param hex defines a string containing valid hexadecimal values
  60810. * @returns a new Color4 object
  60811. */
  60812. static FromHexString(hex: string): Color4;
  60813. /**
  60814. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60815. * @param left defines the start value
  60816. * @param right defines the end value
  60817. * @param amount defines the gradient factor
  60818. * @returns a new Color4 object
  60819. */
  60820. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60821. /**
  60822. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60823. * @param left defines the start value
  60824. * @param right defines the end value
  60825. * @param amount defines the gradient factor
  60826. * @param result defines the Color4 object where to store data
  60827. */
  60828. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60829. /**
  60830. * Creates a new Color4 from a Color3 and an alpha value
  60831. * @param color3 defines the source Color3 to read from
  60832. * @param alpha defines the alpha component (1.0 by default)
  60833. * @returns a new Color4 object
  60834. */
  60835. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60836. /**
  60837. * Creates a new Color4 from the starting index element of the given array
  60838. * @param array defines the source array to read from
  60839. * @param offset defines the offset in the source array
  60840. * @returns a new Color4 object
  60841. */
  60842. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60843. /**
  60844. * Creates a new Color3 from integer values (< 256)
  60845. * @param r defines the red component to read from (value between 0 and 255)
  60846. * @param g defines the green component to read from (value between 0 and 255)
  60847. * @param b defines the blue component to read from (value between 0 and 255)
  60848. * @param a defines the alpha component to read from (value between 0 and 255)
  60849. * @returns a new Color3 object
  60850. */
  60851. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60852. /**
  60853. * Check the content of a given array and convert it to an array containing RGBA data
  60854. * If the original array was already containing count * 4 values then it is returned directly
  60855. * @param colors defines the array to check
  60856. * @param count defines the number of RGBA data to expect
  60857. * @returns an array containing count * 4 values (RGBA)
  60858. */
  60859. static CheckColors4(colors: number[], count: number): number[];
  60860. }
  60861. /**
  60862. * Class representing a vector containing 2 coordinates
  60863. */
  60864. export class Vector2 {
  60865. /** defines the first coordinate */
  60866. x: number;
  60867. /** defines the second coordinate */
  60868. y: number;
  60869. /**
  60870. * Creates a new Vector2 from the given x and y coordinates
  60871. * @param x defines the first coordinate
  60872. * @param y defines the second coordinate
  60873. */
  60874. constructor(
  60875. /** defines the first coordinate */
  60876. x?: number,
  60877. /** defines the second coordinate */
  60878. y?: number);
  60879. /**
  60880. * Gets a string with the Vector2 coordinates
  60881. * @returns a string with the Vector2 coordinates
  60882. */
  60883. toString(): string;
  60884. /**
  60885. * Gets class name
  60886. * @returns the string "Vector2"
  60887. */
  60888. getClassName(): string;
  60889. /**
  60890. * Gets current vector hash code
  60891. * @returns the Vector2 hash code as a number
  60892. */
  60893. getHashCode(): number;
  60894. /**
  60895. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60896. * @param array defines the source array
  60897. * @param index defines the offset in source array
  60898. * @returns the current Vector2
  60899. */
  60900. toArray(array: FloatArray, index?: number): Vector2;
  60901. /**
  60902. * Copy the current vector to an array
  60903. * @returns a new array with 2 elements: the Vector2 coordinates.
  60904. */
  60905. asArray(): number[];
  60906. /**
  60907. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60908. * @param source defines the source Vector2
  60909. * @returns the current updated Vector2
  60910. */
  60911. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60912. /**
  60913. * Sets the Vector2 coordinates with the given floats
  60914. * @param x defines the first coordinate
  60915. * @param y defines the second coordinate
  60916. * @returns the current updated Vector2
  60917. */
  60918. copyFromFloats(x: number, y: number): Vector2;
  60919. /**
  60920. * Sets the Vector2 coordinates with the given floats
  60921. * @param x defines the first coordinate
  60922. * @param y defines the second coordinate
  60923. * @returns the current updated Vector2
  60924. */
  60925. set(x: number, y: number): Vector2;
  60926. /**
  60927. * Add another vector with the current one
  60928. * @param otherVector defines the other vector
  60929. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60930. */
  60931. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60932. /**
  60933. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60934. * @param otherVector defines the other vector
  60935. * @param result defines the target vector
  60936. * @returns the unmodified current Vector2
  60937. */
  60938. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60939. /**
  60940. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60941. * @param otherVector defines the other vector
  60942. * @returns the current updated Vector2
  60943. */
  60944. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60945. /**
  60946. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60947. * @param otherVector defines the other vector
  60948. * @returns a new Vector2
  60949. */
  60950. addVector3(otherVector: Vector3): Vector2;
  60951. /**
  60952. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60953. * @param otherVector defines the other vector
  60954. * @returns a new Vector2
  60955. */
  60956. subtract(otherVector: Vector2): Vector2;
  60957. /**
  60958. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60959. * @param otherVector defines the other vector
  60960. * @param result defines the target vector
  60961. * @returns the unmodified current Vector2
  60962. */
  60963. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60964. /**
  60965. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60966. * @param otherVector defines the other vector
  60967. * @returns the current updated Vector2
  60968. */
  60969. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60970. /**
  60971. * Multiplies in place the current Vector2 coordinates by the given ones
  60972. * @param otherVector defines the other vector
  60973. * @returns the current updated Vector2
  60974. */
  60975. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60976. /**
  60977. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60978. * @param otherVector defines the other vector
  60979. * @returns a new Vector2
  60980. */
  60981. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60982. /**
  60983. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60984. * @param otherVector defines the other vector
  60985. * @param result defines the target vector
  60986. * @returns the unmodified current Vector2
  60987. */
  60988. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60989. /**
  60990. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60991. * @param x defines the first coordinate
  60992. * @param y defines the second coordinate
  60993. * @returns a new Vector2
  60994. */
  60995. multiplyByFloats(x: number, y: number): Vector2;
  60996. /**
  60997. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60998. * @param otherVector defines the other vector
  60999. * @returns a new Vector2
  61000. */
  61001. divide(otherVector: Vector2): Vector2;
  61002. /**
  61003. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  61004. * @param otherVector defines the other vector
  61005. * @param result defines the target vector
  61006. * @returns the unmodified current Vector2
  61007. */
  61008. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  61009. /**
  61010. * Divides the current Vector2 coordinates by the given ones
  61011. * @param otherVector defines the other vector
  61012. * @returns the current updated Vector2
  61013. */
  61014. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  61015. /**
  61016. * Gets a new Vector2 with current Vector2 negated coordinates
  61017. * @returns a new Vector2
  61018. */
  61019. negate(): Vector2;
  61020. /**
  61021. * Multiply the Vector2 coordinates by scale
  61022. * @param scale defines the scaling factor
  61023. * @returns the current updated Vector2
  61024. */
  61025. scaleInPlace(scale: number): Vector2;
  61026. /**
  61027. * Returns a new Vector2 scaled by "scale" from the current Vector2
  61028. * @param scale defines the scaling factor
  61029. * @returns a new Vector2
  61030. */
  61031. scale(scale: number): Vector2;
  61032. /**
  61033. * Scale the current Vector2 values by a factor to a given Vector2
  61034. * @param scale defines the scale factor
  61035. * @param result defines the Vector2 object where to store the result
  61036. * @returns the unmodified current Vector2
  61037. */
  61038. scaleToRef(scale: number, result: Vector2): Vector2;
  61039. /**
  61040. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  61041. * @param scale defines the scale factor
  61042. * @param result defines the Vector2 object where to store the result
  61043. * @returns the unmodified current Vector2
  61044. */
  61045. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  61046. /**
  61047. * Gets a boolean if two vectors are equals
  61048. * @param otherVector defines the other vector
  61049. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  61050. */
  61051. equals(otherVector: DeepImmutable<Vector2>): boolean;
  61052. /**
  61053. * Gets a boolean if two vectors are equals (using an epsilon value)
  61054. * @param otherVector defines the other vector
  61055. * @param epsilon defines the minimal distance to consider equality
  61056. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  61057. */
  61058. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  61059. /**
  61060. * Gets a new Vector2 from current Vector2 floored values
  61061. * @returns a new Vector2
  61062. */
  61063. floor(): Vector2;
  61064. /**
  61065. * Gets a new Vector2 from current Vector2 floored values
  61066. * @returns a new Vector2
  61067. */
  61068. fract(): Vector2;
  61069. /**
  61070. * Gets the length of the vector
  61071. * @returns the vector length (float)
  61072. */
  61073. length(): number;
  61074. /**
  61075. * Gets the vector squared length
  61076. * @returns the vector squared length (float)
  61077. */
  61078. lengthSquared(): number;
  61079. /**
  61080. * Normalize the vector
  61081. * @returns the current updated Vector2
  61082. */
  61083. normalize(): Vector2;
  61084. /**
  61085. * Gets a new Vector2 copied from the Vector2
  61086. * @returns a new Vector2
  61087. */
  61088. clone(): Vector2;
  61089. /**
  61090. * Gets a new Vector2(0, 0)
  61091. * @returns a new Vector2
  61092. */
  61093. static Zero(): Vector2;
  61094. /**
  61095. * Gets a new Vector2(1, 1)
  61096. * @returns a new Vector2
  61097. */
  61098. static One(): Vector2;
  61099. /**
  61100. * Gets a new Vector2 set from the given index element of the given array
  61101. * @param array defines the data source
  61102. * @param offset defines the offset in the data source
  61103. * @returns a new Vector2
  61104. */
  61105. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  61106. /**
  61107. * Sets "result" from the given index element of the given array
  61108. * @param array defines the data source
  61109. * @param offset defines the offset in the data source
  61110. * @param result defines the target vector
  61111. */
  61112. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  61113. /**
  61114. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  61115. * @param value1 defines 1st point of control
  61116. * @param value2 defines 2nd point of control
  61117. * @param value3 defines 3rd point of control
  61118. * @param value4 defines 4th point of control
  61119. * @param amount defines the interpolation factor
  61120. * @returns a new Vector2
  61121. */
  61122. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  61123. /**
  61124. * 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".
  61125. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  61126. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  61127. * @param value defines the value to clamp
  61128. * @param min defines the lower limit
  61129. * @param max defines the upper limit
  61130. * @returns a new Vector2
  61131. */
  61132. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  61133. /**
  61134. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  61135. * @param value1 defines the 1st control point
  61136. * @param tangent1 defines the outgoing tangent
  61137. * @param value2 defines the 2nd control point
  61138. * @param tangent2 defines the incoming tangent
  61139. * @param amount defines the interpolation factor
  61140. * @returns a new Vector2
  61141. */
  61142. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  61143. /**
  61144. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  61145. * @param start defines the start vector
  61146. * @param end defines the end vector
  61147. * @param amount defines the interpolation factor
  61148. * @returns a new Vector2
  61149. */
  61150. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  61151. /**
  61152. * Gets the dot product of the vector "left" and the vector "right"
  61153. * @param left defines first vector
  61154. * @param right defines second vector
  61155. * @returns the dot product (float)
  61156. */
  61157. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  61158. /**
  61159. * Returns a new Vector2 equal to the normalized given vector
  61160. * @param vector defines the vector to normalize
  61161. * @returns a new Vector2
  61162. */
  61163. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  61164. /**
  61165. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  61166. * @param left defines 1st vector
  61167. * @param right defines 2nd vector
  61168. * @returns a new Vector2
  61169. */
  61170. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61171. /**
  61172. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  61173. * @param left defines 1st vector
  61174. * @param right defines 2nd vector
  61175. * @returns a new Vector2
  61176. */
  61177. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61178. /**
  61179. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  61180. * @param vector defines the vector to transform
  61181. * @param transformation defines the matrix to apply
  61182. * @returns a new Vector2
  61183. */
  61184. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  61185. /**
  61186. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  61187. * @param vector defines the vector to transform
  61188. * @param transformation defines the matrix to apply
  61189. * @param result defines the target vector
  61190. */
  61191. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  61192. /**
  61193. * Determines if a given vector is included in a triangle
  61194. * @param p defines the vector to test
  61195. * @param p0 defines 1st triangle point
  61196. * @param p1 defines 2nd triangle point
  61197. * @param p2 defines 3rd triangle point
  61198. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  61199. */
  61200. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  61201. /**
  61202. * Gets the distance between the vectors "value1" and "value2"
  61203. * @param value1 defines first vector
  61204. * @param value2 defines second vector
  61205. * @returns the distance between vectors
  61206. */
  61207. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61208. /**
  61209. * Returns the squared distance between the vectors "value1" and "value2"
  61210. * @param value1 defines first vector
  61211. * @param value2 defines second vector
  61212. * @returns the squared distance between vectors
  61213. */
  61214. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61215. /**
  61216. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  61217. * @param value1 defines first vector
  61218. * @param value2 defines second vector
  61219. * @returns a new Vector2
  61220. */
  61221. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  61222. /**
  61223. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  61224. * @param p defines the middle point
  61225. * @param segA defines one point of the segment
  61226. * @param segB defines the other point of the segment
  61227. * @returns the shortest distance
  61228. */
  61229. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  61230. }
  61231. /**
  61232. * Classed used to store (x,y,z) vector representation
  61233. * A Vector3 is the main object used in 3D geometry
  61234. * It can represent etiher the coordinates of a point the space, either a direction
  61235. * Reminder: js uses a left handed forward facing system
  61236. */
  61237. export class Vector3 {
  61238. /**
  61239. * Defines the first coordinates (on X axis)
  61240. */
  61241. x: number;
  61242. /**
  61243. * Defines the second coordinates (on Y axis)
  61244. */
  61245. y: number;
  61246. /**
  61247. * Defines the third coordinates (on Z axis)
  61248. */
  61249. z: number;
  61250. private static _UpReadOnly;
  61251. /**
  61252. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  61253. * @param x defines the first coordinates (on X axis)
  61254. * @param y defines the second coordinates (on Y axis)
  61255. * @param z defines the third coordinates (on Z axis)
  61256. */
  61257. constructor(
  61258. /**
  61259. * Defines the first coordinates (on X axis)
  61260. */
  61261. x?: number,
  61262. /**
  61263. * Defines the second coordinates (on Y axis)
  61264. */
  61265. y?: number,
  61266. /**
  61267. * Defines the third coordinates (on Z axis)
  61268. */
  61269. z?: number);
  61270. /**
  61271. * Creates a string representation of the Vector3
  61272. * @returns a string with the Vector3 coordinates.
  61273. */
  61274. toString(): string;
  61275. /**
  61276. * Gets the class name
  61277. * @returns the string "Vector3"
  61278. */
  61279. getClassName(): string;
  61280. /**
  61281. * Creates the Vector3 hash code
  61282. * @returns a number which tends to be unique between Vector3 instances
  61283. */
  61284. getHashCode(): number;
  61285. /**
  61286. * Creates an array containing three elements : the coordinates of the Vector3
  61287. * @returns a new array of numbers
  61288. */
  61289. asArray(): number[];
  61290. /**
  61291. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  61292. * @param array defines the destination array
  61293. * @param index defines the offset in the destination array
  61294. * @returns the current Vector3
  61295. */
  61296. toArray(array: FloatArray, index?: number): Vector3;
  61297. /**
  61298. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  61299. * @returns a new Quaternion object, computed from the Vector3 coordinates
  61300. */
  61301. toQuaternion(): Quaternion;
  61302. /**
  61303. * Adds the given vector to the current Vector3
  61304. * @param otherVector defines the second operand
  61305. * @returns the current updated Vector3
  61306. */
  61307. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61308. /**
  61309. * Adds the given coordinates to the current Vector3
  61310. * @param x defines the x coordinate of the operand
  61311. * @param y defines the y coordinate of the operand
  61312. * @param z defines the z coordinate of the operand
  61313. * @returns the current updated Vector3
  61314. */
  61315. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61316. /**
  61317. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  61318. * @param otherVector defines the second operand
  61319. * @returns the resulting Vector3
  61320. */
  61321. add(otherVector: DeepImmutable<Vector3>): Vector3;
  61322. /**
  61323. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  61324. * @param otherVector defines the second operand
  61325. * @param result defines the Vector3 object where to store the result
  61326. * @returns the current Vector3
  61327. */
  61328. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61329. /**
  61330. * Subtract the given vector from the current Vector3
  61331. * @param otherVector defines the second operand
  61332. * @returns the current updated Vector3
  61333. */
  61334. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61335. /**
  61336. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  61337. * @param otherVector defines the second operand
  61338. * @returns the resulting Vector3
  61339. */
  61340. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  61341. /**
  61342. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  61343. * @param otherVector defines the second operand
  61344. * @param result defines the Vector3 object where to store the result
  61345. * @returns the current Vector3
  61346. */
  61347. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61348. /**
  61349. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  61350. * @param x defines the x coordinate of the operand
  61351. * @param y defines the y coordinate of the operand
  61352. * @param z defines the z coordinate of the operand
  61353. * @returns the resulting Vector3
  61354. */
  61355. subtractFromFloats(x: number, y: number, z: number): Vector3;
  61356. /**
  61357. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  61358. * @param x defines the x coordinate of the operand
  61359. * @param y defines the y coordinate of the operand
  61360. * @param z defines the z coordinate of the operand
  61361. * @param result defines the Vector3 object where to store the result
  61362. * @returns the current Vector3
  61363. */
  61364. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  61365. /**
  61366. * Gets a new Vector3 set with the current Vector3 negated coordinates
  61367. * @returns a new Vector3
  61368. */
  61369. negate(): Vector3;
  61370. /**
  61371. * Multiplies the Vector3 coordinates by the float "scale"
  61372. * @param scale defines the multiplier factor
  61373. * @returns the current updated Vector3
  61374. */
  61375. scaleInPlace(scale: number): Vector3;
  61376. /**
  61377. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  61378. * @param scale defines the multiplier factor
  61379. * @returns a new Vector3
  61380. */
  61381. scale(scale: number): Vector3;
  61382. /**
  61383. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  61384. * @param scale defines the multiplier factor
  61385. * @param result defines the Vector3 object where to store the result
  61386. * @returns the current Vector3
  61387. */
  61388. scaleToRef(scale: number, result: Vector3): Vector3;
  61389. /**
  61390. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  61391. * @param scale defines the scale factor
  61392. * @param result defines the Vector3 object where to store the result
  61393. * @returns the unmodified current Vector3
  61394. */
  61395. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  61396. /**
  61397. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  61398. * @param otherVector defines the second operand
  61399. * @returns true if both vectors are equals
  61400. */
  61401. equals(otherVector: DeepImmutable<Vector3>): boolean;
  61402. /**
  61403. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  61404. * @param otherVector defines the second operand
  61405. * @param epsilon defines the minimal distance to define values as equals
  61406. * @returns true if both vectors are distant less than epsilon
  61407. */
  61408. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  61409. /**
  61410. * Returns true if the current Vector3 coordinates equals the given floats
  61411. * @param x defines the x coordinate of the operand
  61412. * @param y defines the y coordinate of the operand
  61413. * @param z defines the z coordinate of the operand
  61414. * @returns true if both vectors are equals
  61415. */
  61416. equalsToFloats(x: number, y: number, z: number): boolean;
  61417. /**
  61418. * Multiplies the current Vector3 coordinates by the given ones
  61419. * @param otherVector defines the second operand
  61420. * @returns the current updated Vector3
  61421. */
  61422. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61423. /**
  61424. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  61425. * @param otherVector defines the second operand
  61426. * @returns the new Vector3
  61427. */
  61428. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  61429. /**
  61430. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  61431. * @param otherVector defines the second operand
  61432. * @param result defines the Vector3 object where to store the result
  61433. * @returns the current Vector3
  61434. */
  61435. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61436. /**
  61437. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  61438. * @param x defines the x coordinate of the operand
  61439. * @param y defines the y coordinate of the operand
  61440. * @param z defines the z coordinate of the operand
  61441. * @returns the new Vector3
  61442. */
  61443. multiplyByFloats(x: number, y: number, z: number): Vector3;
  61444. /**
  61445. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  61446. * @param otherVector defines the second operand
  61447. * @returns the new Vector3
  61448. */
  61449. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  61450. /**
  61451. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  61452. * @param otherVector defines the second operand
  61453. * @param result defines the Vector3 object where to store the result
  61454. * @returns the current Vector3
  61455. */
  61456. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61457. /**
  61458. * Divides the current Vector3 coordinates by the given ones.
  61459. * @param otherVector defines the second operand
  61460. * @returns the current updated Vector3
  61461. */
  61462. divideInPlace(otherVector: Vector3): Vector3;
  61463. /**
  61464. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  61465. * @param other defines the second operand
  61466. * @returns the current updated Vector3
  61467. */
  61468. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61469. /**
  61470. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  61471. * @param other defines the second operand
  61472. * @returns the current updated Vector3
  61473. */
  61474. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61475. /**
  61476. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  61477. * @param x defines the x coordinate of the operand
  61478. * @param y defines the y coordinate of the operand
  61479. * @param z defines the z coordinate of the operand
  61480. * @returns the current updated Vector3
  61481. */
  61482. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61483. /**
  61484. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  61485. * @param x defines the x coordinate of the operand
  61486. * @param y defines the y coordinate of the operand
  61487. * @param z defines the z coordinate of the operand
  61488. * @returns the current updated Vector3
  61489. */
  61490. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61491. /**
  61492. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  61493. * Check if is non uniform within a certain amount of decimal places to account for this
  61494. * @param epsilon the amount the values can differ
  61495. * @returns if the the vector is non uniform to a certain number of decimal places
  61496. */
  61497. isNonUniformWithinEpsilon(epsilon: number): boolean;
  61498. /**
  61499. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  61500. */
  61501. readonly isNonUniform: boolean;
  61502. /**
  61503. * Gets a new Vector3 from current Vector3 floored values
  61504. * @returns a new Vector3
  61505. */
  61506. floor(): Vector3;
  61507. /**
  61508. * Gets a new Vector3 from current Vector3 floored values
  61509. * @returns a new Vector3
  61510. */
  61511. fract(): Vector3;
  61512. /**
  61513. * Gets the length of the Vector3
  61514. * @returns the length of the Vecto3
  61515. */
  61516. length(): number;
  61517. /**
  61518. * Gets the squared length of the Vector3
  61519. * @returns squared length of the Vector3
  61520. */
  61521. lengthSquared(): number;
  61522. /**
  61523. * Normalize the current Vector3.
  61524. * Please note that this is an in place operation.
  61525. * @returns the current updated Vector3
  61526. */
  61527. normalize(): Vector3;
  61528. /**
  61529. * Reorders the x y z properties of the vector in place
  61530. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  61531. * @returns the current updated vector
  61532. */
  61533. reorderInPlace(order: string): this;
  61534. /**
  61535. * Rotates the vector around 0,0,0 by a quaternion
  61536. * @param quaternion the rotation quaternion
  61537. * @param result vector to store the result
  61538. * @returns the resulting vector
  61539. */
  61540. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  61541. /**
  61542. * Rotates a vector around a given point
  61543. * @param quaternion the rotation quaternion
  61544. * @param point the point to rotate around
  61545. * @param result vector to store the result
  61546. * @returns the resulting vector
  61547. */
  61548. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  61549. /**
  61550. * Normalize the current Vector3 with the given input length.
  61551. * Please note that this is an in place operation.
  61552. * @param len the length of the vector
  61553. * @returns the current updated Vector3
  61554. */
  61555. normalizeFromLength(len: number): Vector3;
  61556. /**
  61557. * Normalize the current Vector3 to a new vector
  61558. * @returns the new Vector3
  61559. */
  61560. normalizeToNew(): Vector3;
  61561. /**
  61562. * Normalize the current Vector3 to the reference
  61563. * @param reference define the Vector3 to update
  61564. * @returns the updated Vector3
  61565. */
  61566. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  61567. /**
  61568. * Creates a new Vector3 copied from the current Vector3
  61569. * @returns the new Vector3
  61570. */
  61571. clone(): Vector3;
  61572. /**
  61573. * Copies the given vector coordinates to the current Vector3 ones
  61574. * @param source defines the source Vector3
  61575. * @returns the current updated Vector3
  61576. */
  61577. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  61578. /**
  61579. * Copies the given floats to the current Vector3 coordinates
  61580. * @param x defines the x coordinate of the operand
  61581. * @param y defines the y coordinate of the operand
  61582. * @param z defines the z coordinate of the operand
  61583. * @returns the current updated Vector3
  61584. */
  61585. copyFromFloats(x: number, y: number, z: number): Vector3;
  61586. /**
  61587. * Copies the given floats to the current Vector3 coordinates
  61588. * @param x defines the x coordinate of the operand
  61589. * @param y defines the y coordinate of the operand
  61590. * @param z defines the z coordinate of the operand
  61591. * @returns the current updated Vector3
  61592. */
  61593. set(x: number, y: number, z: number): Vector3;
  61594. /**
  61595. * Copies the given float to the current Vector3 coordinates
  61596. * @param v defines the x, y and z coordinates of the operand
  61597. * @returns the current updated Vector3
  61598. */
  61599. setAll(v: number): Vector3;
  61600. /**
  61601. * Get the clip factor between two vectors
  61602. * @param vector0 defines the first operand
  61603. * @param vector1 defines the second operand
  61604. * @param axis defines the axis to use
  61605. * @param size defines the size along the axis
  61606. * @returns the clip factor
  61607. */
  61608. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  61609. /**
  61610. * Get angle between two vectors
  61611. * @param vector0 angle between vector0 and vector1
  61612. * @param vector1 angle between vector0 and vector1
  61613. * @param normal direction of the normal
  61614. * @return the angle between vector0 and vector1
  61615. */
  61616. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  61617. /**
  61618. * Returns a new Vector3 set from the index "offset" of the given array
  61619. * @param array defines the source array
  61620. * @param offset defines the offset in the source array
  61621. * @returns the new Vector3
  61622. */
  61623. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  61624. /**
  61625. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  61626. * This function is deprecated. Use FromArray instead
  61627. * @param array defines the source array
  61628. * @param offset defines the offset in the source array
  61629. * @returns the new Vector3
  61630. */
  61631. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  61632. /**
  61633. * Sets the given vector "result" with the element values from the index "offset" of the given array
  61634. * @param array defines the source array
  61635. * @param offset defines the offset in the source array
  61636. * @param result defines the Vector3 where to store the result
  61637. */
  61638. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  61639. /**
  61640. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  61641. * This function is deprecated. Use FromArrayToRef instead.
  61642. * @param array defines the source array
  61643. * @param offset defines the offset in the source array
  61644. * @param result defines the Vector3 where to store the result
  61645. */
  61646. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  61647. /**
  61648. * Sets the given vector "result" with the given floats.
  61649. * @param x defines the x coordinate of the source
  61650. * @param y defines the y coordinate of the source
  61651. * @param z defines the z coordinate of the source
  61652. * @param result defines the Vector3 where to store the result
  61653. */
  61654. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  61655. /**
  61656. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  61657. * @returns a new empty Vector3
  61658. */
  61659. static Zero(): Vector3;
  61660. /**
  61661. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  61662. * @returns a new unit Vector3
  61663. */
  61664. static One(): Vector3;
  61665. /**
  61666. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61667. * @returns a new up Vector3
  61668. */
  61669. static Up(): Vector3;
  61670. /**
  61671. * Gets a up Vector3 that must not be updated
  61672. */
  61673. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61674. /**
  61675. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61676. * @returns a new down Vector3
  61677. */
  61678. static Down(): Vector3;
  61679. /**
  61680. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61681. * @returns a new forward Vector3
  61682. */
  61683. static Forward(): Vector3;
  61684. /**
  61685. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61686. * @returns a new forward Vector3
  61687. */
  61688. static Backward(): Vector3;
  61689. /**
  61690. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61691. * @returns a new right Vector3
  61692. */
  61693. static Right(): Vector3;
  61694. /**
  61695. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61696. * @returns a new left Vector3
  61697. */
  61698. static Left(): Vector3;
  61699. /**
  61700. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61701. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61702. * @param vector defines the Vector3 to transform
  61703. * @param transformation defines the transformation matrix
  61704. * @returns the transformed Vector3
  61705. */
  61706. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61707. /**
  61708. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61709. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61710. * @param vector defines the Vector3 to transform
  61711. * @param transformation defines the transformation matrix
  61712. * @param result defines the Vector3 where to store the result
  61713. */
  61714. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61715. /**
  61716. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61717. * This method computes tranformed coordinates only, not transformed direction vectors
  61718. * @param x define the x coordinate of the source vector
  61719. * @param y define the y coordinate of the source vector
  61720. * @param z define the z coordinate of the source vector
  61721. * @param transformation defines the transformation matrix
  61722. * @param result defines the Vector3 where to store the result
  61723. */
  61724. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61725. /**
  61726. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61727. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61728. * @param vector defines the Vector3 to transform
  61729. * @param transformation defines the transformation matrix
  61730. * @returns the new Vector3
  61731. */
  61732. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61733. /**
  61734. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61735. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61736. * @param vector defines the Vector3 to transform
  61737. * @param transformation defines the transformation matrix
  61738. * @param result defines the Vector3 where to store the result
  61739. */
  61740. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61741. /**
  61742. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61743. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61744. * @param x define the x coordinate of the source vector
  61745. * @param y define the y coordinate of the source vector
  61746. * @param z define the z coordinate of the source vector
  61747. * @param transformation defines the transformation matrix
  61748. * @param result defines the Vector3 where to store the result
  61749. */
  61750. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61751. /**
  61752. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61753. * @param value1 defines the first control point
  61754. * @param value2 defines the second control point
  61755. * @param value3 defines the third control point
  61756. * @param value4 defines the fourth control point
  61757. * @param amount defines the amount on the spline to use
  61758. * @returns the new Vector3
  61759. */
  61760. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61761. /**
  61762. * 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"
  61763. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61764. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61765. * @param value defines the current value
  61766. * @param min defines the lower range value
  61767. * @param max defines the upper range value
  61768. * @returns the new Vector3
  61769. */
  61770. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61771. /**
  61772. * 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"
  61773. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61774. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61775. * @param value defines the current value
  61776. * @param min defines the lower range value
  61777. * @param max defines the upper range value
  61778. * @param result defines the Vector3 where to store the result
  61779. */
  61780. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61781. /**
  61782. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61783. * @param value1 defines the first control point
  61784. * @param tangent1 defines the first tangent vector
  61785. * @param value2 defines the second control point
  61786. * @param tangent2 defines the second tangent vector
  61787. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61788. * @returns the new Vector3
  61789. */
  61790. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61791. /**
  61792. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61793. * @param start defines the start value
  61794. * @param end defines the end value
  61795. * @param amount max defines amount between both (between 0 and 1)
  61796. * @returns the new Vector3
  61797. */
  61798. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61799. /**
  61800. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61801. * @param start defines the start value
  61802. * @param end defines the end value
  61803. * @param amount max defines amount between both (between 0 and 1)
  61804. * @param result defines the Vector3 where to store the result
  61805. */
  61806. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61807. /**
  61808. * Returns the dot product (float) between the vectors "left" and "right"
  61809. * @param left defines the left operand
  61810. * @param right defines the right operand
  61811. * @returns the dot product
  61812. */
  61813. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61814. /**
  61815. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61816. * The cross product is then orthogonal to both "left" and "right"
  61817. * @param left defines the left operand
  61818. * @param right defines the right operand
  61819. * @returns the cross product
  61820. */
  61821. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61822. /**
  61823. * Sets the given vector "result" with the cross product of "left" and "right"
  61824. * The cross product is then orthogonal to both "left" and "right"
  61825. * @param left defines the left operand
  61826. * @param right defines the right operand
  61827. * @param result defines the Vector3 where to store the result
  61828. */
  61829. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61830. /**
  61831. * Returns a new Vector3 as the normalization of the given vector
  61832. * @param vector defines the Vector3 to normalize
  61833. * @returns the new Vector3
  61834. */
  61835. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61836. /**
  61837. * Sets the given vector "result" with the normalization of the given first vector
  61838. * @param vector defines the Vector3 to normalize
  61839. * @param result defines the Vector3 where to store the result
  61840. */
  61841. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61842. /**
  61843. * Project a Vector3 onto screen space
  61844. * @param vector defines the Vector3 to project
  61845. * @param world defines the world matrix to use
  61846. * @param transform defines the transform (view x projection) matrix to use
  61847. * @param viewport defines the screen viewport to use
  61848. * @returns the new Vector3
  61849. */
  61850. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61851. /** @hidden */
  61852. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61853. /**
  61854. * Unproject from screen space to object space
  61855. * @param source defines the screen space Vector3 to use
  61856. * @param viewportWidth defines the current width of the viewport
  61857. * @param viewportHeight defines the current height of the viewport
  61858. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61859. * @param transform defines the transform (view x projection) matrix to use
  61860. * @returns the new Vector3
  61861. */
  61862. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61863. /**
  61864. * Unproject from screen space to object space
  61865. * @param source defines the screen space Vector3 to use
  61866. * @param viewportWidth defines the current width of the viewport
  61867. * @param viewportHeight defines the current height of the viewport
  61868. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61869. * @param view defines the view matrix to use
  61870. * @param projection defines the projection matrix to use
  61871. * @returns the new Vector3
  61872. */
  61873. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61874. /**
  61875. * Unproject from screen space to object space
  61876. * @param source defines the screen space Vector3 to use
  61877. * @param viewportWidth defines the current width of the viewport
  61878. * @param viewportHeight defines the current height of the viewport
  61879. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61880. * @param view defines the view matrix to use
  61881. * @param projection defines the projection matrix to use
  61882. * @param result defines the Vector3 where to store the result
  61883. */
  61884. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61885. /**
  61886. * Unproject from screen space to object space
  61887. * @param sourceX defines the screen space x coordinate to use
  61888. * @param sourceY defines the screen space y coordinate to use
  61889. * @param sourceZ defines the screen space z coordinate to use
  61890. * @param viewportWidth defines the current width of the viewport
  61891. * @param viewportHeight defines the current height of the viewport
  61892. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61893. * @param view defines the view matrix to use
  61894. * @param projection defines the projection matrix to use
  61895. * @param result defines the Vector3 where to store the result
  61896. */
  61897. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61898. /**
  61899. * Gets the minimal coordinate values between two Vector3
  61900. * @param left defines the first operand
  61901. * @param right defines the second operand
  61902. * @returns the new Vector3
  61903. */
  61904. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61905. /**
  61906. * Gets the maximal coordinate values between two Vector3
  61907. * @param left defines the first operand
  61908. * @param right defines the second operand
  61909. * @returns the new Vector3
  61910. */
  61911. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61912. /**
  61913. * Returns the distance between the vectors "value1" and "value2"
  61914. * @param value1 defines the first operand
  61915. * @param value2 defines the second operand
  61916. * @returns the distance
  61917. */
  61918. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61919. /**
  61920. * Returns the squared distance between the vectors "value1" and "value2"
  61921. * @param value1 defines the first operand
  61922. * @param value2 defines the second operand
  61923. * @returns the squared distance
  61924. */
  61925. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61926. /**
  61927. * Returns a new Vector3 located at the center between "value1" and "value2"
  61928. * @param value1 defines the first operand
  61929. * @param value2 defines the second operand
  61930. * @returns the new Vector3
  61931. */
  61932. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61933. /**
  61934. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61935. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61936. * to something in order to rotate it from its local system to the given target system
  61937. * Note: axis1, axis2 and axis3 are normalized during this operation
  61938. * @param axis1 defines the first axis
  61939. * @param axis2 defines the second axis
  61940. * @param axis3 defines the third axis
  61941. * @returns a new Vector3
  61942. */
  61943. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61944. /**
  61945. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61946. * @param axis1 defines the first axis
  61947. * @param axis2 defines the second axis
  61948. * @param axis3 defines the third axis
  61949. * @param ref defines the Vector3 where to store the result
  61950. */
  61951. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61952. }
  61953. /**
  61954. * Vector4 class created for EulerAngle class conversion to Quaternion
  61955. */
  61956. export class Vector4 {
  61957. /** x value of the vector */
  61958. x: number;
  61959. /** y value of the vector */
  61960. y: number;
  61961. /** z value of the vector */
  61962. z: number;
  61963. /** w value of the vector */
  61964. w: number;
  61965. /**
  61966. * Creates a Vector4 object from the given floats.
  61967. * @param x x value of the vector
  61968. * @param y y value of the vector
  61969. * @param z z value of the vector
  61970. * @param w w value of the vector
  61971. */
  61972. constructor(
  61973. /** x value of the vector */
  61974. x: number,
  61975. /** y value of the vector */
  61976. y: number,
  61977. /** z value of the vector */
  61978. z: number,
  61979. /** w value of the vector */
  61980. w: number);
  61981. /**
  61982. * Returns the string with the Vector4 coordinates.
  61983. * @returns a string containing all the vector values
  61984. */
  61985. toString(): string;
  61986. /**
  61987. * Returns the string "Vector4".
  61988. * @returns "Vector4"
  61989. */
  61990. getClassName(): string;
  61991. /**
  61992. * Returns the Vector4 hash code.
  61993. * @returns a unique hash code
  61994. */
  61995. getHashCode(): number;
  61996. /**
  61997. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61998. * @returns the resulting array
  61999. */
  62000. asArray(): number[];
  62001. /**
  62002. * Populates the given array from the given index with the Vector4 coordinates.
  62003. * @param array array to populate
  62004. * @param index index of the array to start at (default: 0)
  62005. * @returns the Vector4.
  62006. */
  62007. toArray(array: FloatArray, index?: number): Vector4;
  62008. /**
  62009. * Adds the given vector to the current Vector4.
  62010. * @param otherVector the vector to add
  62011. * @returns the updated Vector4.
  62012. */
  62013. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  62014. /**
  62015. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  62016. * @param otherVector the vector to add
  62017. * @returns the resulting vector
  62018. */
  62019. add(otherVector: DeepImmutable<Vector4>): Vector4;
  62020. /**
  62021. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  62022. * @param otherVector the vector to add
  62023. * @param result the vector to store the result
  62024. * @returns the current Vector4.
  62025. */
  62026. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62027. /**
  62028. * Subtract in place the given vector from the current Vector4.
  62029. * @param otherVector the vector to subtract
  62030. * @returns the updated Vector4.
  62031. */
  62032. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  62033. /**
  62034. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  62035. * @param otherVector the vector to add
  62036. * @returns the new vector with the result
  62037. */
  62038. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  62039. /**
  62040. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  62041. * @param otherVector the vector to subtract
  62042. * @param result the vector to store the result
  62043. * @returns the current Vector4.
  62044. */
  62045. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62046. /**
  62047. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  62048. */
  62049. /**
  62050. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  62051. * @param x value to subtract
  62052. * @param y value to subtract
  62053. * @param z value to subtract
  62054. * @param w value to subtract
  62055. * @returns new vector containing the result
  62056. */
  62057. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  62058. /**
  62059. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  62060. * @param x value to subtract
  62061. * @param y value to subtract
  62062. * @param z value to subtract
  62063. * @param w value to subtract
  62064. * @param result the vector to store the result in
  62065. * @returns the current Vector4.
  62066. */
  62067. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  62068. /**
  62069. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  62070. * @returns a new vector with the negated values
  62071. */
  62072. negate(): Vector4;
  62073. /**
  62074. * Multiplies the current Vector4 coordinates by scale (float).
  62075. * @param scale the number to scale with
  62076. * @returns the updated Vector4.
  62077. */
  62078. scaleInPlace(scale: number): Vector4;
  62079. /**
  62080. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  62081. * @param scale the number to scale with
  62082. * @returns a new vector with the result
  62083. */
  62084. scale(scale: number): Vector4;
  62085. /**
  62086. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  62087. * @param scale the number to scale with
  62088. * @param result a vector to store the result in
  62089. * @returns the current Vector4.
  62090. */
  62091. scaleToRef(scale: number, result: Vector4): Vector4;
  62092. /**
  62093. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  62094. * @param scale defines the scale factor
  62095. * @param result defines the Vector4 object where to store the result
  62096. * @returns the unmodified current Vector4
  62097. */
  62098. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  62099. /**
  62100. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  62101. * @param otherVector the vector to compare against
  62102. * @returns true if they are equal
  62103. */
  62104. equals(otherVector: DeepImmutable<Vector4>): boolean;
  62105. /**
  62106. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  62107. * @param otherVector vector to compare against
  62108. * @param epsilon (Default: very small number)
  62109. * @returns true if they are equal
  62110. */
  62111. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  62112. /**
  62113. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  62114. * @param x x value to compare against
  62115. * @param y y value to compare against
  62116. * @param z z value to compare against
  62117. * @param w w value to compare against
  62118. * @returns true if equal
  62119. */
  62120. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  62121. /**
  62122. * Multiplies in place the current Vector4 by the given one.
  62123. * @param otherVector vector to multiple with
  62124. * @returns the updated Vector4.
  62125. */
  62126. multiplyInPlace(otherVector: Vector4): Vector4;
  62127. /**
  62128. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  62129. * @param otherVector vector to multiple with
  62130. * @returns resulting new vector
  62131. */
  62132. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  62133. /**
  62134. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  62135. * @param otherVector vector to multiple with
  62136. * @param result vector to store the result
  62137. * @returns the current Vector4.
  62138. */
  62139. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62140. /**
  62141. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  62142. * @param x x value multiply with
  62143. * @param y y value multiply with
  62144. * @param z z value multiply with
  62145. * @param w w value multiply with
  62146. * @returns resulting new vector
  62147. */
  62148. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  62149. /**
  62150. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  62151. * @param otherVector vector to devide with
  62152. * @returns resulting new vector
  62153. */
  62154. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  62155. /**
  62156. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  62157. * @param otherVector vector to devide with
  62158. * @param result vector to store the result
  62159. * @returns the current Vector4.
  62160. */
  62161. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62162. /**
  62163. * Divides the current Vector3 coordinates by the given ones.
  62164. * @param otherVector vector to devide with
  62165. * @returns the updated Vector3.
  62166. */
  62167. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  62168. /**
  62169. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  62170. * @param other defines the second operand
  62171. * @returns the current updated Vector4
  62172. */
  62173. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62174. /**
  62175. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  62176. * @param other defines the second operand
  62177. * @returns the current updated Vector4
  62178. */
  62179. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62180. /**
  62181. * Gets a new Vector4 from current Vector4 floored values
  62182. * @returns a new Vector4
  62183. */
  62184. floor(): Vector4;
  62185. /**
  62186. * Gets a new Vector4 from current Vector3 floored values
  62187. * @returns a new Vector4
  62188. */
  62189. fract(): Vector4;
  62190. /**
  62191. * Returns the Vector4 length (float).
  62192. * @returns the length
  62193. */
  62194. length(): number;
  62195. /**
  62196. * Returns the Vector4 squared length (float).
  62197. * @returns the length squared
  62198. */
  62199. lengthSquared(): number;
  62200. /**
  62201. * Normalizes in place the Vector4.
  62202. * @returns the updated Vector4.
  62203. */
  62204. normalize(): Vector4;
  62205. /**
  62206. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  62207. * @returns this converted to a new vector3
  62208. */
  62209. toVector3(): Vector3;
  62210. /**
  62211. * Returns a new Vector4 copied from the current one.
  62212. * @returns the new cloned vector
  62213. */
  62214. clone(): Vector4;
  62215. /**
  62216. * Updates the current Vector4 with the given one coordinates.
  62217. * @param source the source vector to copy from
  62218. * @returns the updated Vector4.
  62219. */
  62220. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  62221. /**
  62222. * Updates the current Vector4 coordinates with the given floats.
  62223. * @param x float to copy from
  62224. * @param y float to copy from
  62225. * @param z float to copy from
  62226. * @param w float to copy from
  62227. * @returns the updated Vector4.
  62228. */
  62229. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  62230. /**
  62231. * Updates the current Vector4 coordinates with the given floats.
  62232. * @param x float to set from
  62233. * @param y float to set from
  62234. * @param z float to set from
  62235. * @param w float to set from
  62236. * @returns the updated Vector4.
  62237. */
  62238. set(x: number, y: number, z: number, w: number): Vector4;
  62239. /**
  62240. * Copies the given float to the current Vector3 coordinates
  62241. * @param v defines the x, y, z and w coordinates of the operand
  62242. * @returns the current updated Vector3
  62243. */
  62244. setAll(v: number): Vector4;
  62245. /**
  62246. * Returns a new Vector4 set from the starting index of the given array.
  62247. * @param array the array to pull values from
  62248. * @param offset the offset into the array to start at
  62249. * @returns the new vector
  62250. */
  62251. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  62252. /**
  62253. * Updates the given vector "result" from the starting index of the given array.
  62254. * @param array the array to pull values from
  62255. * @param offset the offset into the array to start at
  62256. * @param result the vector to store the result in
  62257. */
  62258. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  62259. /**
  62260. * Updates the given vector "result" from the starting index of the given Float32Array.
  62261. * @param array the array to pull values from
  62262. * @param offset the offset into the array to start at
  62263. * @param result the vector to store the result in
  62264. */
  62265. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  62266. /**
  62267. * Updates the given vector "result" coordinates from the given floats.
  62268. * @param x float to set from
  62269. * @param y float to set from
  62270. * @param z float to set from
  62271. * @param w float to set from
  62272. * @param result the vector to the floats in
  62273. */
  62274. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  62275. /**
  62276. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  62277. * @returns the new vector
  62278. */
  62279. static Zero(): Vector4;
  62280. /**
  62281. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  62282. * @returns the new vector
  62283. */
  62284. static One(): Vector4;
  62285. /**
  62286. * Returns a new normalized Vector4 from the given one.
  62287. * @param vector the vector to normalize
  62288. * @returns the vector
  62289. */
  62290. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  62291. /**
  62292. * Updates the given vector "result" from the normalization of the given one.
  62293. * @param vector the vector to normalize
  62294. * @param result the vector to store the result in
  62295. */
  62296. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  62297. /**
  62298. * Returns a vector with the minimum values from the left and right vectors
  62299. * @param left left vector to minimize
  62300. * @param right right vector to minimize
  62301. * @returns a new vector with the minimum of the left and right vector values
  62302. */
  62303. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62304. /**
  62305. * Returns a vector with the maximum values from the left and right vectors
  62306. * @param left left vector to maximize
  62307. * @param right right vector to maximize
  62308. * @returns a new vector with the maximum of the left and right vector values
  62309. */
  62310. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62311. /**
  62312. * Returns the distance (float) between the vectors "value1" and "value2".
  62313. * @param value1 value to calulate the distance between
  62314. * @param value2 value to calulate the distance between
  62315. * @return the distance between the two vectors
  62316. */
  62317. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62318. /**
  62319. * Returns the squared distance (float) between the vectors "value1" and "value2".
  62320. * @param value1 value to calulate the distance between
  62321. * @param value2 value to calulate the distance between
  62322. * @return the distance between the two vectors squared
  62323. */
  62324. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62325. /**
  62326. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  62327. * @param value1 value to calulate the center between
  62328. * @param value2 value to calulate the center between
  62329. * @return the center between the two vectors
  62330. */
  62331. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  62332. /**
  62333. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  62334. * This methods computes transformed normalized direction vectors only.
  62335. * @param vector the vector to transform
  62336. * @param transformation the transformation matrix to apply
  62337. * @returns the new vector
  62338. */
  62339. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  62340. /**
  62341. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  62342. * This methods computes transformed normalized direction vectors only.
  62343. * @param vector the vector to transform
  62344. * @param transformation the transformation matrix to apply
  62345. * @param result the vector to store the result in
  62346. */
  62347. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62348. /**
  62349. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  62350. * This methods computes transformed normalized direction vectors only.
  62351. * @param x value to transform
  62352. * @param y value to transform
  62353. * @param z value to transform
  62354. * @param w value to transform
  62355. * @param transformation the transformation matrix to apply
  62356. * @param result the vector to store the results in
  62357. */
  62358. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62359. /**
  62360. * Creates a new Vector4 from a Vector3
  62361. * @param source defines the source data
  62362. * @param w defines the 4th component (default is 0)
  62363. * @returns a new Vector4
  62364. */
  62365. static FromVector3(source: Vector3, w?: number): Vector4;
  62366. }
  62367. /**
  62368. * Interface for the size containing width and height
  62369. */
  62370. export interface ISize {
  62371. /**
  62372. * Width
  62373. */
  62374. width: number;
  62375. /**
  62376. * Heighht
  62377. */
  62378. height: number;
  62379. }
  62380. /**
  62381. * Size containing widht and height
  62382. */
  62383. export class Size implements ISize {
  62384. /**
  62385. * Width
  62386. */
  62387. width: number;
  62388. /**
  62389. * Height
  62390. */
  62391. height: number;
  62392. /**
  62393. * Creates a Size object from the given width and height (floats).
  62394. * @param width width of the new size
  62395. * @param height height of the new size
  62396. */
  62397. constructor(width: number, height: number);
  62398. /**
  62399. * Returns a string with the Size width and height
  62400. * @returns a string with the Size width and height
  62401. */
  62402. toString(): string;
  62403. /**
  62404. * "Size"
  62405. * @returns the string "Size"
  62406. */
  62407. getClassName(): string;
  62408. /**
  62409. * Returns the Size hash code.
  62410. * @returns a hash code for a unique width and height
  62411. */
  62412. getHashCode(): number;
  62413. /**
  62414. * Updates the current size from the given one.
  62415. * @param src the given size
  62416. */
  62417. copyFrom(src: Size): void;
  62418. /**
  62419. * Updates in place the current Size from the given floats.
  62420. * @param width width of the new size
  62421. * @param height height of the new size
  62422. * @returns the updated Size.
  62423. */
  62424. copyFromFloats(width: number, height: number): Size;
  62425. /**
  62426. * Updates in place the current Size from the given floats.
  62427. * @param width width to set
  62428. * @param height height to set
  62429. * @returns the updated Size.
  62430. */
  62431. set(width: number, height: number): Size;
  62432. /**
  62433. * Multiplies the width and height by numbers
  62434. * @param w factor to multiple the width by
  62435. * @param h factor to multiple the height by
  62436. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  62437. */
  62438. multiplyByFloats(w: number, h: number): Size;
  62439. /**
  62440. * Clones the size
  62441. * @returns a new Size copied from the given one.
  62442. */
  62443. clone(): Size;
  62444. /**
  62445. * True if the current Size and the given one width and height are strictly equal.
  62446. * @param other the other size to compare against
  62447. * @returns True if the current Size and the given one width and height are strictly equal.
  62448. */
  62449. equals(other: Size): boolean;
  62450. /**
  62451. * The surface of the Size : width * height (float).
  62452. */
  62453. readonly surface: number;
  62454. /**
  62455. * Create a new size of zero
  62456. * @returns a new Size set to (0.0, 0.0)
  62457. */
  62458. static Zero(): Size;
  62459. /**
  62460. * Sums the width and height of two sizes
  62461. * @param otherSize size to add to this size
  62462. * @returns a new Size set as the addition result of the current Size and the given one.
  62463. */
  62464. add(otherSize: Size): Size;
  62465. /**
  62466. * Subtracts the width and height of two
  62467. * @param otherSize size to subtract to this size
  62468. * @returns a new Size set as the subtraction result of the given one from the current Size.
  62469. */
  62470. subtract(otherSize: Size): Size;
  62471. /**
  62472. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  62473. * @param start starting size to lerp between
  62474. * @param end end size to lerp between
  62475. * @param amount amount to lerp between the start and end values
  62476. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  62477. */
  62478. static Lerp(start: Size, end: Size, amount: number): Size;
  62479. }
  62480. /**
  62481. * Class used to store quaternion data
  62482. * @see https://en.wikipedia.org/wiki/Quaternion
  62483. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  62484. */
  62485. export class Quaternion {
  62486. /** defines the first component (0 by default) */
  62487. x: number;
  62488. /** defines the second component (0 by default) */
  62489. y: number;
  62490. /** defines the third component (0 by default) */
  62491. z: number;
  62492. /** defines the fourth component (1.0 by default) */
  62493. w: number;
  62494. /**
  62495. * Creates a new Quaternion from the given floats
  62496. * @param x defines the first component (0 by default)
  62497. * @param y defines the second component (0 by default)
  62498. * @param z defines the third component (0 by default)
  62499. * @param w defines the fourth component (1.0 by default)
  62500. */
  62501. constructor(
  62502. /** defines the first component (0 by default) */
  62503. x?: number,
  62504. /** defines the second component (0 by default) */
  62505. y?: number,
  62506. /** defines the third component (0 by default) */
  62507. z?: number,
  62508. /** defines the fourth component (1.0 by default) */
  62509. w?: number);
  62510. /**
  62511. * Gets a string representation for the current quaternion
  62512. * @returns a string with the Quaternion coordinates
  62513. */
  62514. toString(): string;
  62515. /**
  62516. * Gets the class name of the quaternion
  62517. * @returns the string "Quaternion"
  62518. */
  62519. getClassName(): string;
  62520. /**
  62521. * Gets a hash code for this quaternion
  62522. * @returns the quaternion hash code
  62523. */
  62524. getHashCode(): number;
  62525. /**
  62526. * Copy the quaternion to an array
  62527. * @returns a new array populated with 4 elements from the quaternion coordinates
  62528. */
  62529. asArray(): number[];
  62530. /**
  62531. * Check if two quaternions are equals
  62532. * @param otherQuaternion defines the second operand
  62533. * @return true if the current quaternion and the given one coordinates are strictly equals
  62534. */
  62535. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  62536. /**
  62537. * Clone the current quaternion
  62538. * @returns a new quaternion copied from the current one
  62539. */
  62540. clone(): Quaternion;
  62541. /**
  62542. * Copy a quaternion to the current one
  62543. * @param other defines the other quaternion
  62544. * @returns the updated current quaternion
  62545. */
  62546. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  62547. /**
  62548. * Updates the current quaternion with the given float coordinates
  62549. * @param x defines the x coordinate
  62550. * @param y defines the y coordinate
  62551. * @param z defines the z coordinate
  62552. * @param w defines the w coordinate
  62553. * @returns the updated current quaternion
  62554. */
  62555. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  62556. /**
  62557. * Updates the current quaternion from the given float coordinates
  62558. * @param x defines the x coordinate
  62559. * @param y defines the y coordinate
  62560. * @param z defines the z coordinate
  62561. * @param w defines the w coordinate
  62562. * @returns the updated current quaternion
  62563. */
  62564. set(x: number, y: number, z: number, w: number): Quaternion;
  62565. /**
  62566. * Adds two quaternions
  62567. * @param other defines the second operand
  62568. * @returns a new quaternion as the addition result of the given one and the current quaternion
  62569. */
  62570. add(other: DeepImmutable<Quaternion>): Quaternion;
  62571. /**
  62572. * Add a quaternion to the current one
  62573. * @param other defines the quaternion to add
  62574. * @returns the current quaternion
  62575. */
  62576. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  62577. /**
  62578. * Subtract two quaternions
  62579. * @param other defines the second operand
  62580. * @returns a new quaternion as the subtraction result of the given one from the current one
  62581. */
  62582. subtract(other: Quaternion): Quaternion;
  62583. /**
  62584. * Multiplies the current quaternion by a scale factor
  62585. * @param value defines the scale factor
  62586. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  62587. */
  62588. scale(value: number): Quaternion;
  62589. /**
  62590. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  62591. * @param scale defines the scale factor
  62592. * @param result defines the Quaternion object where to store the result
  62593. * @returns the unmodified current quaternion
  62594. */
  62595. scaleToRef(scale: number, result: Quaternion): Quaternion;
  62596. /**
  62597. * Multiplies in place the current quaternion by a scale factor
  62598. * @param value defines the scale factor
  62599. * @returns the current modified quaternion
  62600. */
  62601. scaleInPlace(value: number): Quaternion;
  62602. /**
  62603. * Scale the current quaternion values by a factor and add the result to a given quaternion
  62604. * @param scale defines the scale factor
  62605. * @param result defines the Quaternion object where to store the result
  62606. * @returns the unmodified current quaternion
  62607. */
  62608. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  62609. /**
  62610. * Multiplies two quaternions
  62611. * @param q1 defines the second operand
  62612. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  62613. */
  62614. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  62615. /**
  62616. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  62617. * @param q1 defines the second operand
  62618. * @param result defines the target quaternion
  62619. * @returns the current quaternion
  62620. */
  62621. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  62622. /**
  62623. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  62624. * @param q1 defines the second operand
  62625. * @returns the currentupdated quaternion
  62626. */
  62627. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  62628. /**
  62629. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  62630. * @param ref defines the target quaternion
  62631. * @returns the current quaternion
  62632. */
  62633. conjugateToRef(ref: Quaternion): Quaternion;
  62634. /**
  62635. * Conjugates in place (1-q) the current quaternion
  62636. * @returns the current updated quaternion
  62637. */
  62638. conjugateInPlace(): Quaternion;
  62639. /**
  62640. * Conjugates in place (1-q) the current quaternion
  62641. * @returns a new quaternion
  62642. */
  62643. conjugate(): Quaternion;
  62644. /**
  62645. * Gets length of current quaternion
  62646. * @returns the quaternion length (float)
  62647. */
  62648. length(): number;
  62649. /**
  62650. * Normalize in place the current quaternion
  62651. * @returns the current updated quaternion
  62652. */
  62653. normalize(): Quaternion;
  62654. /**
  62655. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  62656. * @param order is a reserved parameter and is ignore for now
  62657. * @returns a new Vector3 containing the Euler angles
  62658. */
  62659. toEulerAngles(order?: string): Vector3;
  62660. /**
  62661. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  62662. * @param result defines the vector which will be filled with the Euler angles
  62663. * @param order is a reserved parameter and is ignore for now
  62664. * @returns the current unchanged quaternion
  62665. */
  62666. toEulerAnglesToRef(result: Vector3): Quaternion;
  62667. /**
  62668. * Updates the given rotation matrix with the current quaternion values
  62669. * @param result defines the target matrix
  62670. * @returns the current unchanged quaternion
  62671. */
  62672. toRotationMatrix(result: Matrix): Quaternion;
  62673. /**
  62674. * Updates the current quaternion from the given rotation matrix values
  62675. * @param matrix defines the source matrix
  62676. * @returns the current updated quaternion
  62677. */
  62678. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62679. /**
  62680. * Creates a new quaternion from a rotation matrix
  62681. * @param matrix defines the source matrix
  62682. * @returns a new quaternion created from the given rotation matrix values
  62683. */
  62684. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62685. /**
  62686. * Updates the given quaternion with the given rotation matrix values
  62687. * @param matrix defines the source matrix
  62688. * @param result defines the target quaternion
  62689. */
  62690. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62691. /**
  62692. * Returns the dot product (float) between the quaternions "left" and "right"
  62693. * @param left defines the left operand
  62694. * @param right defines the right operand
  62695. * @returns the dot product
  62696. */
  62697. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62698. /**
  62699. * Checks if the two quaternions are close to each other
  62700. * @param quat0 defines the first quaternion to check
  62701. * @param quat1 defines the second quaternion to check
  62702. * @returns true if the two quaternions are close to each other
  62703. */
  62704. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62705. /**
  62706. * Creates an empty quaternion
  62707. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62708. */
  62709. static Zero(): Quaternion;
  62710. /**
  62711. * Inverse a given quaternion
  62712. * @param q defines the source quaternion
  62713. * @returns a new quaternion as the inverted current quaternion
  62714. */
  62715. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62716. /**
  62717. * Inverse a given quaternion
  62718. * @param q defines the source quaternion
  62719. * @param result the quaternion the result will be stored in
  62720. * @returns the result quaternion
  62721. */
  62722. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62723. /**
  62724. * Creates an identity quaternion
  62725. * @returns the identity quaternion
  62726. */
  62727. static Identity(): Quaternion;
  62728. /**
  62729. * Gets a boolean indicating if the given quaternion is identity
  62730. * @param quaternion defines the quaternion to check
  62731. * @returns true if the quaternion is identity
  62732. */
  62733. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62734. /**
  62735. * Creates a quaternion from a rotation around an axis
  62736. * @param axis defines the axis to use
  62737. * @param angle defines the angle to use
  62738. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62739. */
  62740. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62741. /**
  62742. * Creates a rotation around an axis and stores it into the given quaternion
  62743. * @param axis defines the axis to use
  62744. * @param angle defines the angle to use
  62745. * @param result defines the target quaternion
  62746. * @returns the target quaternion
  62747. */
  62748. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62749. /**
  62750. * Creates a new quaternion from data stored into an array
  62751. * @param array defines the data source
  62752. * @param offset defines the offset in the source array where the data starts
  62753. * @returns a new quaternion
  62754. */
  62755. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62756. /**
  62757. * Create a quaternion from Euler rotation angles
  62758. * @param x Pitch
  62759. * @param y Yaw
  62760. * @param z Roll
  62761. * @returns the new Quaternion
  62762. */
  62763. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62764. /**
  62765. * Updates a quaternion from Euler rotation angles
  62766. * @param x Pitch
  62767. * @param y Yaw
  62768. * @param z Roll
  62769. * @param result the quaternion to store the result
  62770. * @returns the updated quaternion
  62771. */
  62772. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62773. /**
  62774. * Create a quaternion from Euler rotation vector
  62775. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62776. * @returns the new Quaternion
  62777. */
  62778. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62779. /**
  62780. * Updates a quaternion from Euler rotation vector
  62781. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62782. * @param result the quaternion to store the result
  62783. * @returns the updated quaternion
  62784. */
  62785. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62786. /**
  62787. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62788. * @param yaw defines the rotation around Y axis
  62789. * @param pitch defines the rotation around X axis
  62790. * @param roll defines the rotation around Z axis
  62791. * @returns the new quaternion
  62792. */
  62793. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62794. /**
  62795. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62796. * @param yaw defines the rotation around Y axis
  62797. * @param pitch defines the rotation around X axis
  62798. * @param roll defines the rotation around Z axis
  62799. * @param result defines the target quaternion
  62800. */
  62801. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62802. /**
  62803. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62804. * @param alpha defines the rotation around first axis
  62805. * @param beta defines the rotation around second axis
  62806. * @param gamma defines the rotation around third axis
  62807. * @returns the new quaternion
  62808. */
  62809. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62810. /**
  62811. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62812. * @param alpha defines the rotation around first axis
  62813. * @param beta defines the rotation around second axis
  62814. * @param gamma defines the rotation around third axis
  62815. * @param result defines the target quaternion
  62816. */
  62817. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62818. /**
  62819. * 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)
  62820. * @param axis1 defines the first axis
  62821. * @param axis2 defines the second axis
  62822. * @param axis3 defines the third axis
  62823. * @returns the new quaternion
  62824. */
  62825. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62826. /**
  62827. * 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
  62828. * @param axis1 defines the first axis
  62829. * @param axis2 defines the second axis
  62830. * @param axis3 defines the third axis
  62831. * @param ref defines the target quaternion
  62832. */
  62833. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62834. /**
  62835. * Interpolates between two quaternions
  62836. * @param left defines first quaternion
  62837. * @param right defines second quaternion
  62838. * @param amount defines the gradient to use
  62839. * @returns the new interpolated quaternion
  62840. */
  62841. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62842. /**
  62843. * Interpolates between two quaternions and stores it into a target quaternion
  62844. * @param left defines first quaternion
  62845. * @param right defines second quaternion
  62846. * @param amount defines the gradient to use
  62847. * @param result defines the target quaternion
  62848. */
  62849. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62850. /**
  62851. * Interpolate between two quaternions using Hermite interpolation
  62852. * @param value1 defines first quaternion
  62853. * @param tangent1 defines the incoming tangent
  62854. * @param value2 defines second quaternion
  62855. * @param tangent2 defines the outgoing tangent
  62856. * @param amount defines the target quaternion
  62857. * @returns the new interpolated quaternion
  62858. */
  62859. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62860. }
  62861. /**
  62862. * Class used to store matrix data (4x4)
  62863. */
  62864. export class Matrix {
  62865. private static _updateFlagSeed;
  62866. private static _identityReadOnly;
  62867. private _isIdentity;
  62868. private _isIdentityDirty;
  62869. private _isIdentity3x2;
  62870. private _isIdentity3x2Dirty;
  62871. /**
  62872. * Gets the update flag of the matrix which is an unique number for the matrix.
  62873. * It will be incremented every time the matrix data change.
  62874. * You can use it to speed the comparison between two versions of the same matrix.
  62875. */
  62876. updateFlag: number;
  62877. private readonly _m;
  62878. /**
  62879. * Gets the internal data of the matrix
  62880. */
  62881. readonly m: DeepImmutable<Float32Array>;
  62882. /** @hidden */
  62883. _markAsUpdated(): void;
  62884. /** @hidden */
  62885. private _updateIdentityStatus;
  62886. /**
  62887. * Creates an empty matrix (filled with zeros)
  62888. */
  62889. constructor();
  62890. /**
  62891. * Check if the current matrix is identity
  62892. * @returns true is the matrix is the identity matrix
  62893. */
  62894. isIdentity(): boolean;
  62895. /**
  62896. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62897. * @returns true is the matrix is the identity matrix
  62898. */
  62899. isIdentityAs3x2(): boolean;
  62900. /**
  62901. * Gets the determinant of the matrix
  62902. * @returns the matrix determinant
  62903. */
  62904. determinant(): number;
  62905. /**
  62906. * Returns the matrix as a Float32Array
  62907. * @returns the matrix underlying array
  62908. */
  62909. toArray(): DeepImmutable<Float32Array>;
  62910. /**
  62911. * Returns the matrix as a Float32Array
  62912. * @returns the matrix underlying array.
  62913. */
  62914. asArray(): DeepImmutable<Float32Array>;
  62915. /**
  62916. * Inverts the current matrix in place
  62917. * @returns the current inverted matrix
  62918. */
  62919. invert(): Matrix;
  62920. /**
  62921. * Sets all the matrix elements to zero
  62922. * @returns the current matrix
  62923. */
  62924. reset(): Matrix;
  62925. /**
  62926. * Adds the current matrix with a second one
  62927. * @param other defines the matrix to add
  62928. * @returns a new matrix as the addition of the current matrix and the given one
  62929. */
  62930. add(other: DeepImmutable<Matrix>): Matrix;
  62931. /**
  62932. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62933. * @param other defines the matrix to add
  62934. * @param result defines the target matrix
  62935. * @returns the current matrix
  62936. */
  62937. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62938. /**
  62939. * Adds in place the given matrix to the current matrix
  62940. * @param other defines the second operand
  62941. * @returns the current updated matrix
  62942. */
  62943. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62944. /**
  62945. * Sets the given matrix to the current inverted Matrix
  62946. * @param other defines the target matrix
  62947. * @returns the unmodified current matrix
  62948. */
  62949. invertToRef(other: Matrix): Matrix;
  62950. /**
  62951. * add a value at the specified position in the current Matrix
  62952. * @param index the index of the value within the matrix. between 0 and 15.
  62953. * @param value the value to be added
  62954. * @returns the current updated matrix
  62955. */
  62956. addAtIndex(index: number, value: number): Matrix;
  62957. /**
  62958. * mutiply the specified position in the current Matrix by a value
  62959. * @param index the index of the value within the matrix. between 0 and 15.
  62960. * @param value the value to be added
  62961. * @returns the current updated matrix
  62962. */
  62963. multiplyAtIndex(index: number, value: number): Matrix;
  62964. /**
  62965. * Inserts the translation vector (using 3 floats) in the current matrix
  62966. * @param x defines the 1st component of the translation
  62967. * @param y defines the 2nd component of the translation
  62968. * @param z defines the 3rd component of the translation
  62969. * @returns the current updated matrix
  62970. */
  62971. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62972. /**
  62973. * Adds the translation vector (using 3 floats) in the current matrix
  62974. * @param x defines the 1st component of the translation
  62975. * @param y defines the 2nd component of the translation
  62976. * @param z defines the 3rd component of the translation
  62977. * @returns the current updated matrix
  62978. */
  62979. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62980. /**
  62981. * Inserts the translation vector in the current matrix
  62982. * @param vector3 defines the translation to insert
  62983. * @returns the current updated matrix
  62984. */
  62985. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62986. /**
  62987. * Gets the translation value of the current matrix
  62988. * @returns a new Vector3 as the extracted translation from the matrix
  62989. */
  62990. getTranslation(): Vector3;
  62991. /**
  62992. * Fill a Vector3 with the extracted translation from the matrix
  62993. * @param result defines the Vector3 where to store the translation
  62994. * @returns the current matrix
  62995. */
  62996. getTranslationToRef(result: Vector3): Matrix;
  62997. /**
  62998. * Remove rotation and scaling part from the matrix
  62999. * @returns the updated matrix
  63000. */
  63001. removeRotationAndScaling(): Matrix;
  63002. /**
  63003. * Multiply two matrices
  63004. * @param other defines the second operand
  63005. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  63006. */
  63007. multiply(other: DeepImmutable<Matrix>): Matrix;
  63008. /**
  63009. * Copy the current matrix from the given one
  63010. * @param other defines the source matrix
  63011. * @returns the current updated matrix
  63012. */
  63013. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  63014. /**
  63015. * Populates the given array from the starting index with the current matrix values
  63016. * @param array defines the target array
  63017. * @param offset defines the offset in the target array where to start storing values
  63018. * @returns the current matrix
  63019. */
  63020. copyToArray(array: Float32Array, offset?: number): Matrix;
  63021. /**
  63022. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  63023. * @param other defines the second operand
  63024. * @param result defines the matrix where to store the multiplication
  63025. * @returns the current matrix
  63026. */
  63027. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  63028. /**
  63029. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  63030. * @param other defines the second operand
  63031. * @param result defines the array where to store the multiplication
  63032. * @param offset defines the offset in the target array where to start storing values
  63033. * @returns the current matrix
  63034. */
  63035. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  63036. /**
  63037. * Check equality between this matrix and a second one
  63038. * @param value defines the second matrix to compare
  63039. * @returns true is the current matrix and the given one values are strictly equal
  63040. */
  63041. equals(value: DeepImmutable<Matrix>): boolean;
  63042. /**
  63043. * Clone the current matrix
  63044. * @returns a new matrix from the current matrix
  63045. */
  63046. clone(): Matrix;
  63047. /**
  63048. * Returns the name of the current matrix class
  63049. * @returns the string "Matrix"
  63050. */
  63051. getClassName(): string;
  63052. /**
  63053. * Gets the hash code of the current matrix
  63054. * @returns the hash code
  63055. */
  63056. getHashCode(): number;
  63057. /**
  63058. * Decomposes the current Matrix into a translation, rotation and scaling components
  63059. * @param scale defines the scale vector3 given as a reference to update
  63060. * @param rotation defines the rotation quaternion given as a reference to update
  63061. * @param translation defines the translation vector3 given as a reference to update
  63062. * @returns true if operation was successful
  63063. */
  63064. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  63065. /**
  63066. * Gets specific row of the matrix
  63067. * @param index defines the number of the row to get
  63068. * @returns the index-th row of the current matrix as a new Vector4
  63069. */
  63070. getRow(index: number): Nullable<Vector4>;
  63071. /**
  63072. * Sets the index-th row of the current matrix to the vector4 values
  63073. * @param index defines the number of the row to set
  63074. * @param row defines the target vector4
  63075. * @returns the updated current matrix
  63076. */
  63077. setRow(index: number, row: Vector4): Matrix;
  63078. /**
  63079. * Compute the transpose of the matrix
  63080. * @returns the new transposed matrix
  63081. */
  63082. transpose(): Matrix;
  63083. /**
  63084. * Compute the transpose of the matrix and store it in a given matrix
  63085. * @param result defines the target matrix
  63086. * @returns the current matrix
  63087. */
  63088. transposeToRef(result: Matrix): Matrix;
  63089. /**
  63090. * Sets the index-th row of the current matrix with the given 4 x float values
  63091. * @param index defines the row index
  63092. * @param x defines the x component to set
  63093. * @param y defines the y component to set
  63094. * @param z defines the z component to set
  63095. * @param w defines the w component to set
  63096. * @returns the updated current matrix
  63097. */
  63098. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  63099. /**
  63100. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  63101. * @param scale defines the scale factor
  63102. * @returns a new matrix
  63103. */
  63104. scale(scale: number): Matrix;
  63105. /**
  63106. * Scale the current matrix values by a factor to a given result matrix
  63107. * @param scale defines the scale factor
  63108. * @param result defines the matrix to store the result
  63109. * @returns the current matrix
  63110. */
  63111. scaleToRef(scale: number, result: Matrix): Matrix;
  63112. /**
  63113. * Scale the current matrix values by a factor and add the result to a given matrix
  63114. * @param scale defines the scale factor
  63115. * @param result defines the Matrix to store the result
  63116. * @returns the current matrix
  63117. */
  63118. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  63119. /**
  63120. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  63121. * @param ref matrix to store the result
  63122. */
  63123. toNormalMatrix(ref: Matrix): void;
  63124. /**
  63125. * Gets only rotation part of the current matrix
  63126. * @returns a new matrix sets to the extracted rotation matrix from the current one
  63127. */
  63128. getRotationMatrix(): Matrix;
  63129. /**
  63130. * Extracts the rotation matrix from the current one and sets it as the given "result"
  63131. * @param result defines the target matrix to store data to
  63132. * @returns the current matrix
  63133. */
  63134. getRotationMatrixToRef(result: Matrix): Matrix;
  63135. /**
  63136. * Toggles model matrix from being right handed to left handed in place and vice versa
  63137. */
  63138. toggleModelMatrixHandInPlace(): void;
  63139. /**
  63140. * Toggles projection matrix from being right handed to left handed in place and vice versa
  63141. */
  63142. toggleProjectionMatrixHandInPlace(): void;
  63143. /**
  63144. * Creates a matrix from an array
  63145. * @param array defines the source array
  63146. * @param offset defines an offset in the source array
  63147. * @returns a new Matrix set from the starting index of the given array
  63148. */
  63149. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  63150. /**
  63151. * Copy the content of an array into a given matrix
  63152. * @param array defines the source array
  63153. * @param offset defines an offset in the source array
  63154. * @param result defines the target matrix
  63155. */
  63156. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  63157. /**
  63158. * Stores an array into a matrix after having multiplied each component by a given factor
  63159. * @param array defines the source array
  63160. * @param offset defines the offset in the source array
  63161. * @param scale defines the scaling factor
  63162. * @param result defines the target matrix
  63163. */
  63164. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  63165. /**
  63166. * Gets an identity matrix that must not be updated
  63167. */
  63168. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  63169. /**
  63170. * Stores a list of values (16) inside a given matrix
  63171. * @param initialM11 defines 1st value of 1st row
  63172. * @param initialM12 defines 2nd value of 1st row
  63173. * @param initialM13 defines 3rd value of 1st row
  63174. * @param initialM14 defines 4th value of 1st row
  63175. * @param initialM21 defines 1st value of 2nd row
  63176. * @param initialM22 defines 2nd value of 2nd row
  63177. * @param initialM23 defines 3rd value of 2nd row
  63178. * @param initialM24 defines 4th value of 2nd row
  63179. * @param initialM31 defines 1st value of 3rd row
  63180. * @param initialM32 defines 2nd value of 3rd row
  63181. * @param initialM33 defines 3rd value of 3rd row
  63182. * @param initialM34 defines 4th value of 3rd row
  63183. * @param initialM41 defines 1st value of 4th row
  63184. * @param initialM42 defines 2nd value of 4th row
  63185. * @param initialM43 defines 3rd value of 4th row
  63186. * @param initialM44 defines 4th value of 4th row
  63187. * @param result defines the target matrix
  63188. */
  63189. 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;
  63190. /**
  63191. * Creates new matrix from a list of values (16)
  63192. * @param initialM11 defines 1st value of 1st row
  63193. * @param initialM12 defines 2nd value of 1st row
  63194. * @param initialM13 defines 3rd value of 1st row
  63195. * @param initialM14 defines 4th value of 1st row
  63196. * @param initialM21 defines 1st value of 2nd row
  63197. * @param initialM22 defines 2nd value of 2nd row
  63198. * @param initialM23 defines 3rd value of 2nd row
  63199. * @param initialM24 defines 4th value of 2nd row
  63200. * @param initialM31 defines 1st value of 3rd row
  63201. * @param initialM32 defines 2nd value of 3rd row
  63202. * @param initialM33 defines 3rd value of 3rd row
  63203. * @param initialM34 defines 4th value of 3rd row
  63204. * @param initialM41 defines 1st value of 4th row
  63205. * @param initialM42 defines 2nd value of 4th row
  63206. * @param initialM43 defines 3rd value of 4th row
  63207. * @param initialM44 defines 4th value of 4th row
  63208. * @returns the new matrix
  63209. */
  63210. 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;
  63211. /**
  63212. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63213. * @param scale defines the scale vector3
  63214. * @param rotation defines the rotation quaternion
  63215. * @param translation defines the translation vector3
  63216. * @returns a new matrix
  63217. */
  63218. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  63219. /**
  63220. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63221. * @param scale defines the scale vector3
  63222. * @param rotation defines the rotation quaternion
  63223. * @param translation defines the translation vector3
  63224. * @param result defines the target matrix
  63225. */
  63226. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  63227. /**
  63228. * Creates a new identity matrix
  63229. * @returns a new identity matrix
  63230. */
  63231. static Identity(): Matrix;
  63232. /**
  63233. * Creates a new identity matrix and stores the result in a given matrix
  63234. * @param result defines the target matrix
  63235. */
  63236. static IdentityToRef(result: Matrix): void;
  63237. /**
  63238. * Creates a new zero matrix
  63239. * @returns a new zero matrix
  63240. */
  63241. static Zero(): Matrix;
  63242. /**
  63243. * Creates a new rotation matrix for "angle" radians around the X axis
  63244. * @param angle defines the angle (in radians) to use
  63245. * @return the new matrix
  63246. */
  63247. static RotationX(angle: number): Matrix;
  63248. /**
  63249. * Creates a new matrix as the invert of a given matrix
  63250. * @param source defines the source matrix
  63251. * @returns the new matrix
  63252. */
  63253. static Invert(source: DeepImmutable<Matrix>): Matrix;
  63254. /**
  63255. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  63256. * @param angle defines the angle (in radians) to use
  63257. * @param result defines the target matrix
  63258. */
  63259. static RotationXToRef(angle: number, result: Matrix): void;
  63260. /**
  63261. * Creates a new rotation matrix for "angle" radians around the Y axis
  63262. * @param angle defines the angle (in radians) to use
  63263. * @return the new matrix
  63264. */
  63265. static RotationY(angle: number): Matrix;
  63266. /**
  63267. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  63268. * @param angle defines the angle (in radians) to use
  63269. * @param result defines the target matrix
  63270. */
  63271. static RotationYToRef(angle: number, result: Matrix): void;
  63272. /**
  63273. * Creates a new rotation matrix for "angle" radians around the Z axis
  63274. * @param angle defines the angle (in radians) to use
  63275. * @return the new matrix
  63276. */
  63277. static RotationZ(angle: number): Matrix;
  63278. /**
  63279. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  63280. * @param angle defines the angle (in radians) to use
  63281. * @param result defines the target matrix
  63282. */
  63283. static RotationZToRef(angle: number, result: Matrix): void;
  63284. /**
  63285. * Creates a new rotation matrix for "angle" radians around the given axis
  63286. * @param axis defines the axis to use
  63287. * @param angle defines the angle (in radians) to use
  63288. * @return the new matrix
  63289. */
  63290. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  63291. /**
  63292. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  63293. * @param axis defines the axis to use
  63294. * @param angle defines the angle (in radians) to use
  63295. * @param result defines the target matrix
  63296. */
  63297. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  63298. /**
  63299. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  63300. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  63301. * @param from defines the vector to align
  63302. * @param to defines the vector to align to
  63303. * @param result defines the target matrix
  63304. */
  63305. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  63306. /**
  63307. * Creates a rotation matrix
  63308. * @param yaw defines the yaw angle in radians (Y axis)
  63309. * @param pitch defines the pitch angle in radians (X axis)
  63310. * @param roll defines the roll angle in radians (X axis)
  63311. * @returns the new rotation matrix
  63312. */
  63313. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  63314. /**
  63315. * Creates a rotation matrix and stores it in a given matrix
  63316. * @param yaw defines the yaw angle in radians (Y axis)
  63317. * @param pitch defines the pitch angle in radians (X axis)
  63318. * @param roll defines the roll angle in radians (X axis)
  63319. * @param result defines the target matrix
  63320. */
  63321. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  63322. /**
  63323. * Creates a scaling matrix
  63324. * @param x defines the scale factor on X axis
  63325. * @param y defines the scale factor on Y axis
  63326. * @param z defines the scale factor on Z axis
  63327. * @returns the new matrix
  63328. */
  63329. static Scaling(x: number, y: number, z: number): Matrix;
  63330. /**
  63331. * Creates a scaling matrix and stores it in a given matrix
  63332. * @param x defines the scale factor on X axis
  63333. * @param y defines the scale factor on Y axis
  63334. * @param z defines the scale factor on Z axis
  63335. * @param result defines the target matrix
  63336. */
  63337. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  63338. /**
  63339. * Creates a translation matrix
  63340. * @param x defines the translation on X axis
  63341. * @param y defines the translation on Y axis
  63342. * @param z defines the translationon Z axis
  63343. * @returns the new matrix
  63344. */
  63345. static Translation(x: number, y: number, z: number): Matrix;
  63346. /**
  63347. * Creates a translation matrix and stores it in a given matrix
  63348. * @param x defines the translation on X axis
  63349. * @param y defines the translation on Y axis
  63350. * @param z defines the translationon Z axis
  63351. * @param result defines the target matrix
  63352. */
  63353. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  63354. /**
  63355. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63356. * @param startValue defines the start value
  63357. * @param endValue defines the end value
  63358. * @param gradient defines the gradient factor
  63359. * @returns the new matrix
  63360. */
  63361. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63362. /**
  63363. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63364. * @param startValue defines the start value
  63365. * @param endValue defines the end value
  63366. * @param gradient defines the gradient factor
  63367. * @param result defines the Matrix object where to store data
  63368. */
  63369. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63370. /**
  63371. * Builds a new matrix whose values are computed by:
  63372. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63373. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63374. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63375. * @param startValue defines the first matrix
  63376. * @param endValue defines the second matrix
  63377. * @param gradient defines the gradient between the two matrices
  63378. * @returns the new matrix
  63379. */
  63380. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63381. /**
  63382. * Update a matrix to values which are computed by:
  63383. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63384. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63385. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63386. * @param startValue defines the first matrix
  63387. * @param endValue defines the second matrix
  63388. * @param gradient defines the gradient between the two matrices
  63389. * @param result defines the target matrix
  63390. */
  63391. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63392. /**
  63393. * 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"
  63394. * This function works in left handed mode
  63395. * @param eye defines the final position of the entity
  63396. * @param target defines where the entity should look at
  63397. * @param up defines the up vector for the entity
  63398. * @returns the new matrix
  63399. */
  63400. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63401. /**
  63402. * 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".
  63403. * This function works in left handed mode
  63404. * @param eye defines the final position of the entity
  63405. * @param target defines where the entity should look at
  63406. * @param up defines the up vector for the entity
  63407. * @param result defines the target matrix
  63408. */
  63409. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63410. /**
  63411. * 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"
  63412. * This function works in right handed mode
  63413. * @param eye defines the final position of the entity
  63414. * @param target defines where the entity should look at
  63415. * @param up defines the up vector for the entity
  63416. * @returns the new matrix
  63417. */
  63418. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63419. /**
  63420. * 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".
  63421. * This function works in right handed mode
  63422. * @param eye defines the final position of the entity
  63423. * @param target defines where the entity should look at
  63424. * @param up defines the up vector for the entity
  63425. * @param result defines the target matrix
  63426. */
  63427. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63428. /**
  63429. * Create a left-handed orthographic projection matrix
  63430. * @param width defines the viewport width
  63431. * @param height defines the viewport height
  63432. * @param znear defines the near clip plane
  63433. * @param zfar defines the far clip plane
  63434. * @returns a new matrix as a left-handed orthographic projection matrix
  63435. */
  63436. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63437. /**
  63438. * Store a left-handed orthographic projection to a given matrix
  63439. * @param width defines the viewport width
  63440. * @param height defines the viewport height
  63441. * @param znear defines the near clip plane
  63442. * @param zfar defines the far clip plane
  63443. * @param result defines the target matrix
  63444. */
  63445. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  63446. /**
  63447. * Create a left-handed orthographic projection matrix
  63448. * @param left defines the viewport left coordinate
  63449. * @param right defines the viewport right coordinate
  63450. * @param bottom defines the viewport bottom coordinate
  63451. * @param top defines the viewport top coordinate
  63452. * @param znear defines the near clip plane
  63453. * @param zfar defines the far clip plane
  63454. * @returns a new matrix as a left-handed orthographic projection matrix
  63455. */
  63456. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63457. /**
  63458. * Stores a left-handed orthographic projection into a given matrix
  63459. * @param left defines the viewport left coordinate
  63460. * @param right defines the viewport right coordinate
  63461. * @param bottom defines the viewport bottom coordinate
  63462. * @param top defines the viewport top coordinate
  63463. * @param znear defines the near clip plane
  63464. * @param zfar defines the far clip plane
  63465. * @param result defines the target matrix
  63466. */
  63467. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63468. /**
  63469. * Creates a right-handed orthographic projection matrix
  63470. * @param left defines the viewport left coordinate
  63471. * @param right defines the viewport right coordinate
  63472. * @param bottom defines the viewport bottom coordinate
  63473. * @param top defines the viewport top coordinate
  63474. * @param znear defines the near clip plane
  63475. * @param zfar defines the far clip plane
  63476. * @returns a new matrix as a right-handed orthographic projection matrix
  63477. */
  63478. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63479. /**
  63480. * Stores a right-handed orthographic projection into a given matrix
  63481. * @param left defines the viewport left coordinate
  63482. * @param right defines the viewport right coordinate
  63483. * @param bottom defines the viewport bottom coordinate
  63484. * @param top defines the viewport top coordinate
  63485. * @param znear defines the near clip plane
  63486. * @param zfar defines the far clip plane
  63487. * @param result defines the target matrix
  63488. */
  63489. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63490. /**
  63491. * Creates a left-handed perspective projection matrix
  63492. * @param width defines the viewport width
  63493. * @param height defines the viewport height
  63494. * @param znear defines the near clip plane
  63495. * @param zfar defines the far clip plane
  63496. * @returns a new matrix as a left-handed perspective projection matrix
  63497. */
  63498. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63499. /**
  63500. * Creates a left-handed perspective projection matrix
  63501. * @param fov defines the horizontal field of view
  63502. * @param aspect defines the aspect ratio
  63503. * @param znear defines the near clip plane
  63504. * @param zfar defines the far clip plane
  63505. * @returns a new matrix as a left-handed perspective projection matrix
  63506. */
  63507. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63508. /**
  63509. * Stores a left-handed perspective projection into a given matrix
  63510. * @param fov defines the horizontal field of view
  63511. * @param aspect defines the aspect ratio
  63512. * @param znear defines the near clip plane
  63513. * @param zfar defines the far clip plane
  63514. * @param result defines the target matrix
  63515. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63516. */
  63517. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63518. /**
  63519. * Creates a right-handed perspective projection matrix
  63520. * @param fov defines the horizontal field of view
  63521. * @param aspect defines the aspect ratio
  63522. * @param znear defines the near clip plane
  63523. * @param zfar defines the far clip plane
  63524. * @returns a new matrix as a right-handed perspective projection matrix
  63525. */
  63526. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63527. /**
  63528. * Stores a right-handed perspective projection into a given matrix
  63529. * @param fov defines the horizontal field of view
  63530. * @param aspect defines the aspect ratio
  63531. * @param znear defines the near clip plane
  63532. * @param zfar defines the far clip plane
  63533. * @param result defines the target matrix
  63534. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63535. */
  63536. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63537. /**
  63538. * Stores a perspective projection for WebVR info a given matrix
  63539. * @param fov defines the field of view
  63540. * @param znear defines the near clip plane
  63541. * @param zfar defines the far clip plane
  63542. * @param result defines the target matrix
  63543. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  63544. */
  63545. static PerspectiveFovWebVRToRef(fov: {
  63546. upDegrees: number;
  63547. downDegrees: number;
  63548. leftDegrees: number;
  63549. rightDegrees: number;
  63550. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  63551. /**
  63552. * Computes a complete transformation matrix
  63553. * @param viewport defines the viewport to use
  63554. * @param world defines the world matrix
  63555. * @param view defines the view matrix
  63556. * @param projection defines the projection matrix
  63557. * @param zmin defines the near clip plane
  63558. * @param zmax defines the far clip plane
  63559. * @returns the transformation matrix
  63560. */
  63561. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  63562. /**
  63563. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  63564. * @param matrix defines the matrix to use
  63565. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  63566. */
  63567. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  63568. /**
  63569. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  63570. * @param matrix defines the matrix to use
  63571. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  63572. */
  63573. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  63574. /**
  63575. * Compute the transpose of a given matrix
  63576. * @param matrix defines the matrix to transpose
  63577. * @returns the new matrix
  63578. */
  63579. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  63580. /**
  63581. * Compute the transpose of a matrix and store it in a target matrix
  63582. * @param matrix defines the matrix to transpose
  63583. * @param result defines the target matrix
  63584. */
  63585. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  63586. /**
  63587. * Computes a reflection matrix from a plane
  63588. * @param plane defines the reflection plane
  63589. * @returns a new matrix
  63590. */
  63591. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  63592. /**
  63593. * Computes a reflection matrix from a plane
  63594. * @param plane defines the reflection plane
  63595. * @param result defines the target matrix
  63596. */
  63597. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  63598. /**
  63599. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  63600. * @param xaxis defines the value of the 1st axis
  63601. * @param yaxis defines the value of the 2nd axis
  63602. * @param zaxis defines the value of the 3rd axis
  63603. * @param result defines the target matrix
  63604. */
  63605. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  63606. /**
  63607. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  63608. * @param quat defines the quaternion to use
  63609. * @param result defines the target matrix
  63610. */
  63611. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  63612. }
  63613. /**
  63614. * Represens a plane by the equation ax + by + cz + d = 0
  63615. */
  63616. export class Plane {
  63617. /**
  63618. * Normal of the plane (a,b,c)
  63619. */
  63620. normal: Vector3;
  63621. /**
  63622. * d component of the plane
  63623. */
  63624. d: number;
  63625. /**
  63626. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  63627. * @param a a component of the plane
  63628. * @param b b component of the plane
  63629. * @param c c component of the plane
  63630. * @param d d component of the plane
  63631. */
  63632. constructor(a: number, b: number, c: number, d: number);
  63633. /**
  63634. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  63635. */
  63636. asArray(): number[];
  63637. /**
  63638. * @returns a new plane copied from the current Plane.
  63639. */
  63640. clone(): Plane;
  63641. /**
  63642. * @returns the string "Plane".
  63643. */
  63644. getClassName(): string;
  63645. /**
  63646. * @returns the Plane hash code.
  63647. */
  63648. getHashCode(): number;
  63649. /**
  63650. * Normalize the current Plane in place.
  63651. * @returns the updated Plane.
  63652. */
  63653. normalize(): Plane;
  63654. /**
  63655. * Applies a transformation the plane and returns the result
  63656. * @param transformation the transformation matrix to be applied to the plane
  63657. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  63658. */
  63659. transform(transformation: DeepImmutable<Matrix>): Plane;
  63660. /**
  63661. * Calcualtte the dot product between the point and the plane normal
  63662. * @param point point to calculate the dot product with
  63663. * @returns the dot product (float) of the point coordinates and the plane normal.
  63664. */
  63665. dotCoordinate(point: DeepImmutable<Vector3>): number;
  63666. /**
  63667. * Updates the current Plane from the plane defined by the three given points.
  63668. * @param point1 one of the points used to contruct the plane
  63669. * @param point2 one of the points used to contruct the plane
  63670. * @param point3 one of the points used to contruct the plane
  63671. * @returns the updated Plane.
  63672. */
  63673. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63674. /**
  63675. * Checks if the plane is facing a given direction
  63676. * @param direction the direction to check if the plane is facing
  63677. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63678. * @returns True is the vector "direction" is the same side than the plane normal.
  63679. */
  63680. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63681. /**
  63682. * Calculates the distance to a point
  63683. * @param point point to calculate distance to
  63684. * @returns the signed distance (float) from the given point to the Plane.
  63685. */
  63686. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63687. /**
  63688. * Creates a plane from an array
  63689. * @param array the array to create a plane from
  63690. * @returns a new Plane from the given array.
  63691. */
  63692. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63693. /**
  63694. * Creates a plane from three points
  63695. * @param point1 point used to create the plane
  63696. * @param point2 point used to create the plane
  63697. * @param point3 point used to create the plane
  63698. * @returns a new Plane defined by the three given points.
  63699. */
  63700. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63701. /**
  63702. * Creates a plane from an origin point and a normal
  63703. * @param origin origin of the plane to be constructed
  63704. * @param normal normal of the plane to be constructed
  63705. * @returns a new Plane the normal vector to this plane at the given origin point.
  63706. * Note : the vector "normal" is updated because normalized.
  63707. */
  63708. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63709. /**
  63710. * Calculates the distance from a plane and a point
  63711. * @param origin origin of the plane to be constructed
  63712. * @param normal normal of the plane to be constructed
  63713. * @param point point to calculate distance to
  63714. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63715. */
  63716. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63717. }
  63718. /**
  63719. * Class used to represent a viewport on screen
  63720. */
  63721. export class Viewport {
  63722. /** viewport left coordinate */
  63723. x: number;
  63724. /** viewport top coordinate */
  63725. y: number;
  63726. /**viewport width */
  63727. width: number;
  63728. /** viewport height */
  63729. height: number;
  63730. /**
  63731. * Creates a Viewport object located at (x, y) and sized (width, height)
  63732. * @param x defines viewport left coordinate
  63733. * @param y defines viewport top coordinate
  63734. * @param width defines the viewport width
  63735. * @param height defines the viewport height
  63736. */
  63737. constructor(
  63738. /** viewport left coordinate */
  63739. x: number,
  63740. /** viewport top coordinate */
  63741. y: number,
  63742. /**viewport width */
  63743. width: number,
  63744. /** viewport height */
  63745. height: number);
  63746. /**
  63747. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63748. * @param renderWidth defines the rendering width
  63749. * @param renderHeight defines the rendering height
  63750. * @returns a new Viewport
  63751. */
  63752. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63753. /**
  63754. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63755. * @param renderWidth defines the rendering width
  63756. * @param renderHeight defines the rendering height
  63757. * @param ref defines the target viewport
  63758. * @returns the current viewport
  63759. */
  63760. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63761. /**
  63762. * Returns a new Viewport copied from the current one
  63763. * @returns a new Viewport
  63764. */
  63765. clone(): Viewport;
  63766. }
  63767. /**
  63768. * Reprasents a camera frustum
  63769. */
  63770. export class Frustum {
  63771. /**
  63772. * Gets the planes representing the frustum
  63773. * @param transform matrix to be applied to the returned planes
  63774. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63775. */
  63776. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63777. /**
  63778. * Gets the near frustum plane transformed by the transform matrix
  63779. * @param transform transformation matrix to be applied to the resulting frustum plane
  63780. * @param frustumPlane the resuling frustum plane
  63781. */
  63782. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63783. /**
  63784. * Gets the far frustum plane transformed by the transform matrix
  63785. * @param transform transformation matrix to be applied to the resulting frustum plane
  63786. * @param frustumPlane the resuling frustum plane
  63787. */
  63788. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63789. /**
  63790. * Gets the left frustum plane transformed by the transform matrix
  63791. * @param transform transformation matrix to be applied to the resulting frustum plane
  63792. * @param frustumPlane the resuling frustum plane
  63793. */
  63794. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63795. /**
  63796. * Gets the right frustum plane transformed by the transform matrix
  63797. * @param transform transformation matrix to be applied to the resulting frustum plane
  63798. * @param frustumPlane the resuling frustum plane
  63799. */
  63800. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63801. /**
  63802. * Gets the top frustum plane transformed by the transform matrix
  63803. * @param transform transformation matrix to be applied to the resulting frustum plane
  63804. * @param frustumPlane the resuling frustum plane
  63805. */
  63806. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63807. /**
  63808. * Gets the bottom frustum plane transformed by the transform matrix
  63809. * @param transform transformation matrix to be applied to the resulting frustum plane
  63810. * @param frustumPlane the resuling frustum plane
  63811. */
  63812. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63813. /**
  63814. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63815. * @param transform transformation matrix to be applied to the resulting frustum planes
  63816. * @param frustumPlanes the resuling frustum planes
  63817. */
  63818. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63819. }
  63820. /** Defines supported spaces */
  63821. export enum Space {
  63822. /** Local (object) space */
  63823. LOCAL = 0,
  63824. /** World space */
  63825. WORLD = 1,
  63826. /** Bone space */
  63827. BONE = 2
  63828. }
  63829. /** Defines the 3 main axes */
  63830. export class Axis {
  63831. /** X axis */
  63832. static X: Vector3;
  63833. /** Y axis */
  63834. static Y: Vector3;
  63835. /** Z axis */
  63836. static Z: Vector3;
  63837. }
  63838. /** Class used to represent a Bezier curve */
  63839. export class BezierCurve {
  63840. /**
  63841. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63842. * @param t defines the time
  63843. * @param x1 defines the left coordinate on X axis
  63844. * @param y1 defines the left coordinate on Y axis
  63845. * @param x2 defines the right coordinate on X axis
  63846. * @param y2 defines the right coordinate on Y axis
  63847. * @returns the interpolated value
  63848. */
  63849. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63850. }
  63851. /**
  63852. * Defines potential orientation for back face culling
  63853. */
  63854. export enum Orientation {
  63855. /**
  63856. * Clockwise
  63857. */
  63858. CW = 0,
  63859. /** Counter clockwise */
  63860. CCW = 1
  63861. }
  63862. /**
  63863. * Defines angle representation
  63864. */
  63865. export class Angle {
  63866. private _radians;
  63867. /**
  63868. * Creates an Angle object of "radians" radians (float).
  63869. * @param radians the angle in radians
  63870. */
  63871. constructor(radians: number);
  63872. /**
  63873. * Get value in degrees
  63874. * @returns the Angle value in degrees (float)
  63875. */
  63876. degrees(): number;
  63877. /**
  63878. * Get value in radians
  63879. * @returns the Angle value in radians (float)
  63880. */
  63881. radians(): number;
  63882. /**
  63883. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63884. * @param a defines first vector
  63885. * @param b defines second vector
  63886. * @returns a new Angle
  63887. */
  63888. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63889. /**
  63890. * Gets a new Angle object from the given float in radians
  63891. * @param radians defines the angle value in radians
  63892. * @returns a new Angle
  63893. */
  63894. static FromRadians(radians: number): Angle;
  63895. /**
  63896. * Gets a new Angle object from the given float in degrees
  63897. * @param degrees defines the angle value in degrees
  63898. * @returns a new Angle
  63899. */
  63900. static FromDegrees(degrees: number): Angle;
  63901. }
  63902. /**
  63903. * This represents an arc in a 2d space.
  63904. */
  63905. export class Arc2 {
  63906. /** Defines the start point of the arc */
  63907. startPoint: Vector2;
  63908. /** Defines the mid point of the arc */
  63909. midPoint: Vector2;
  63910. /** Defines the end point of the arc */
  63911. endPoint: Vector2;
  63912. /**
  63913. * Defines the center point of the arc.
  63914. */
  63915. centerPoint: Vector2;
  63916. /**
  63917. * Defines the radius of the arc.
  63918. */
  63919. radius: number;
  63920. /**
  63921. * Defines the angle of the arc (from mid point to end point).
  63922. */
  63923. angle: Angle;
  63924. /**
  63925. * Defines the start angle of the arc (from start point to middle point).
  63926. */
  63927. startAngle: Angle;
  63928. /**
  63929. * Defines the orientation of the arc (clock wise/counter clock wise).
  63930. */
  63931. orientation: Orientation;
  63932. /**
  63933. * Creates an Arc object from the three given points : start, middle and end.
  63934. * @param startPoint Defines the start point of the arc
  63935. * @param midPoint Defines the midlle point of the arc
  63936. * @param endPoint Defines the end point of the arc
  63937. */
  63938. constructor(
  63939. /** Defines the start point of the arc */
  63940. startPoint: Vector2,
  63941. /** Defines the mid point of the arc */
  63942. midPoint: Vector2,
  63943. /** Defines the end point of the arc */
  63944. endPoint: Vector2);
  63945. }
  63946. /**
  63947. * Represents a 2D path made up of multiple 2D points
  63948. */
  63949. export class Path2 {
  63950. private _points;
  63951. private _length;
  63952. /**
  63953. * If the path start and end point are the same
  63954. */
  63955. closed: boolean;
  63956. /**
  63957. * Creates a Path2 object from the starting 2D coordinates x and y.
  63958. * @param x the starting points x value
  63959. * @param y the starting points y value
  63960. */
  63961. constructor(x: number, y: number);
  63962. /**
  63963. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63964. * @param x the added points x value
  63965. * @param y the added points y value
  63966. * @returns the updated Path2.
  63967. */
  63968. addLineTo(x: number, y: number): Path2;
  63969. /**
  63970. * 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.
  63971. * @param midX middle point x value
  63972. * @param midY middle point y value
  63973. * @param endX end point x value
  63974. * @param endY end point y value
  63975. * @param numberOfSegments (default: 36)
  63976. * @returns the updated Path2.
  63977. */
  63978. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63979. /**
  63980. * Closes the Path2.
  63981. * @returns the Path2.
  63982. */
  63983. close(): Path2;
  63984. /**
  63985. * Gets the sum of the distance between each sequential point in the path
  63986. * @returns the Path2 total length (float).
  63987. */
  63988. length(): number;
  63989. /**
  63990. * Gets the points which construct the path
  63991. * @returns the Path2 internal array of points.
  63992. */
  63993. getPoints(): Vector2[];
  63994. /**
  63995. * Retreives the point at the distance aways from the starting point
  63996. * @param normalizedLengthPosition the length along the path to retreive the point from
  63997. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63998. */
  63999. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  64000. /**
  64001. * Creates a new path starting from an x and y position
  64002. * @param x starting x value
  64003. * @param y starting y value
  64004. * @returns a new Path2 starting at the coordinates (x, y).
  64005. */
  64006. static StartingAt(x: number, y: number): Path2;
  64007. }
  64008. /**
  64009. * Represents a 3D path made up of multiple 3D points
  64010. */
  64011. export class Path3D {
  64012. /**
  64013. * an array of Vector3, the curve axis of the Path3D
  64014. */
  64015. path: Vector3[];
  64016. private _curve;
  64017. private _distances;
  64018. private _tangents;
  64019. private _normals;
  64020. private _binormals;
  64021. private _raw;
  64022. /**
  64023. * new Path3D(path, normal, raw)
  64024. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  64025. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  64026. * @param path an array of Vector3, the curve axis of the Path3D
  64027. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  64028. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  64029. */
  64030. constructor(
  64031. /**
  64032. * an array of Vector3, the curve axis of the Path3D
  64033. */
  64034. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  64035. /**
  64036. * Returns the Path3D array of successive Vector3 designing its curve.
  64037. * @returns the Path3D array of successive Vector3 designing its curve.
  64038. */
  64039. getCurve(): Vector3[];
  64040. /**
  64041. * Returns an array populated with tangent vectors on each Path3D curve point.
  64042. * @returns an array populated with tangent vectors on each Path3D curve point.
  64043. */
  64044. getTangents(): Vector3[];
  64045. /**
  64046. * Returns an array populated with normal vectors on each Path3D curve point.
  64047. * @returns an array populated with normal vectors on each Path3D curve point.
  64048. */
  64049. getNormals(): Vector3[];
  64050. /**
  64051. * Returns an array populated with binormal vectors on each Path3D curve point.
  64052. * @returns an array populated with binormal vectors on each Path3D curve point.
  64053. */
  64054. getBinormals(): Vector3[];
  64055. /**
  64056. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  64057. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  64058. */
  64059. getDistances(): number[];
  64060. /**
  64061. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  64062. * @param path path which all values are copied into the curves points
  64063. * @param firstNormal which should be projected onto the curve
  64064. * @returns the same object updated.
  64065. */
  64066. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  64067. private _compute;
  64068. private _getFirstNonNullVector;
  64069. private _getLastNonNullVector;
  64070. private _normalVector;
  64071. }
  64072. /**
  64073. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  64074. * A Curve3 is designed from a series of successive Vector3.
  64075. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  64076. */
  64077. export class Curve3 {
  64078. private _points;
  64079. private _length;
  64080. /**
  64081. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  64082. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  64083. * @param v1 (Vector3) the control point
  64084. * @param v2 (Vector3) the end point of the Quadratic Bezier
  64085. * @param nbPoints (integer) the wanted number of points in the curve
  64086. * @returns the created Curve3
  64087. */
  64088. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  64089. /**
  64090. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  64091. * @param v0 (Vector3) the origin point of the Cubic Bezier
  64092. * @param v1 (Vector3) the first control point
  64093. * @param v2 (Vector3) the second control point
  64094. * @param v3 (Vector3) the end point of the Cubic Bezier
  64095. * @param nbPoints (integer) the wanted number of points in the curve
  64096. * @returns the created Curve3
  64097. */
  64098. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  64099. /**
  64100. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  64101. * @param p1 (Vector3) the origin point of the Hermite Spline
  64102. * @param t1 (Vector3) the tangent vector at the origin point
  64103. * @param p2 (Vector3) the end point of the Hermite Spline
  64104. * @param t2 (Vector3) the tangent vector at the end point
  64105. * @param nbPoints (integer) the wanted number of points in the curve
  64106. * @returns the created Curve3
  64107. */
  64108. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  64109. /**
  64110. * Returns a Curve3 object along a CatmullRom Spline curve :
  64111. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  64112. * @param nbPoints (integer) the wanted number of points between each curve control points
  64113. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  64114. * @returns the created Curve3
  64115. */
  64116. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  64117. /**
  64118. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  64119. * A Curve3 is designed from a series of successive Vector3.
  64120. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  64121. * @param points points which make up the curve
  64122. */
  64123. constructor(points: Vector3[]);
  64124. /**
  64125. * @returns the Curve3 stored array of successive Vector3
  64126. */
  64127. getPoints(): Vector3[];
  64128. /**
  64129. * @returns the computed length (float) of the curve.
  64130. */
  64131. length(): number;
  64132. /**
  64133. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  64134. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  64135. * curveA and curveB keep unchanged.
  64136. * @param curve the curve to continue from this curve
  64137. * @returns the newly constructed curve
  64138. */
  64139. continue(curve: DeepImmutable<Curve3>): Curve3;
  64140. private _computeLength;
  64141. }
  64142. /**
  64143. * Contains position and normal vectors for a vertex
  64144. */
  64145. export class PositionNormalVertex {
  64146. /** the position of the vertex (defaut: 0,0,0) */
  64147. position: Vector3;
  64148. /** the normal of the vertex (defaut: 0,1,0) */
  64149. normal: Vector3;
  64150. /**
  64151. * Creates a PositionNormalVertex
  64152. * @param position the position of the vertex (defaut: 0,0,0)
  64153. * @param normal the normal of the vertex (defaut: 0,1,0)
  64154. */
  64155. constructor(
  64156. /** the position of the vertex (defaut: 0,0,0) */
  64157. position?: Vector3,
  64158. /** the normal of the vertex (defaut: 0,1,0) */
  64159. normal?: Vector3);
  64160. /**
  64161. * Clones the PositionNormalVertex
  64162. * @returns the cloned PositionNormalVertex
  64163. */
  64164. clone(): PositionNormalVertex;
  64165. }
  64166. /**
  64167. * Contains position, normal and uv vectors for a vertex
  64168. */
  64169. export class PositionNormalTextureVertex {
  64170. /** the position of the vertex (defaut: 0,0,0) */
  64171. position: Vector3;
  64172. /** the normal of the vertex (defaut: 0,1,0) */
  64173. normal: Vector3;
  64174. /** the uv of the vertex (default: 0,0) */
  64175. uv: Vector2;
  64176. /**
  64177. * Creates a PositionNormalTextureVertex
  64178. * @param position the position of the vertex (defaut: 0,0,0)
  64179. * @param normal the normal of the vertex (defaut: 0,1,0)
  64180. * @param uv the uv of the vertex (default: 0,0)
  64181. */
  64182. constructor(
  64183. /** the position of the vertex (defaut: 0,0,0) */
  64184. position?: Vector3,
  64185. /** the normal of the vertex (defaut: 0,1,0) */
  64186. normal?: Vector3,
  64187. /** the uv of the vertex (default: 0,0) */
  64188. uv?: Vector2);
  64189. /**
  64190. * Clones the PositionNormalTextureVertex
  64191. * @returns the cloned PositionNormalTextureVertex
  64192. */
  64193. clone(): PositionNormalTextureVertex;
  64194. }
  64195. /**
  64196. * @hidden
  64197. */
  64198. export class Tmp {
  64199. static Color3: Color3[];
  64200. static Color4: Color4[];
  64201. static Vector2: Vector2[];
  64202. static Vector3: Vector3[];
  64203. static Vector4: Vector4[];
  64204. static Quaternion: Quaternion[];
  64205. static Matrix: Matrix[];
  64206. }
  64207. }
  64208. declare module BABYLON {
  64209. /**
  64210. * Class used to enable access to offline support
  64211. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64212. */
  64213. export interface IOfflineProvider {
  64214. /**
  64215. * Gets a boolean indicating if scene must be saved in the database
  64216. */
  64217. enableSceneOffline: boolean;
  64218. /**
  64219. * Gets a boolean indicating if textures must be saved in the database
  64220. */
  64221. enableTexturesOffline: boolean;
  64222. /**
  64223. * Open the offline support and make it available
  64224. * @param successCallback defines the callback to call on success
  64225. * @param errorCallback defines the callback to call on error
  64226. */
  64227. open(successCallback: () => void, errorCallback: () => void): void;
  64228. /**
  64229. * Loads an image from the offline support
  64230. * @param url defines the url to load from
  64231. * @param image defines the target DOM image
  64232. */
  64233. loadImage(url: string, image: HTMLImageElement): void;
  64234. /**
  64235. * Loads a file from offline support
  64236. * @param url defines the URL to load from
  64237. * @param sceneLoaded defines a callback to call on success
  64238. * @param progressCallBack defines a callback to call when progress changed
  64239. * @param errorCallback defines a callback to call on error
  64240. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64241. */
  64242. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64243. }
  64244. }
  64245. declare module BABYLON {
  64246. /**
  64247. * A class serves as a medium between the observable and its observers
  64248. */
  64249. export class EventState {
  64250. /**
  64251. * Create a new EventState
  64252. * @param mask defines the mask associated with this state
  64253. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64254. * @param target defines the original target of the state
  64255. * @param currentTarget defines the current target of the state
  64256. */
  64257. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64258. /**
  64259. * Initialize the current event state
  64260. * @param mask defines the mask associated with this state
  64261. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64262. * @param target defines the original target of the state
  64263. * @param currentTarget defines the current target of the state
  64264. * @returns the current event state
  64265. */
  64266. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64267. /**
  64268. * An Observer can set this property to true to prevent subsequent observers of being notified
  64269. */
  64270. skipNextObservers: boolean;
  64271. /**
  64272. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64273. */
  64274. mask: number;
  64275. /**
  64276. * The object that originally notified the event
  64277. */
  64278. target?: any;
  64279. /**
  64280. * The current object in the bubbling phase
  64281. */
  64282. currentTarget?: any;
  64283. /**
  64284. * This will be populated with the return value of the last function that was executed.
  64285. * If it is the first function in the callback chain it will be the event data.
  64286. */
  64287. lastReturnValue?: any;
  64288. }
  64289. /**
  64290. * Represent an Observer registered to a given Observable object.
  64291. */
  64292. export class Observer<T> {
  64293. /**
  64294. * Defines the callback to call when the observer is notified
  64295. */
  64296. callback: (eventData: T, eventState: EventState) => void;
  64297. /**
  64298. * Defines the mask of the observer (used to filter notifications)
  64299. */
  64300. mask: number;
  64301. /**
  64302. * Defines the current scope used to restore the JS context
  64303. */
  64304. scope: any;
  64305. /** @hidden */
  64306. _willBeUnregistered: boolean;
  64307. /**
  64308. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64309. */
  64310. unregisterOnNextCall: boolean;
  64311. /**
  64312. * Creates a new observer
  64313. * @param callback defines the callback to call when the observer is notified
  64314. * @param mask defines the mask of the observer (used to filter notifications)
  64315. * @param scope defines the current scope used to restore the JS context
  64316. */
  64317. constructor(
  64318. /**
  64319. * Defines the callback to call when the observer is notified
  64320. */
  64321. callback: (eventData: T, eventState: EventState) => void,
  64322. /**
  64323. * Defines the mask of the observer (used to filter notifications)
  64324. */
  64325. mask: number,
  64326. /**
  64327. * Defines the current scope used to restore the JS context
  64328. */
  64329. scope?: any);
  64330. }
  64331. /**
  64332. * Represent a list of observers registered to multiple Observables object.
  64333. */
  64334. export class MultiObserver<T> {
  64335. private _observers;
  64336. private _observables;
  64337. /**
  64338. * Release associated resources
  64339. */
  64340. dispose(): void;
  64341. /**
  64342. * Raise a callback when one of the observable will notify
  64343. * @param observables defines a list of observables to watch
  64344. * @param callback defines the callback to call on notification
  64345. * @param mask defines the mask used to filter notifications
  64346. * @param scope defines the current scope used to restore the JS context
  64347. * @returns the new MultiObserver
  64348. */
  64349. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64350. }
  64351. /**
  64352. * The Observable class is a simple implementation of the Observable pattern.
  64353. *
  64354. * 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.
  64355. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64356. * 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).
  64357. * 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.
  64358. */
  64359. export class Observable<T> {
  64360. private _observers;
  64361. private _eventState;
  64362. private _onObserverAdded;
  64363. /**
  64364. * Creates a new observable
  64365. * @param onObserverAdded defines a callback to call when a new observer is added
  64366. */
  64367. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64368. /**
  64369. * Create a new Observer with the specified callback
  64370. * @param callback the callback that will be executed for that Observer
  64371. * @param mask the mask used to filter observers
  64372. * @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.
  64373. * @param scope optional scope for the callback to be called from
  64374. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64375. * @returns the new observer created for the callback
  64376. */
  64377. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64378. /**
  64379. * Create a new Observer with the specified callback and unregisters after the next notification
  64380. * @param callback the callback that will be executed for that Observer
  64381. * @returns the new observer created for the callback
  64382. */
  64383. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64384. /**
  64385. * Remove an Observer from the Observable object
  64386. * @param observer the instance of the Observer to remove
  64387. * @returns false if it doesn't belong to this Observable
  64388. */
  64389. remove(observer: Nullable<Observer<T>>): boolean;
  64390. /**
  64391. * Remove a callback from the Observable object
  64392. * @param callback the callback to remove
  64393. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64394. * @returns false if it doesn't belong to this Observable
  64395. */
  64396. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64397. private _deferUnregister;
  64398. private _remove;
  64399. /**
  64400. * Moves the observable to the top of the observer list making it get called first when notified
  64401. * @param observer the observer to move
  64402. */
  64403. makeObserverTopPriority(observer: Observer<T>): void;
  64404. /**
  64405. * Moves the observable to the bottom of the observer list making it get called last when notified
  64406. * @param observer the observer to move
  64407. */
  64408. makeObserverBottomPriority(observer: Observer<T>): void;
  64409. /**
  64410. * Notify all Observers by calling their respective callback with the given data
  64411. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64412. * @param eventData defines the data to send to all observers
  64413. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64414. * @param target defines the original target of the state
  64415. * @param currentTarget defines the current target of the state
  64416. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64417. */
  64418. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64419. /**
  64420. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64421. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64422. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64423. * and it is crucial that all callbacks will be executed.
  64424. * The order of the callbacks is kept, callbacks are not executed parallel.
  64425. *
  64426. * @param eventData The data to be sent to each callback
  64427. * @param mask is used to filter observers defaults to -1
  64428. * @param target defines the callback target (see EventState)
  64429. * @param currentTarget defines he current object in the bubbling phase
  64430. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64431. */
  64432. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64433. /**
  64434. * Notify a specific observer
  64435. * @param observer defines the observer to notify
  64436. * @param eventData defines the data to be sent to each callback
  64437. * @param mask is used to filter observers defaults to -1
  64438. */
  64439. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64440. /**
  64441. * Gets a boolean indicating if the observable has at least one observer
  64442. * @returns true is the Observable has at least one Observer registered
  64443. */
  64444. hasObservers(): boolean;
  64445. /**
  64446. * Clear the list of observers
  64447. */
  64448. clear(): void;
  64449. /**
  64450. * Clone the current observable
  64451. * @returns a new observable
  64452. */
  64453. clone(): Observable<T>;
  64454. /**
  64455. * Does this observable handles observer registered with a given mask
  64456. * @param mask defines the mask to be tested
  64457. * @return whether or not one observer registered with the given mask is handeled
  64458. **/
  64459. hasSpecificMask(mask?: number): boolean;
  64460. }
  64461. }
  64462. declare module BABYLON {
  64463. /**
  64464. * Class used to help managing file picking and drag'n'drop
  64465. * File Storage
  64466. */
  64467. export class FilesInputStore {
  64468. /**
  64469. * List of files ready to be loaded
  64470. */
  64471. static FilesToLoad: {
  64472. [key: string]: File;
  64473. };
  64474. }
  64475. }
  64476. declare module BABYLON {
  64477. /** Defines the cross module used constants to avoid circular dependncies */
  64478. export class Constants {
  64479. /** Defines that alpha blending is disabled */
  64480. static readonly ALPHA_DISABLE: number;
  64481. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  64482. static readonly ALPHA_ADD: number;
  64483. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  64484. static readonly ALPHA_COMBINE: number;
  64485. /** Defines that alpha blending to DEST - SRC * DEST */
  64486. static readonly ALPHA_SUBTRACT: number;
  64487. /** Defines that alpha blending to SRC * DEST */
  64488. static readonly ALPHA_MULTIPLY: number;
  64489. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  64490. static readonly ALPHA_MAXIMIZED: number;
  64491. /** Defines that alpha blending to SRC + DEST */
  64492. static readonly ALPHA_ONEONE: number;
  64493. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  64494. static readonly ALPHA_PREMULTIPLIED: number;
  64495. /**
  64496. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  64497. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  64498. */
  64499. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  64500. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  64501. static readonly ALPHA_INTERPOLATE: number;
  64502. /**
  64503. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  64504. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  64505. */
  64506. static readonly ALPHA_SCREENMODE: number;
  64507. /** Defines that the ressource is not delayed*/
  64508. static readonly DELAYLOADSTATE_NONE: number;
  64509. /** Defines that the ressource was successfully delay loaded */
  64510. static readonly DELAYLOADSTATE_LOADED: number;
  64511. /** Defines that the ressource is currently delay loading */
  64512. static readonly DELAYLOADSTATE_LOADING: number;
  64513. /** Defines that the ressource is delayed and has not started loading */
  64514. static readonly DELAYLOADSTATE_NOTLOADED: number;
  64515. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  64516. static readonly NEVER: number;
  64517. /** 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 */
  64518. static readonly ALWAYS: number;
  64519. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  64520. static readonly LESS: number;
  64521. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  64522. static readonly EQUAL: number;
  64523. /** 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 */
  64524. static readonly LEQUAL: number;
  64525. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  64526. static readonly GREATER: number;
  64527. /** 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 */
  64528. static readonly GEQUAL: number;
  64529. /** 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 */
  64530. static readonly NOTEQUAL: number;
  64531. /** Passed to stencilOperation to specify that stencil value must be kept */
  64532. static readonly KEEP: number;
  64533. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64534. static readonly REPLACE: number;
  64535. /** Passed to stencilOperation to specify that stencil value must be incremented */
  64536. static readonly INCR: number;
  64537. /** Passed to stencilOperation to specify that stencil value must be decremented */
  64538. static readonly DECR: number;
  64539. /** Passed to stencilOperation to specify that stencil value must be inverted */
  64540. static readonly INVERT: number;
  64541. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  64542. static readonly INCR_WRAP: number;
  64543. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  64544. static readonly DECR_WRAP: number;
  64545. /** Texture is not repeating outside of 0..1 UVs */
  64546. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  64547. /** Texture is repeating outside of 0..1 UVs */
  64548. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  64549. /** Texture is repeating and mirrored */
  64550. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  64551. /** ALPHA */
  64552. static readonly TEXTUREFORMAT_ALPHA: number;
  64553. /** LUMINANCE */
  64554. static readonly TEXTUREFORMAT_LUMINANCE: number;
  64555. /** LUMINANCE_ALPHA */
  64556. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  64557. /** RGB */
  64558. static readonly TEXTUREFORMAT_RGB: number;
  64559. /** RGBA */
  64560. static readonly TEXTUREFORMAT_RGBA: number;
  64561. /** RED */
  64562. static readonly TEXTUREFORMAT_RED: number;
  64563. /** RED (2nd reference) */
  64564. static readonly TEXTUREFORMAT_R: number;
  64565. /** RG */
  64566. static readonly TEXTUREFORMAT_RG: number;
  64567. /** RED_INTEGER */
  64568. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  64569. /** RED_INTEGER (2nd reference) */
  64570. static readonly TEXTUREFORMAT_R_INTEGER: number;
  64571. /** RG_INTEGER */
  64572. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  64573. /** RGB_INTEGER */
  64574. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  64575. /** RGBA_INTEGER */
  64576. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  64577. /** UNSIGNED_BYTE */
  64578. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  64579. /** UNSIGNED_BYTE (2nd reference) */
  64580. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  64581. /** FLOAT */
  64582. static readonly TEXTURETYPE_FLOAT: number;
  64583. /** HALF_FLOAT */
  64584. static readonly TEXTURETYPE_HALF_FLOAT: number;
  64585. /** BYTE */
  64586. static readonly TEXTURETYPE_BYTE: number;
  64587. /** SHORT */
  64588. static readonly TEXTURETYPE_SHORT: number;
  64589. /** UNSIGNED_SHORT */
  64590. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  64591. /** INT */
  64592. static readonly TEXTURETYPE_INT: number;
  64593. /** UNSIGNED_INT */
  64594. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  64595. /** UNSIGNED_SHORT_4_4_4_4 */
  64596. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  64597. /** UNSIGNED_SHORT_5_5_5_1 */
  64598. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  64599. /** UNSIGNED_SHORT_5_6_5 */
  64600. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  64601. /** UNSIGNED_INT_2_10_10_10_REV */
  64602. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  64603. /** UNSIGNED_INT_24_8 */
  64604. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  64605. /** UNSIGNED_INT_10F_11F_11F_REV */
  64606. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  64607. /** UNSIGNED_INT_5_9_9_9_REV */
  64608. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  64609. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  64610. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64611. /** nearest is mag = nearest and min = nearest and mip = linear */
  64612. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  64613. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64614. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  64615. /** Trilinear is mag = linear and min = linear and mip = linear */
  64616. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  64617. /** nearest is mag = nearest and min = nearest and mip = linear */
  64618. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  64619. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64620. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  64621. /** Trilinear is mag = linear and min = linear and mip = linear */
  64622. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  64623. /** mag = nearest and min = nearest and mip = nearest */
  64624. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  64625. /** mag = nearest and min = linear and mip = nearest */
  64626. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  64627. /** mag = nearest and min = linear and mip = linear */
  64628. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  64629. /** mag = nearest and min = linear and mip = none */
  64630. static readonly TEXTURE_NEAREST_LINEAR: number;
  64631. /** mag = nearest and min = nearest and mip = none */
  64632. static readonly TEXTURE_NEAREST_NEAREST: number;
  64633. /** mag = linear and min = nearest and mip = nearest */
  64634. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  64635. /** mag = linear and min = nearest and mip = linear */
  64636. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  64637. /** mag = linear and min = linear and mip = none */
  64638. static readonly TEXTURE_LINEAR_LINEAR: number;
  64639. /** mag = linear and min = nearest and mip = none */
  64640. static readonly TEXTURE_LINEAR_NEAREST: number;
  64641. /** Explicit coordinates mode */
  64642. static readonly TEXTURE_EXPLICIT_MODE: number;
  64643. /** Spherical coordinates mode */
  64644. static readonly TEXTURE_SPHERICAL_MODE: number;
  64645. /** Planar coordinates mode */
  64646. static readonly TEXTURE_PLANAR_MODE: number;
  64647. /** Cubic coordinates mode */
  64648. static readonly TEXTURE_CUBIC_MODE: number;
  64649. /** Projection coordinates mode */
  64650. static readonly TEXTURE_PROJECTION_MODE: number;
  64651. /** Skybox coordinates mode */
  64652. static readonly TEXTURE_SKYBOX_MODE: number;
  64653. /** Inverse Cubic coordinates mode */
  64654. static readonly TEXTURE_INVCUBIC_MODE: number;
  64655. /** Equirectangular coordinates mode */
  64656. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  64657. /** Equirectangular Fixed coordinates mode */
  64658. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  64659. /** Equirectangular Fixed Mirrored coordinates mode */
  64660. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  64661. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  64662. static readonly SCALEMODE_FLOOR: number;
  64663. /** Defines that texture rescaling will look for the nearest power of 2 size */
  64664. static readonly SCALEMODE_NEAREST: number;
  64665. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  64666. static readonly SCALEMODE_CEILING: number;
  64667. /**
  64668. * The dirty texture flag value
  64669. */
  64670. static readonly MATERIAL_TextureDirtyFlag: number;
  64671. /**
  64672. * The dirty light flag value
  64673. */
  64674. static readonly MATERIAL_LightDirtyFlag: number;
  64675. /**
  64676. * The dirty fresnel flag value
  64677. */
  64678. static readonly MATERIAL_FresnelDirtyFlag: number;
  64679. /**
  64680. * The dirty attribute flag value
  64681. */
  64682. static readonly MATERIAL_AttributesDirtyFlag: number;
  64683. /**
  64684. * The dirty misc flag value
  64685. */
  64686. static readonly MATERIAL_MiscDirtyFlag: number;
  64687. /**
  64688. * The all dirty flag value
  64689. */
  64690. static readonly MATERIAL_AllDirtyFlag: number;
  64691. /**
  64692. * Returns the triangle fill mode
  64693. */
  64694. static readonly MATERIAL_TriangleFillMode: number;
  64695. /**
  64696. * Returns the wireframe mode
  64697. */
  64698. static readonly MATERIAL_WireFrameFillMode: number;
  64699. /**
  64700. * Returns the point fill mode
  64701. */
  64702. static readonly MATERIAL_PointFillMode: number;
  64703. /**
  64704. * Returns the point list draw mode
  64705. */
  64706. static readonly MATERIAL_PointListDrawMode: number;
  64707. /**
  64708. * Returns the line list draw mode
  64709. */
  64710. static readonly MATERIAL_LineListDrawMode: number;
  64711. /**
  64712. * Returns the line loop draw mode
  64713. */
  64714. static readonly MATERIAL_LineLoopDrawMode: number;
  64715. /**
  64716. * Returns the line strip draw mode
  64717. */
  64718. static readonly MATERIAL_LineStripDrawMode: number;
  64719. /**
  64720. * Returns the triangle strip draw mode
  64721. */
  64722. static readonly MATERIAL_TriangleStripDrawMode: number;
  64723. /**
  64724. * Returns the triangle fan draw mode
  64725. */
  64726. static readonly MATERIAL_TriangleFanDrawMode: number;
  64727. /**
  64728. * Stores the clock-wise side orientation
  64729. */
  64730. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64731. /**
  64732. * Stores the counter clock-wise side orientation
  64733. */
  64734. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64735. /**
  64736. * Nothing
  64737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64738. */
  64739. static readonly ACTION_NothingTrigger: number;
  64740. /**
  64741. * On pick
  64742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64743. */
  64744. static readonly ACTION_OnPickTrigger: number;
  64745. /**
  64746. * On left pick
  64747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64748. */
  64749. static readonly ACTION_OnLeftPickTrigger: number;
  64750. /**
  64751. * On right pick
  64752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64753. */
  64754. static readonly ACTION_OnRightPickTrigger: number;
  64755. /**
  64756. * On center pick
  64757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64758. */
  64759. static readonly ACTION_OnCenterPickTrigger: number;
  64760. /**
  64761. * On pick down
  64762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64763. */
  64764. static readonly ACTION_OnPickDownTrigger: number;
  64765. /**
  64766. * On double pick
  64767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64768. */
  64769. static readonly ACTION_OnDoublePickTrigger: number;
  64770. /**
  64771. * On pick up
  64772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64773. */
  64774. static readonly ACTION_OnPickUpTrigger: number;
  64775. /**
  64776. * On pick out.
  64777. * This trigger will only be raised if you also declared a OnPickDown
  64778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64779. */
  64780. static readonly ACTION_OnPickOutTrigger: number;
  64781. /**
  64782. * On long press
  64783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64784. */
  64785. static readonly ACTION_OnLongPressTrigger: number;
  64786. /**
  64787. * On pointer over
  64788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64789. */
  64790. static readonly ACTION_OnPointerOverTrigger: number;
  64791. /**
  64792. * On pointer out
  64793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64794. */
  64795. static readonly ACTION_OnPointerOutTrigger: number;
  64796. /**
  64797. * On every frame
  64798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64799. */
  64800. static readonly ACTION_OnEveryFrameTrigger: number;
  64801. /**
  64802. * On intersection enter
  64803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64804. */
  64805. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64806. /**
  64807. * On intersection exit
  64808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64809. */
  64810. static readonly ACTION_OnIntersectionExitTrigger: number;
  64811. /**
  64812. * On key down
  64813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64814. */
  64815. static readonly ACTION_OnKeyDownTrigger: number;
  64816. /**
  64817. * On key up
  64818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64819. */
  64820. static readonly ACTION_OnKeyUpTrigger: number;
  64821. /**
  64822. * Billboard mode will only apply to Y axis
  64823. */
  64824. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64825. /**
  64826. * Billboard mode will apply to all axes
  64827. */
  64828. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64829. /**
  64830. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64831. */
  64832. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64833. /**
  64834. * Gets or sets base Assets URL
  64835. */
  64836. static readonly PARTICLES_BaseAssetsUrl: string;
  64837. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64838. * Test order :
  64839. * Is the bounding sphere outside the frustum ?
  64840. * If not, are the bounding box vertices outside the frustum ?
  64841. * It not, then the cullable object is in the frustum.
  64842. */
  64843. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64844. /** Culling strategy : Bounding Sphere Only.
  64845. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64846. * It's also less accurate than the standard because some not visible objects can still be selected.
  64847. * Test : is the bounding sphere outside the frustum ?
  64848. * If not, then the cullable object is in the frustum.
  64849. */
  64850. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64851. /** Culling strategy : Optimistic Inclusion.
  64852. * This in an inclusion test first, then the standard exclusion test.
  64853. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64854. * 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.
  64855. * Anyway, it's as accurate as the standard strategy.
  64856. * Test :
  64857. * Is the cullable object bounding sphere center in the frustum ?
  64858. * If not, apply the default culling strategy.
  64859. */
  64860. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64861. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64862. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64863. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64864. * 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.
  64865. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64866. * Test :
  64867. * Is the cullable object bounding sphere center in the frustum ?
  64868. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64869. */
  64870. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64871. /**
  64872. * No logging while loading
  64873. */
  64874. static readonly SCENELOADER_NO_LOGGING: number;
  64875. /**
  64876. * Minimal logging while loading
  64877. */
  64878. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64879. /**
  64880. * Summary logging while loading
  64881. */
  64882. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64883. /**
  64884. * Detailled logging while loading
  64885. */
  64886. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64887. }
  64888. }
  64889. declare module BABYLON {
  64890. /**
  64891. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64892. * Babylon.js
  64893. */
  64894. export class DomManagement {
  64895. /**
  64896. * Checks if the window object exists
  64897. * @returns true if the window object exists
  64898. */
  64899. static IsWindowObjectExist(): boolean;
  64900. /**
  64901. * Extracts text content from a DOM element hierarchy
  64902. * @param element defines the root element
  64903. * @returns a string
  64904. */
  64905. static GetDOMTextContent(element: HTMLElement): string;
  64906. }
  64907. }
  64908. declare module BABYLON {
  64909. /**
  64910. * Logger used througouht the application to allow configuration of
  64911. * the log level required for the messages.
  64912. */
  64913. export class Logger {
  64914. /**
  64915. * No log
  64916. */
  64917. static readonly NoneLogLevel: number;
  64918. /**
  64919. * Only message logs
  64920. */
  64921. static readonly MessageLogLevel: number;
  64922. /**
  64923. * Only warning logs
  64924. */
  64925. static readonly WarningLogLevel: number;
  64926. /**
  64927. * Only error logs
  64928. */
  64929. static readonly ErrorLogLevel: number;
  64930. /**
  64931. * All logs
  64932. */
  64933. static readonly AllLogLevel: number;
  64934. private static _LogCache;
  64935. /**
  64936. * Gets a value indicating the number of loading errors
  64937. * @ignorenaming
  64938. */
  64939. static errorsCount: number;
  64940. /**
  64941. * Callback called when a new log is added
  64942. */
  64943. static OnNewCacheEntry: (entry: string) => void;
  64944. private static _AddLogEntry;
  64945. private static _FormatMessage;
  64946. private static _LogDisabled;
  64947. private static _LogEnabled;
  64948. private static _WarnDisabled;
  64949. private static _WarnEnabled;
  64950. private static _ErrorDisabled;
  64951. private static _ErrorEnabled;
  64952. /**
  64953. * Log a message to the console
  64954. */
  64955. static Log: (message: string) => void;
  64956. /**
  64957. * Write a warning message to the console
  64958. */
  64959. static Warn: (message: string) => void;
  64960. /**
  64961. * Write an error message to the console
  64962. */
  64963. static Error: (message: string) => void;
  64964. /**
  64965. * Gets current log cache (list of logs)
  64966. */
  64967. static readonly LogCache: string;
  64968. /**
  64969. * Clears the log cache
  64970. */
  64971. static ClearLogCache(): void;
  64972. /**
  64973. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64974. */
  64975. static LogLevels: number;
  64976. }
  64977. }
  64978. declare module BABYLON {
  64979. /** @hidden */
  64980. export class _TypeStore {
  64981. /** @hidden */
  64982. static RegisteredTypes: {
  64983. [key: string]: Object;
  64984. };
  64985. /** @hidden */
  64986. static GetClass(fqdn: string): any;
  64987. }
  64988. }
  64989. declare module BABYLON {
  64990. /**
  64991. * Class containing a set of static utilities functions for deep copy.
  64992. */
  64993. export class DeepCopier {
  64994. /**
  64995. * Tries to copy an object by duplicating every property
  64996. * @param source defines the source object
  64997. * @param destination defines the target object
  64998. * @param doNotCopyList defines a list of properties to avoid
  64999. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  65000. */
  65001. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  65002. }
  65003. }
  65004. declare module BABYLON {
  65005. /**
  65006. * Class containing a set of static utilities functions for precision date
  65007. */
  65008. export class PrecisionDate {
  65009. /**
  65010. * Gets either window.performance.now() if supported or Date.now() else
  65011. */
  65012. static readonly Now: number;
  65013. }
  65014. }
  65015. declare module BABYLON {
  65016. /** @hidden */
  65017. export class _DevTools {
  65018. static WarnImport(name: string): string;
  65019. }
  65020. }
  65021. declare module BABYLON {
  65022. /**
  65023. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  65024. */
  65025. export class WebRequest {
  65026. private _xhr;
  65027. /**
  65028. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  65029. * i.e. when loading files, where the server/service expects an Authorization header
  65030. */
  65031. static CustomRequestHeaders: {
  65032. [key: string]: string;
  65033. };
  65034. /**
  65035. * Add callback functions in this array to update all the requests before they get sent to the network
  65036. */
  65037. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  65038. private _injectCustomRequestHeaders;
  65039. /**
  65040. * Gets or sets a function to be called when loading progress changes
  65041. */
  65042. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  65043. /**
  65044. * Returns client's state
  65045. */
  65046. readonly readyState: number;
  65047. /**
  65048. * Returns client's status
  65049. */
  65050. readonly status: number;
  65051. /**
  65052. * Returns client's status as a text
  65053. */
  65054. readonly statusText: string;
  65055. /**
  65056. * Returns client's response
  65057. */
  65058. readonly response: any;
  65059. /**
  65060. * Returns client's response url
  65061. */
  65062. readonly responseURL: string;
  65063. /**
  65064. * Returns client's response as text
  65065. */
  65066. readonly responseText: string;
  65067. /**
  65068. * Gets or sets the expected response type
  65069. */
  65070. responseType: XMLHttpRequestResponseType;
  65071. /** @hidden */
  65072. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  65073. /** @hidden */
  65074. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  65075. /**
  65076. * Cancels any network activity
  65077. */
  65078. abort(): void;
  65079. /**
  65080. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  65081. * @param body defines an optional request body
  65082. */
  65083. send(body?: Document | BodyInit | null): void;
  65084. /**
  65085. * Sets the request method, request URL
  65086. * @param method defines the method to use (GET, POST, etc..)
  65087. * @param url defines the url to connect with
  65088. */
  65089. open(method: string, url: string): void;
  65090. }
  65091. }
  65092. declare module BABYLON {
  65093. /**
  65094. * Class used to evalaute queries containing `and` and `or` operators
  65095. */
  65096. export class AndOrNotEvaluator {
  65097. /**
  65098. * Evaluate a query
  65099. * @param query defines the query to evaluate
  65100. * @param evaluateCallback defines the callback used to filter result
  65101. * @returns true if the query matches
  65102. */
  65103. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  65104. private static _HandleParenthesisContent;
  65105. private static _SimplifyNegation;
  65106. }
  65107. }
  65108. declare module BABYLON {
  65109. /**
  65110. * Class used to store custom tags
  65111. */
  65112. export class Tags {
  65113. /**
  65114. * Adds support for tags on the given object
  65115. * @param obj defines the object to use
  65116. */
  65117. static EnableFor(obj: any): void;
  65118. /**
  65119. * Removes tags support
  65120. * @param obj defines the object to use
  65121. */
  65122. static DisableFor(obj: any): void;
  65123. /**
  65124. * Gets a boolean indicating if the given object has tags
  65125. * @param obj defines the object to use
  65126. * @returns a boolean
  65127. */
  65128. static HasTags(obj: any): boolean;
  65129. /**
  65130. * Gets the tags available on a given object
  65131. * @param obj defines the object to use
  65132. * @param asString defines if the tags must be returned as a string instead of an array of strings
  65133. * @returns the tags
  65134. */
  65135. static GetTags(obj: any, asString?: boolean): any;
  65136. /**
  65137. * Adds tags to an object
  65138. * @param obj defines the object to use
  65139. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  65140. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  65141. */
  65142. static AddTagsTo(obj: any, tagsString: string): void;
  65143. /**
  65144. * @hidden
  65145. */
  65146. static _AddTagTo(obj: any, tag: string): void;
  65147. /**
  65148. * Removes specific tags from a specific object
  65149. * @param obj defines the object to use
  65150. * @param tagsString defines the tags to remove
  65151. */
  65152. static RemoveTagsFrom(obj: any, tagsString: string): void;
  65153. /**
  65154. * @hidden
  65155. */
  65156. static _RemoveTagFrom(obj: any, tag: string): void;
  65157. /**
  65158. * Defines if tags hosted on an object match a given query
  65159. * @param obj defines the object to use
  65160. * @param tagsQuery defines the tag query
  65161. * @returns a boolean
  65162. */
  65163. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  65164. }
  65165. }
  65166. declare module BABYLON {
  65167. /**
  65168. * Manages the defines for the Material
  65169. */
  65170. export class MaterialDefines {
  65171. private _keys;
  65172. private _isDirty;
  65173. /** @hidden */
  65174. _renderId: number;
  65175. /** @hidden */
  65176. _areLightsDirty: boolean;
  65177. /** @hidden */
  65178. _areAttributesDirty: boolean;
  65179. /** @hidden */
  65180. _areTexturesDirty: boolean;
  65181. /** @hidden */
  65182. _areFresnelDirty: boolean;
  65183. /** @hidden */
  65184. _areMiscDirty: boolean;
  65185. /** @hidden */
  65186. _areImageProcessingDirty: boolean;
  65187. /** @hidden */
  65188. _normals: boolean;
  65189. /** @hidden */
  65190. _uvs: boolean;
  65191. /** @hidden */
  65192. _needNormals: boolean;
  65193. /** @hidden */
  65194. _needUVs: boolean;
  65195. /**
  65196. * Specifies if the material needs to be re-calculated
  65197. */
  65198. readonly isDirty: boolean;
  65199. /**
  65200. * Marks the material to indicate that it has been re-calculated
  65201. */
  65202. markAsProcessed(): void;
  65203. /**
  65204. * Marks the material to indicate that it needs to be re-calculated
  65205. */
  65206. markAsUnprocessed(): void;
  65207. /**
  65208. * Marks the material to indicate all of its defines need to be re-calculated
  65209. */
  65210. markAllAsDirty(): void;
  65211. /**
  65212. * Marks the material to indicate that image processing needs to be re-calculated
  65213. */
  65214. markAsImageProcessingDirty(): void;
  65215. /**
  65216. * Marks the material to indicate the lights need to be re-calculated
  65217. */
  65218. markAsLightDirty(): void;
  65219. /**
  65220. * Marks the attribute state as changed
  65221. */
  65222. markAsAttributesDirty(): void;
  65223. /**
  65224. * Marks the texture state as changed
  65225. */
  65226. markAsTexturesDirty(): void;
  65227. /**
  65228. * Marks the fresnel state as changed
  65229. */
  65230. markAsFresnelDirty(): void;
  65231. /**
  65232. * Marks the misc state as changed
  65233. */
  65234. markAsMiscDirty(): void;
  65235. /**
  65236. * Rebuilds the material defines
  65237. */
  65238. rebuild(): void;
  65239. /**
  65240. * Specifies if two material defines are equal
  65241. * @param other - A material define instance to compare to
  65242. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  65243. */
  65244. isEqual(other: MaterialDefines): boolean;
  65245. /**
  65246. * Clones this instance's defines to another instance
  65247. * @param other - material defines to clone values to
  65248. */
  65249. cloneTo(other: MaterialDefines): void;
  65250. /**
  65251. * Resets the material define values
  65252. */
  65253. reset(): void;
  65254. /**
  65255. * Converts the material define values to a string
  65256. * @returns - String of material define information
  65257. */
  65258. toString(): string;
  65259. }
  65260. }
  65261. declare module BABYLON {
  65262. /**
  65263. * Class used to store and describe the pipeline context associated with an effect
  65264. */
  65265. export interface IPipelineContext {
  65266. /**
  65267. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  65268. */
  65269. isAsync: boolean;
  65270. /**
  65271. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  65272. */
  65273. isReady: boolean;
  65274. /** @hidden */
  65275. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  65276. }
  65277. }
  65278. declare module BABYLON {
  65279. /**
  65280. * Class used to store gfx data (like WebGLBuffer)
  65281. */
  65282. export class DataBuffer {
  65283. /**
  65284. * Gets or sets the number of objects referencing this buffer
  65285. */
  65286. references: number;
  65287. /** Gets or sets the size of the underlying buffer */
  65288. capacity: number;
  65289. /**
  65290. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65291. */
  65292. is32Bits: boolean;
  65293. /**
  65294. * Gets the underlying buffer
  65295. */
  65296. readonly underlyingResource: any;
  65297. }
  65298. }
  65299. declare module BABYLON {
  65300. /**
  65301. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65302. */
  65303. export class PerformanceMonitor {
  65304. private _enabled;
  65305. private _rollingFrameTime;
  65306. private _lastFrameTimeMs;
  65307. /**
  65308. * constructor
  65309. * @param frameSampleSize The number of samples required to saturate the sliding window
  65310. */
  65311. constructor(frameSampleSize?: number);
  65312. /**
  65313. * Samples current frame
  65314. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65315. */
  65316. sampleFrame(timeMs?: number): void;
  65317. /**
  65318. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65319. */
  65320. readonly averageFrameTime: number;
  65321. /**
  65322. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65323. */
  65324. readonly averageFrameTimeVariance: number;
  65325. /**
  65326. * Returns the frame time of the most recent frame
  65327. */
  65328. readonly instantaneousFrameTime: number;
  65329. /**
  65330. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65331. */
  65332. readonly averageFPS: number;
  65333. /**
  65334. * Returns the average framerate in frames per second using the most recent frame time
  65335. */
  65336. readonly instantaneousFPS: number;
  65337. /**
  65338. * Returns true if enough samples have been taken to completely fill the sliding window
  65339. */
  65340. readonly isSaturated: boolean;
  65341. /**
  65342. * Enables contributions to the sliding window sample set
  65343. */
  65344. enable(): void;
  65345. /**
  65346. * Disables contributions to the sliding window sample set
  65347. * Samples will not be interpolated over the disabled period
  65348. */
  65349. disable(): void;
  65350. /**
  65351. * Returns true if sampling is enabled
  65352. */
  65353. readonly isEnabled: boolean;
  65354. /**
  65355. * Resets performance monitor
  65356. */
  65357. reset(): void;
  65358. }
  65359. /**
  65360. * RollingAverage
  65361. *
  65362. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65363. */
  65364. export class RollingAverage {
  65365. /**
  65366. * Current average
  65367. */
  65368. average: number;
  65369. /**
  65370. * Current variance
  65371. */
  65372. variance: number;
  65373. protected _samples: Array<number>;
  65374. protected _sampleCount: number;
  65375. protected _pos: number;
  65376. protected _m2: number;
  65377. /**
  65378. * constructor
  65379. * @param length The number of samples required to saturate the sliding window
  65380. */
  65381. constructor(length: number);
  65382. /**
  65383. * Adds a sample to the sample set
  65384. * @param v The sample value
  65385. */
  65386. add(v: number): void;
  65387. /**
  65388. * Returns previously added values or null if outside of history or outside the sliding window domain
  65389. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65390. * @return Value previously recorded with add() or null if outside of range
  65391. */
  65392. history(i: number): number;
  65393. /**
  65394. * Returns true if enough samples have been taken to completely fill the sliding window
  65395. * @return true if sample-set saturated
  65396. */
  65397. isSaturated(): boolean;
  65398. /**
  65399. * Resets the rolling average (equivalent to 0 samples taken so far)
  65400. */
  65401. reset(): void;
  65402. /**
  65403. * Wraps a value around the sample range boundaries
  65404. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65405. * @return Wrapped position in sample range
  65406. */
  65407. protected _wrapPosition(i: number): number;
  65408. }
  65409. }
  65410. declare module BABYLON {
  65411. /**
  65412. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65413. * The underlying implementation relies on an associative array to ensure the best performances.
  65414. * The value can be anything including 'null' but except 'undefined'
  65415. */
  65416. export class StringDictionary<T> {
  65417. /**
  65418. * This will clear this dictionary and copy the content from the 'source' one.
  65419. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65420. * @param source the dictionary to take the content from and copy to this dictionary
  65421. */
  65422. copyFrom(source: StringDictionary<T>): void;
  65423. /**
  65424. * Get a value based from its key
  65425. * @param key the given key to get the matching value from
  65426. * @return the value if found, otherwise undefined is returned
  65427. */
  65428. get(key: string): T | undefined;
  65429. /**
  65430. * Get a value from its key or add it if it doesn't exist.
  65431. * This method will ensure you that a given key/data will be present in the dictionary.
  65432. * @param key the given key to get the matching value from
  65433. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65434. * The factory will only be invoked if there's no data for the given key.
  65435. * @return the value corresponding to the key.
  65436. */
  65437. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65438. /**
  65439. * Get a value from its key if present in the dictionary otherwise add it
  65440. * @param key the key to get the value from
  65441. * @param val if there's no such key/value pair in the dictionary add it with this value
  65442. * @return the value corresponding to the key
  65443. */
  65444. getOrAdd(key: string, val: T): T;
  65445. /**
  65446. * Check if there's a given key in the dictionary
  65447. * @param key the key to check for
  65448. * @return true if the key is present, false otherwise
  65449. */
  65450. contains(key: string): boolean;
  65451. /**
  65452. * Add a new key and its corresponding value
  65453. * @param key the key to add
  65454. * @param value the value corresponding to the key
  65455. * @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
  65456. */
  65457. add(key: string, value: T): boolean;
  65458. /**
  65459. * Update a specific value associated to a key
  65460. * @param key defines the key to use
  65461. * @param value defines the value to store
  65462. * @returns true if the value was updated (or false if the key was not found)
  65463. */
  65464. set(key: string, value: T): boolean;
  65465. /**
  65466. * Get the element of the given key and remove it from the dictionary
  65467. * @param key defines the key to search
  65468. * @returns the value associated with the key or null if not found
  65469. */
  65470. getAndRemove(key: string): Nullable<T>;
  65471. /**
  65472. * Remove a key/value from the dictionary.
  65473. * @param key the key to remove
  65474. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65475. */
  65476. remove(key: string): boolean;
  65477. /**
  65478. * Clear the whole content of the dictionary
  65479. */
  65480. clear(): void;
  65481. /**
  65482. * Gets the current count
  65483. */
  65484. readonly count: number;
  65485. /**
  65486. * Execute a callback on each key/val of the dictionary.
  65487. * Note that you can remove any element in this dictionary in the callback implementation
  65488. * @param callback the callback to execute on a given key/value pair
  65489. */
  65490. forEach(callback: (key: string, val: T) => void): void;
  65491. /**
  65492. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65493. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65494. * Note that you can remove any element in this dictionary in the callback implementation
  65495. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65496. * @returns the first item
  65497. */
  65498. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65499. private _count;
  65500. private _data;
  65501. }
  65502. }
  65503. declare module BABYLON {
  65504. /**
  65505. * Helper class that provides a small promise polyfill
  65506. */
  65507. export class PromisePolyfill {
  65508. /**
  65509. * Static function used to check if the polyfill is required
  65510. * If this is the case then the function will inject the polyfill to window.Promise
  65511. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  65512. */
  65513. static Apply(force?: boolean): void;
  65514. }
  65515. }
  65516. declare module BABYLON {
  65517. /**
  65518. * Class used to store data that will be store in GPU memory
  65519. */
  65520. export class Buffer {
  65521. private _engine;
  65522. private _buffer;
  65523. /** @hidden */
  65524. _data: Nullable<DataArray>;
  65525. private _updatable;
  65526. private _instanced;
  65527. /**
  65528. * Gets the byte stride.
  65529. */
  65530. readonly byteStride: number;
  65531. /**
  65532. * Constructor
  65533. * @param engine the engine
  65534. * @param data the data to use for this buffer
  65535. * @param updatable whether the data is updatable
  65536. * @param stride the stride (optional)
  65537. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65538. * @param instanced whether the buffer is instanced (optional)
  65539. * @param useBytes set to true if the stride in in bytes (optional)
  65540. */
  65541. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65542. /**
  65543. * Create a new VertexBuffer based on the current buffer
  65544. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65545. * @param offset defines offset in the buffer (0 by default)
  65546. * @param size defines the size in floats of attributes (position is 3 for instance)
  65547. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65548. * @param instanced defines if the vertex buffer contains indexed data
  65549. * @param useBytes defines if the offset and stride are in bytes
  65550. * @returns the new vertex buffer
  65551. */
  65552. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65553. /**
  65554. * Gets a boolean indicating if the Buffer is updatable?
  65555. * @returns true if the buffer is updatable
  65556. */
  65557. isUpdatable(): boolean;
  65558. /**
  65559. * Gets current buffer's data
  65560. * @returns a DataArray or null
  65561. */
  65562. getData(): Nullable<DataArray>;
  65563. /**
  65564. * Gets underlying native buffer
  65565. * @returns underlying native buffer
  65566. */
  65567. getBuffer(): Nullable<DataBuffer>;
  65568. /**
  65569. * Gets the stride in float32 units (i.e. byte stride / 4).
  65570. * May not be an integer if the byte stride is not divisible by 4.
  65571. * DEPRECATED. Use byteStride instead.
  65572. * @returns the stride in float32 units
  65573. */
  65574. getStrideSize(): number;
  65575. /**
  65576. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65577. * @param data defines the data to store
  65578. */
  65579. create(data?: Nullable<DataArray>): void;
  65580. /** @hidden */
  65581. _rebuild(): void;
  65582. /**
  65583. * Update current buffer data
  65584. * @param data defines the data to store
  65585. */
  65586. update(data: DataArray): void;
  65587. /**
  65588. * Updates the data directly.
  65589. * @param data the new data
  65590. * @param offset the new offset
  65591. * @param vertexCount the vertex count (optional)
  65592. * @param useBytes set to true if the offset is in bytes
  65593. */
  65594. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65595. /**
  65596. * Release all resources
  65597. */
  65598. dispose(): void;
  65599. }
  65600. /**
  65601. * Specialized buffer used to store vertex data
  65602. */
  65603. export class VertexBuffer {
  65604. /** @hidden */
  65605. _buffer: Buffer;
  65606. private _kind;
  65607. private _size;
  65608. private _ownsBuffer;
  65609. private _instanced;
  65610. private _instanceDivisor;
  65611. /**
  65612. * The byte type.
  65613. */
  65614. static readonly BYTE: number;
  65615. /**
  65616. * The unsigned byte type.
  65617. */
  65618. static readonly UNSIGNED_BYTE: number;
  65619. /**
  65620. * The short type.
  65621. */
  65622. static readonly SHORT: number;
  65623. /**
  65624. * The unsigned short type.
  65625. */
  65626. static readonly UNSIGNED_SHORT: number;
  65627. /**
  65628. * The integer type.
  65629. */
  65630. static readonly INT: number;
  65631. /**
  65632. * The unsigned integer type.
  65633. */
  65634. static readonly UNSIGNED_INT: number;
  65635. /**
  65636. * The float type.
  65637. */
  65638. static readonly FLOAT: number;
  65639. /**
  65640. * Gets or sets the instance divisor when in instanced mode
  65641. */
  65642. instanceDivisor: number;
  65643. /**
  65644. * Gets the byte stride.
  65645. */
  65646. readonly byteStride: number;
  65647. /**
  65648. * Gets the byte offset.
  65649. */
  65650. readonly byteOffset: number;
  65651. /**
  65652. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65653. */
  65654. readonly normalized: boolean;
  65655. /**
  65656. * Gets the data type of each component in the array.
  65657. */
  65658. readonly type: number;
  65659. /**
  65660. * Constructor
  65661. * @param engine the engine
  65662. * @param data the data to use for this vertex buffer
  65663. * @param kind the vertex buffer kind
  65664. * @param updatable whether the data is updatable
  65665. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65666. * @param stride the stride (optional)
  65667. * @param instanced whether the buffer is instanced (optional)
  65668. * @param offset the offset of the data (optional)
  65669. * @param size the number of components (optional)
  65670. * @param type the type of the component (optional)
  65671. * @param normalized whether the data contains normalized data (optional)
  65672. * @param useBytes set to true if stride and offset are in bytes (optional)
  65673. */
  65674. 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);
  65675. /** @hidden */
  65676. _rebuild(): void;
  65677. /**
  65678. * Returns the kind of the VertexBuffer (string)
  65679. * @returns a string
  65680. */
  65681. getKind(): string;
  65682. /**
  65683. * Gets a boolean indicating if the VertexBuffer is updatable?
  65684. * @returns true if the buffer is updatable
  65685. */
  65686. isUpdatable(): boolean;
  65687. /**
  65688. * Gets current buffer's data
  65689. * @returns a DataArray or null
  65690. */
  65691. getData(): Nullable<DataArray>;
  65692. /**
  65693. * Gets underlying native buffer
  65694. * @returns underlying native buffer
  65695. */
  65696. getBuffer(): Nullable<DataBuffer>;
  65697. /**
  65698. * Gets the stride in float32 units (i.e. byte stride / 4).
  65699. * May not be an integer if the byte stride is not divisible by 4.
  65700. * DEPRECATED. Use byteStride instead.
  65701. * @returns the stride in float32 units
  65702. */
  65703. getStrideSize(): number;
  65704. /**
  65705. * Returns the offset as a multiple of the type byte length.
  65706. * DEPRECATED. Use byteOffset instead.
  65707. * @returns the offset in bytes
  65708. */
  65709. getOffset(): number;
  65710. /**
  65711. * Returns the number of components per vertex attribute (integer)
  65712. * @returns the size in float
  65713. */
  65714. getSize(): number;
  65715. /**
  65716. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65717. * @returns true if this buffer is instanced
  65718. */
  65719. getIsInstanced(): boolean;
  65720. /**
  65721. * Returns the instancing divisor, zero for non-instanced (integer).
  65722. * @returns a number
  65723. */
  65724. getInstanceDivisor(): number;
  65725. /**
  65726. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65727. * @param data defines the data to store
  65728. */
  65729. create(data?: DataArray): void;
  65730. /**
  65731. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65732. * This function will create a new buffer if the current one is not updatable
  65733. * @param data defines the data to store
  65734. */
  65735. update(data: DataArray): void;
  65736. /**
  65737. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65738. * Returns the directly updated WebGLBuffer.
  65739. * @param data the new data
  65740. * @param offset the new offset
  65741. * @param useBytes set to true if the offset is in bytes
  65742. */
  65743. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65744. /**
  65745. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65746. */
  65747. dispose(): void;
  65748. /**
  65749. * Enumerates each value of this vertex buffer as numbers.
  65750. * @param count the number of values to enumerate
  65751. * @param callback the callback function called for each value
  65752. */
  65753. forEach(count: number, callback: (value: number, index: number) => void): void;
  65754. /**
  65755. * Positions
  65756. */
  65757. static readonly PositionKind: string;
  65758. /**
  65759. * Normals
  65760. */
  65761. static readonly NormalKind: string;
  65762. /**
  65763. * Tangents
  65764. */
  65765. static readonly TangentKind: string;
  65766. /**
  65767. * Texture coordinates
  65768. */
  65769. static readonly UVKind: string;
  65770. /**
  65771. * Texture coordinates 2
  65772. */
  65773. static readonly UV2Kind: string;
  65774. /**
  65775. * Texture coordinates 3
  65776. */
  65777. static readonly UV3Kind: string;
  65778. /**
  65779. * Texture coordinates 4
  65780. */
  65781. static readonly UV4Kind: string;
  65782. /**
  65783. * Texture coordinates 5
  65784. */
  65785. static readonly UV5Kind: string;
  65786. /**
  65787. * Texture coordinates 6
  65788. */
  65789. static readonly UV6Kind: string;
  65790. /**
  65791. * Colors
  65792. */
  65793. static readonly ColorKind: string;
  65794. /**
  65795. * Matrix indices (for bones)
  65796. */
  65797. static readonly MatricesIndicesKind: string;
  65798. /**
  65799. * Matrix weights (for bones)
  65800. */
  65801. static readonly MatricesWeightsKind: string;
  65802. /**
  65803. * Additional matrix indices (for bones)
  65804. */
  65805. static readonly MatricesIndicesExtraKind: string;
  65806. /**
  65807. * Additional matrix weights (for bones)
  65808. */
  65809. static readonly MatricesWeightsExtraKind: string;
  65810. /**
  65811. * Deduces the stride given a kind.
  65812. * @param kind The kind string to deduce
  65813. * @returns The deduced stride
  65814. */
  65815. static DeduceStride(kind: string): number;
  65816. /**
  65817. * Gets the byte length of the given type.
  65818. * @param type the type
  65819. * @returns the number of bytes
  65820. */
  65821. static GetTypeByteLength(type: number): number;
  65822. /**
  65823. * Enumerates each value of the given parameters as numbers.
  65824. * @param data the data to enumerate
  65825. * @param byteOffset the byte offset of the data
  65826. * @param byteStride the byte stride of the data
  65827. * @param componentCount the number of components per element
  65828. * @param componentType the type of the component
  65829. * @param count the total number of components
  65830. * @param normalized whether the data is normalized
  65831. * @param callback the callback function called for each value
  65832. */
  65833. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65834. private static _GetFloatValue;
  65835. }
  65836. }
  65837. declare module BABYLON {
  65838. /**
  65839. * Class representing spherical harmonics coefficients to the 3rd degree
  65840. */
  65841. export class SphericalHarmonics {
  65842. /**
  65843. * Defines whether or not the harmonics have been prescaled for rendering.
  65844. */
  65845. preScaled: boolean;
  65846. /**
  65847. * The l0,0 coefficients of the spherical harmonics
  65848. */
  65849. l00: Vector3;
  65850. /**
  65851. * The l1,-1 coefficients of the spherical harmonics
  65852. */
  65853. l1_1: Vector3;
  65854. /**
  65855. * The l1,0 coefficients of the spherical harmonics
  65856. */
  65857. l10: Vector3;
  65858. /**
  65859. * The l1,1 coefficients of the spherical harmonics
  65860. */
  65861. l11: Vector3;
  65862. /**
  65863. * The l2,-2 coefficients of the spherical harmonics
  65864. */
  65865. l2_2: Vector3;
  65866. /**
  65867. * The l2,-1 coefficients of the spherical harmonics
  65868. */
  65869. l2_1: Vector3;
  65870. /**
  65871. * The l2,0 coefficients of the spherical harmonics
  65872. */
  65873. l20: Vector3;
  65874. /**
  65875. * The l2,1 coefficients of the spherical harmonics
  65876. */
  65877. l21: Vector3;
  65878. /**
  65879. * The l2,2 coefficients of the spherical harmonics
  65880. */
  65881. l22: Vector3;
  65882. /**
  65883. * Adds a light to the spherical harmonics
  65884. * @param direction the direction of the light
  65885. * @param color the color of the light
  65886. * @param deltaSolidAngle the delta solid angle of the light
  65887. */
  65888. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65889. /**
  65890. * Scales the spherical harmonics by the given amount
  65891. * @param scale the amount to scale
  65892. */
  65893. scaleInPlace(scale: number): void;
  65894. /**
  65895. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65896. *
  65897. * ```
  65898. * E_lm = A_l * L_lm
  65899. * ```
  65900. *
  65901. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65902. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65903. * the scaling factors are given in equation 9.
  65904. */
  65905. convertIncidentRadianceToIrradiance(): void;
  65906. /**
  65907. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65908. *
  65909. * ```
  65910. * L = (1/pi) * E * rho
  65911. * ```
  65912. *
  65913. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65914. */
  65915. convertIrradianceToLambertianRadiance(): void;
  65916. /**
  65917. * Integrates the reconstruction coefficients directly in to the SH preventing further
  65918. * required operations at run time.
  65919. *
  65920. * This is simply done by scaling back the SH with Ylm constants parameter.
  65921. * The trigonometric part being applied by the shader at run time.
  65922. */
  65923. preScaleForRendering(): void;
  65924. /**
  65925. * Constructs a spherical harmonics from an array.
  65926. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65927. * @returns the spherical harmonics
  65928. */
  65929. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65930. /**
  65931. * Gets the spherical harmonics from polynomial
  65932. * @param polynomial the spherical polynomial
  65933. * @returns the spherical harmonics
  65934. */
  65935. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65936. }
  65937. /**
  65938. * Class representing spherical polynomial coefficients to the 3rd degree
  65939. */
  65940. export class SphericalPolynomial {
  65941. private _harmonics;
  65942. /**
  65943. * The spherical harmonics used to create the polynomials.
  65944. */
  65945. readonly preScaledHarmonics: SphericalHarmonics;
  65946. /**
  65947. * The x coefficients of the spherical polynomial
  65948. */
  65949. x: Vector3;
  65950. /**
  65951. * The y coefficients of the spherical polynomial
  65952. */
  65953. y: Vector3;
  65954. /**
  65955. * The z coefficients of the spherical polynomial
  65956. */
  65957. z: Vector3;
  65958. /**
  65959. * The xx coefficients of the spherical polynomial
  65960. */
  65961. xx: Vector3;
  65962. /**
  65963. * The yy coefficients of the spherical polynomial
  65964. */
  65965. yy: Vector3;
  65966. /**
  65967. * The zz coefficients of the spherical polynomial
  65968. */
  65969. zz: Vector3;
  65970. /**
  65971. * The xy coefficients of the spherical polynomial
  65972. */
  65973. xy: Vector3;
  65974. /**
  65975. * The yz coefficients of the spherical polynomial
  65976. */
  65977. yz: Vector3;
  65978. /**
  65979. * The zx coefficients of the spherical polynomial
  65980. */
  65981. zx: Vector3;
  65982. /**
  65983. * Adds an ambient color to the spherical polynomial
  65984. * @param color the color to add
  65985. */
  65986. addAmbient(color: Color3): void;
  65987. /**
  65988. * Scales the spherical polynomial by the given amount
  65989. * @param scale the amount to scale
  65990. */
  65991. scaleInPlace(scale: number): void;
  65992. /**
  65993. * Gets the spherical polynomial from harmonics
  65994. * @param harmonics the spherical harmonics
  65995. * @returns the spherical polynomial
  65996. */
  65997. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65998. /**
  65999. * Constructs a spherical polynomial from an array.
  66000. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  66001. * @returns the spherical polynomial
  66002. */
  66003. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  66004. }
  66005. }
  66006. declare module BABYLON {
  66007. /**
  66008. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  66009. */
  66010. export interface CubeMapInfo {
  66011. /**
  66012. * The pixel array for the front face.
  66013. * This is stored in format, left to right, up to down format.
  66014. */
  66015. front: Nullable<ArrayBufferView>;
  66016. /**
  66017. * The pixel array for the back face.
  66018. * This is stored in format, left to right, up to down format.
  66019. */
  66020. back: Nullable<ArrayBufferView>;
  66021. /**
  66022. * The pixel array for the left face.
  66023. * This is stored in format, left to right, up to down format.
  66024. */
  66025. left: Nullable<ArrayBufferView>;
  66026. /**
  66027. * The pixel array for the right face.
  66028. * This is stored in format, left to right, up to down format.
  66029. */
  66030. right: Nullable<ArrayBufferView>;
  66031. /**
  66032. * The pixel array for the up face.
  66033. * This is stored in format, left to right, up to down format.
  66034. */
  66035. up: Nullable<ArrayBufferView>;
  66036. /**
  66037. * The pixel array for the down face.
  66038. * This is stored in format, left to right, up to down format.
  66039. */
  66040. down: Nullable<ArrayBufferView>;
  66041. /**
  66042. * The size of the cubemap stored.
  66043. *
  66044. * Each faces will be size * size pixels.
  66045. */
  66046. size: number;
  66047. /**
  66048. * The format of the texture.
  66049. *
  66050. * RGBA, RGB.
  66051. */
  66052. format: number;
  66053. /**
  66054. * The type of the texture data.
  66055. *
  66056. * UNSIGNED_INT, FLOAT.
  66057. */
  66058. type: number;
  66059. /**
  66060. * Specifies whether the texture is in gamma space.
  66061. */
  66062. gammaSpace: boolean;
  66063. }
  66064. /**
  66065. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  66066. */
  66067. export class PanoramaToCubeMapTools {
  66068. private static FACE_FRONT;
  66069. private static FACE_BACK;
  66070. private static FACE_RIGHT;
  66071. private static FACE_LEFT;
  66072. private static FACE_DOWN;
  66073. private static FACE_UP;
  66074. /**
  66075. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  66076. *
  66077. * @param float32Array The source data.
  66078. * @param inputWidth The width of the input panorama.
  66079. * @param inputHeight The height of the input panorama.
  66080. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  66081. * @return The cubemap data
  66082. */
  66083. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  66084. private static CreateCubemapTexture;
  66085. private static CalcProjectionSpherical;
  66086. }
  66087. }
  66088. declare module BABYLON {
  66089. /**
  66090. * Helper class dealing with the extraction of spherical polynomial dataArray
  66091. * from a cube map.
  66092. */
  66093. export class CubeMapToSphericalPolynomialTools {
  66094. private static FileFaces;
  66095. /**
  66096. * Converts a texture to the according Spherical Polynomial data.
  66097. * This extracts the first 3 orders only as they are the only one used in the lighting.
  66098. *
  66099. * @param texture The texture to extract the information from.
  66100. * @return The Spherical Polynomial data.
  66101. */
  66102. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  66103. /**
  66104. * Converts a cubemap to the according Spherical Polynomial data.
  66105. * This extracts the first 3 orders only as they are the only one used in the lighting.
  66106. *
  66107. * @param cubeInfo The Cube map to extract the information from.
  66108. * @return The Spherical Polynomial data.
  66109. */
  66110. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  66111. }
  66112. }
  66113. declare module BABYLON {
  66114. /**
  66115. * The engine store class is responsible to hold all the instances of Engine and Scene created
  66116. * during the life time of the application.
  66117. */
  66118. export class EngineStore {
  66119. /** Gets the list of created engines */
  66120. static Instances: Engine[];
  66121. /** @hidden */
  66122. static _LastCreatedScene: Nullable<Scene>;
  66123. /**
  66124. * Gets the latest created engine
  66125. */
  66126. static readonly LastCreatedEngine: Nullable<Engine>;
  66127. /**
  66128. * Gets the latest created scene
  66129. */
  66130. static readonly LastCreatedScene: Nullable<Scene>;
  66131. }
  66132. }
  66133. declare module BABYLON {
  66134. /**
  66135. * Define options used to create a render target texture
  66136. */
  66137. export class RenderTargetCreationOptions {
  66138. /**
  66139. * Specifies is mipmaps must be generated
  66140. */
  66141. generateMipMaps?: boolean;
  66142. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  66143. generateDepthBuffer?: boolean;
  66144. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  66145. generateStencilBuffer?: boolean;
  66146. /** Defines texture type (int by default) */
  66147. type?: number;
  66148. /** Defines sampling mode (trilinear by default) */
  66149. samplingMode?: number;
  66150. /** Defines format (RGBA by default) */
  66151. format?: number;
  66152. }
  66153. }
  66154. declare module BABYLON {
  66155. /**
  66156. * @hidden
  66157. **/
  66158. export class _AlphaState {
  66159. private _isAlphaBlendDirty;
  66160. private _isBlendFunctionParametersDirty;
  66161. private _isBlendEquationParametersDirty;
  66162. private _isBlendConstantsDirty;
  66163. private _alphaBlend;
  66164. private _blendFunctionParameters;
  66165. private _blendEquationParameters;
  66166. private _blendConstants;
  66167. /**
  66168. * Initializes the state.
  66169. */
  66170. constructor();
  66171. readonly isDirty: boolean;
  66172. alphaBlend: boolean;
  66173. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  66174. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  66175. setAlphaEquationParameters(rgb: number, alpha: number): void;
  66176. reset(): void;
  66177. apply(gl: WebGLRenderingContext): void;
  66178. }
  66179. }
  66180. declare module BABYLON {
  66181. /**
  66182. * @hidden
  66183. **/
  66184. export class _DepthCullingState {
  66185. private _isDepthTestDirty;
  66186. private _isDepthMaskDirty;
  66187. private _isDepthFuncDirty;
  66188. private _isCullFaceDirty;
  66189. private _isCullDirty;
  66190. private _isZOffsetDirty;
  66191. private _isFrontFaceDirty;
  66192. private _depthTest;
  66193. private _depthMask;
  66194. private _depthFunc;
  66195. private _cull;
  66196. private _cullFace;
  66197. private _zOffset;
  66198. private _frontFace;
  66199. /**
  66200. * Initializes the state.
  66201. */
  66202. constructor();
  66203. readonly isDirty: boolean;
  66204. zOffset: number;
  66205. cullFace: Nullable<number>;
  66206. cull: Nullable<boolean>;
  66207. depthFunc: Nullable<number>;
  66208. depthMask: boolean;
  66209. depthTest: boolean;
  66210. frontFace: Nullable<number>;
  66211. reset(): void;
  66212. apply(gl: WebGLRenderingContext): void;
  66213. }
  66214. }
  66215. declare module BABYLON {
  66216. /**
  66217. * @hidden
  66218. **/
  66219. export class _StencilState {
  66220. /** 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 */
  66221. static readonly ALWAYS: number;
  66222. /** Passed to stencilOperation to specify that stencil value must be kept */
  66223. static readonly KEEP: number;
  66224. /** Passed to stencilOperation to specify that stencil value must be replaced */
  66225. static readonly REPLACE: number;
  66226. private _isStencilTestDirty;
  66227. private _isStencilMaskDirty;
  66228. private _isStencilFuncDirty;
  66229. private _isStencilOpDirty;
  66230. private _stencilTest;
  66231. private _stencilMask;
  66232. private _stencilFunc;
  66233. private _stencilFuncRef;
  66234. private _stencilFuncMask;
  66235. private _stencilOpStencilFail;
  66236. private _stencilOpDepthFail;
  66237. private _stencilOpStencilDepthPass;
  66238. readonly isDirty: boolean;
  66239. stencilFunc: number;
  66240. stencilFuncRef: number;
  66241. stencilFuncMask: number;
  66242. stencilOpStencilFail: number;
  66243. stencilOpDepthFail: number;
  66244. stencilOpStencilDepthPass: number;
  66245. stencilMask: number;
  66246. stencilTest: boolean;
  66247. constructor();
  66248. reset(): void;
  66249. apply(gl: WebGLRenderingContext): void;
  66250. }
  66251. }
  66252. declare module BABYLON {
  66253. /**
  66254. * @hidden
  66255. **/
  66256. export class _TimeToken {
  66257. _startTimeQuery: Nullable<WebGLQuery>;
  66258. _endTimeQuery: Nullable<WebGLQuery>;
  66259. _timeElapsedQuery: Nullable<WebGLQuery>;
  66260. _timeElapsedQueryEnded: boolean;
  66261. }
  66262. }
  66263. declare module BABYLON {
  66264. /**
  66265. * Class used to store data associated with WebGL texture data for the engine
  66266. * This class should not be used directly
  66267. */
  66268. export class InternalTexture {
  66269. /** hidden */
  66270. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  66271. /**
  66272. * The source of the texture data is unknown
  66273. */
  66274. static DATASOURCE_UNKNOWN: number;
  66275. /**
  66276. * Texture data comes from an URL
  66277. */
  66278. static DATASOURCE_URL: number;
  66279. /**
  66280. * Texture data is only used for temporary storage
  66281. */
  66282. static DATASOURCE_TEMP: number;
  66283. /**
  66284. * Texture data comes from raw data (ArrayBuffer)
  66285. */
  66286. static DATASOURCE_RAW: number;
  66287. /**
  66288. * Texture content is dynamic (video or dynamic texture)
  66289. */
  66290. static DATASOURCE_DYNAMIC: number;
  66291. /**
  66292. * Texture content is generated by rendering to it
  66293. */
  66294. static DATASOURCE_RENDERTARGET: number;
  66295. /**
  66296. * Texture content is part of a multi render target process
  66297. */
  66298. static DATASOURCE_MULTIRENDERTARGET: number;
  66299. /**
  66300. * Texture data comes from a cube data file
  66301. */
  66302. static DATASOURCE_CUBE: number;
  66303. /**
  66304. * Texture data comes from a raw cube data
  66305. */
  66306. static DATASOURCE_CUBERAW: number;
  66307. /**
  66308. * Texture data come from a prefiltered cube data file
  66309. */
  66310. static DATASOURCE_CUBEPREFILTERED: number;
  66311. /**
  66312. * Texture content is raw 3D data
  66313. */
  66314. static DATASOURCE_RAW3D: number;
  66315. /**
  66316. * Texture content is a depth texture
  66317. */
  66318. static DATASOURCE_DEPTHTEXTURE: number;
  66319. /**
  66320. * Texture data comes from a raw cube data encoded with RGBD
  66321. */
  66322. static DATASOURCE_CUBERAW_RGBD: number;
  66323. /**
  66324. * Defines if the texture is ready
  66325. */
  66326. isReady: boolean;
  66327. /**
  66328. * Defines if the texture is a cube texture
  66329. */
  66330. isCube: boolean;
  66331. /**
  66332. * Defines if the texture contains 3D data
  66333. */
  66334. is3D: boolean;
  66335. /**
  66336. * Defines if the texture contains multiview data
  66337. */
  66338. isMultiview: boolean;
  66339. /**
  66340. * Gets the URL used to load this texture
  66341. */
  66342. url: string;
  66343. /**
  66344. * Gets the sampling mode of the texture
  66345. */
  66346. samplingMode: number;
  66347. /**
  66348. * Gets a boolean indicating if the texture needs mipmaps generation
  66349. */
  66350. generateMipMaps: boolean;
  66351. /**
  66352. * Gets the number of samples used by the texture (WebGL2+ only)
  66353. */
  66354. samples: number;
  66355. /**
  66356. * Gets the type of the texture (int, float...)
  66357. */
  66358. type: number;
  66359. /**
  66360. * Gets the format of the texture (RGB, RGBA...)
  66361. */
  66362. format: number;
  66363. /**
  66364. * Observable called when the texture is loaded
  66365. */
  66366. onLoadedObservable: Observable<InternalTexture>;
  66367. /**
  66368. * Gets the width of the texture
  66369. */
  66370. width: number;
  66371. /**
  66372. * Gets the height of the texture
  66373. */
  66374. height: number;
  66375. /**
  66376. * Gets the depth of the texture
  66377. */
  66378. depth: number;
  66379. /**
  66380. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  66381. */
  66382. baseWidth: number;
  66383. /**
  66384. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  66385. */
  66386. baseHeight: number;
  66387. /**
  66388. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  66389. */
  66390. baseDepth: number;
  66391. /**
  66392. * Gets a boolean indicating if the texture is inverted on Y axis
  66393. */
  66394. invertY: boolean;
  66395. /** @hidden */
  66396. _invertVScale: boolean;
  66397. /** @hidden */
  66398. _associatedChannel: number;
  66399. /** @hidden */
  66400. _dataSource: number;
  66401. /** @hidden */
  66402. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  66403. /** @hidden */
  66404. _bufferView: Nullable<ArrayBufferView>;
  66405. /** @hidden */
  66406. _bufferViewArray: Nullable<ArrayBufferView[]>;
  66407. /** @hidden */
  66408. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  66409. /** @hidden */
  66410. _size: number;
  66411. /** @hidden */
  66412. _extension: string;
  66413. /** @hidden */
  66414. _files: Nullable<string[]>;
  66415. /** @hidden */
  66416. _workingCanvas: Nullable<HTMLCanvasElement>;
  66417. /** @hidden */
  66418. _workingContext: Nullable<CanvasRenderingContext2D>;
  66419. /** @hidden */
  66420. _framebuffer: Nullable<WebGLFramebuffer>;
  66421. /** @hidden */
  66422. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  66423. /** @hidden */
  66424. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  66425. /** @hidden */
  66426. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  66427. /** @hidden */
  66428. _attachments: Nullable<number[]>;
  66429. /** @hidden */
  66430. _cachedCoordinatesMode: Nullable<number>;
  66431. /** @hidden */
  66432. _cachedWrapU: Nullable<number>;
  66433. /** @hidden */
  66434. _cachedWrapV: Nullable<number>;
  66435. /** @hidden */
  66436. _cachedWrapR: Nullable<number>;
  66437. /** @hidden */
  66438. _cachedAnisotropicFilteringLevel: Nullable<number>;
  66439. /** @hidden */
  66440. _isDisabled: boolean;
  66441. /** @hidden */
  66442. _compression: Nullable<string>;
  66443. /** @hidden */
  66444. _generateStencilBuffer: boolean;
  66445. /** @hidden */
  66446. _generateDepthBuffer: boolean;
  66447. /** @hidden */
  66448. _comparisonFunction: number;
  66449. /** @hidden */
  66450. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  66451. /** @hidden */
  66452. _lodGenerationScale: number;
  66453. /** @hidden */
  66454. _lodGenerationOffset: number;
  66455. /** @hidden */
  66456. _colorTextureArray: Nullable<WebGLTexture>;
  66457. /** @hidden */
  66458. _depthStencilTextureArray: Nullable<WebGLTexture>;
  66459. /** @hidden */
  66460. _lodTextureHigh: Nullable<BaseTexture>;
  66461. /** @hidden */
  66462. _lodTextureMid: Nullable<BaseTexture>;
  66463. /** @hidden */
  66464. _lodTextureLow: Nullable<BaseTexture>;
  66465. /** @hidden */
  66466. _isRGBD: boolean;
  66467. /** @hidden */
  66468. _webGLTexture: Nullable<WebGLTexture>;
  66469. /** @hidden */
  66470. _references: number;
  66471. private _engine;
  66472. /**
  66473. * Gets the Engine the texture belongs to.
  66474. * @returns The babylon engine
  66475. */
  66476. getEngine(): Engine;
  66477. /**
  66478. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  66479. */
  66480. readonly dataSource: number;
  66481. /**
  66482. * Creates a new InternalTexture
  66483. * @param engine defines the engine to use
  66484. * @param dataSource defines the type of data that will be used
  66485. * @param delayAllocation if the texture allocation should be delayed (default: false)
  66486. */
  66487. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  66488. /**
  66489. * Increments the number of references (ie. the number of Texture that point to it)
  66490. */
  66491. incrementReferences(): void;
  66492. /**
  66493. * Change the size of the texture (not the size of the content)
  66494. * @param width defines the new width
  66495. * @param height defines the new height
  66496. * @param depth defines the new depth (1 by default)
  66497. */
  66498. updateSize(width: int, height: int, depth?: int): void;
  66499. /** @hidden */
  66500. _rebuild(): void;
  66501. /** @hidden */
  66502. _swapAndDie(target: InternalTexture): void;
  66503. /**
  66504. * Dispose the current allocated resources
  66505. */
  66506. dispose(): void;
  66507. }
  66508. }
  66509. declare module BABYLON {
  66510. /**
  66511. * This represents the main contract an easing function should follow.
  66512. * Easing functions are used throughout the animation system.
  66513. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66514. */
  66515. export interface IEasingFunction {
  66516. /**
  66517. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66518. * of the easing function.
  66519. * The link below provides some of the most common examples of easing functions.
  66520. * @see https://easings.net/
  66521. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66522. * @returns the corresponding value on the curve defined by the easing function
  66523. */
  66524. ease(gradient: number): number;
  66525. }
  66526. /**
  66527. * Base class used for every default easing function.
  66528. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66529. */
  66530. export class EasingFunction implements IEasingFunction {
  66531. /**
  66532. * Interpolation follows the mathematical formula associated with the easing function.
  66533. */
  66534. static readonly EASINGMODE_EASEIN: number;
  66535. /**
  66536. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  66537. */
  66538. static readonly EASINGMODE_EASEOUT: number;
  66539. /**
  66540. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  66541. */
  66542. static readonly EASINGMODE_EASEINOUT: number;
  66543. private _easingMode;
  66544. /**
  66545. * Sets the easing mode of the current function.
  66546. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  66547. */
  66548. setEasingMode(easingMode: number): void;
  66549. /**
  66550. * Gets the current easing mode.
  66551. * @returns the easing mode
  66552. */
  66553. getEasingMode(): number;
  66554. /**
  66555. * @hidden
  66556. */
  66557. easeInCore(gradient: number): number;
  66558. /**
  66559. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66560. * of the easing function.
  66561. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66562. * @returns the corresponding value on the curve defined by the easing function
  66563. */
  66564. ease(gradient: number): number;
  66565. }
  66566. /**
  66567. * Easing function with a circle shape (see link below).
  66568. * @see https://easings.net/#easeInCirc
  66569. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66570. */
  66571. export class CircleEase extends EasingFunction implements IEasingFunction {
  66572. /** @hidden */
  66573. easeInCore(gradient: number): number;
  66574. }
  66575. /**
  66576. * Easing function with a ease back shape (see link below).
  66577. * @see https://easings.net/#easeInBack
  66578. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66579. */
  66580. export class BackEase extends EasingFunction implements IEasingFunction {
  66581. /** Defines the amplitude of the function */
  66582. amplitude: number;
  66583. /**
  66584. * Instantiates a back ease easing
  66585. * @see https://easings.net/#easeInBack
  66586. * @param amplitude Defines the amplitude of the function
  66587. */
  66588. constructor(
  66589. /** Defines the amplitude of the function */
  66590. amplitude?: number);
  66591. /** @hidden */
  66592. easeInCore(gradient: number): number;
  66593. }
  66594. /**
  66595. * Easing function with a bouncing shape (see link below).
  66596. * @see https://easings.net/#easeInBounce
  66597. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66598. */
  66599. export class BounceEase extends EasingFunction implements IEasingFunction {
  66600. /** Defines the number of bounces */
  66601. bounces: number;
  66602. /** Defines the amplitude of the bounce */
  66603. bounciness: number;
  66604. /**
  66605. * Instantiates a bounce easing
  66606. * @see https://easings.net/#easeInBounce
  66607. * @param bounces Defines the number of bounces
  66608. * @param bounciness Defines the amplitude of the bounce
  66609. */
  66610. constructor(
  66611. /** Defines the number of bounces */
  66612. bounces?: number,
  66613. /** Defines the amplitude of the bounce */
  66614. bounciness?: number);
  66615. /** @hidden */
  66616. easeInCore(gradient: number): number;
  66617. }
  66618. /**
  66619. * Easing function with a power of 3 shape (see link below).
  66620. * @see https://easings.net/#easeInCubic
  66621. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66622. */
  66623. export class CubicEase extends EasingFunction implements IEasingFunction {
  66624. /** @hidden */
  66625. easeInCore(gradient: number): number;
  66626. }
  66627. /**
  66628. * Easing function with an elastic shape (see link below).
  66629. * @see https://easings.net/#easeInElastic
  66630. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66631. */
  66632. export class ElasticEase extends EasingFunction implements IEasingFunction {
  66633. /** Defines the number of oscillations*/
  66634. oscillations: number;
  66635. /** Defines the amplitude of the oscillations*/
  66636. springiness: number;
  66637. /**
  66638. * Instantiates an elastic easing function
  66639. * @see https://easings.net/#easeInElastic
  66640. * @param oscillations Defines the number of oscillations
  66641. * @param springiness Defines the amplitude of the oscillations
  66642. */
  66643. constructor(
  66644. /** Defines the number of oscillations*/
  66645. oscillations?: number,
  66646. /** Defines the amplitude of the oscillations*/
  66647. springiness?: number);
  66648. /** @hidden */
  66649. easeInCore(gradient: number): number;
  66650. }
  66651. /**
  66652. * Easing function with an exponential shape (see link below).
  66653. * @see https://easings.net/#easeInExpo
  66654. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66655. */
  66656. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  66657. /** Defines the exponent of the function */
  66658. exponent: number;
  66659. /**
  66660. * Instantiates an exponential easing function
  66661. * @see https://easings.net/#easeInExpo
  66662. * @param exponent Defines the exponent of the function
  66663. */
  66664. constructor(
  66665. /** Defines the exponent of the function */
  66666. exponent?: number);
  66667. /** @hidden */
  66668. easeInCore(gradient: number): number;
  66669. }
  66670. /**
  66671. * Easing function with a power shape (see link below).
  66672. * @see https://easings.net/#easeInQuad
  66673. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66674. */
  66675. export class PowerEase extends EasingFunction implements IEasingFunction {
  66676. /** Defines the power of the function */
  66677. power: number;
  66678. /**
  66679. * Instantiates an power base easing function
  66680. * @see https://easings.net/#easeInQuad
  66681. * @param power Defines the power of the function
  66682. */
  66683. constructor(
  66684. /** Defines the power of the function */
  66685. power?: number);
  66686. /** @hidden */
  66687. easeInCore(gradient: number): number;
  66688. }
  66689. /**
  66690. * Easing function with a power of 2 shape (see link below).
  66691. * @see https://easings.net/#easeInQuad
  66692. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66693. */
  66694. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  66695. /** @hidden */
  66696. easeInCore(gradient: number): number;
  66697. }
  66698. /**
  66699. * Easing function with a power of 4 shape (see link below).
  66700. * @see https://easings.net/#easeInQuart
  66701. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66702. */
  66703. export class QuarticEase extends EasingFunction implements IEasingFunction {
  66704. /** @hidden */
  66705. easeInCore(gradient: number): number;
  66706. }
  66707. /**
  66708. * Easing function with a power of 5 shape (see link below).
  66709. * @see https://easings.net/#easeInQuint
  66710. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66711. */
  66712. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66713. /** @hidden */
  66714. easeInCore(gradient: number): number;
  66715. }
  66716. /**
  66717. * Easing function with a sin shape (see link below).
  66718. * @see https://easings.net/#easeInSine
  66719. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66720. */
  66721. export class SineEase extends EasingFunction implements IEasingFunction {
  66722. /** @hidden */
  66723. easeInCore(gradient: number): number;
  66724. }
  66725. /**
  66726. * Easing function with a bezier shape (see link below).
  66727. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66728. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66729. */
  66730. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66731. /** Defines the x component of the start tangent in the bezier curve */
  66732. x1: number;
  66733. /** Defines the y component of the start tangent in the bezier curve */
  66734. y1: number;
  66735. /** Defines the x component of the end tangent in the bezier curve */
  66736. x2: number;
  66737. /** Defines the y component of the end tangent in the bezier curve */
  66738. y2: number;
  66739. /**
  66740. * Instantiates a bezier function
  66741. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66742. * @param x1 Defines the x component of the start tangent in the bezier curve
  66743. * @param y1 Defines the y component of the start tangent in the bezier curve
  66744. * @param x2 Defines the x component of the end tangent in the bezier curve
  66745. * @param y2 Defines the y component of the end tangent in the bezier curve
  66746. */
  66747. constructor(
  66748. /** Defines the x component of the start tangent in the bezier curve */
  66749. x1?: number,
  66750. /** Defines the y component of the start tangent in the bezier curve */
  66751. y1?: number,
  66752. /** Defines the x component of the end tangent in the bezier curve */
  66753. x2?: number,
  66754. /** Defines the y component of the end tangent in the bezier curve */
  66755. y2?: number);
  66756. /** @hidden */
  66757. easeInCore(gradient: number): number;
  66758. }
  66759. }
  66760. declare module BABYLON {
  66761. /**
  66762. * Defines an interface which represents an animation key frame
  66763. */
  66764. export interface IAnimationKey {
  66765. /**
  66766. * Frame of the key frame
  66767. */
  66768. frame: number;
  66769. /**
  66770. * Value at the specifies key frame
  66771. */
  66772. value: any;
  66773. /**
  66774. * The input tangent for the cubic hermite spline
  66775. */
  66776. inTangent?: any;
  66777. /**
  66778. * The output tangent for the cubic hermite spline
  66779. */
  66780. outTangent?: any;
  66781. /**
  66782. * The animation interpolation type
  66783. */
  66784. interpolation?: AnimationKeyInterpolation;
  66785. }
  66786. /**
  66787. * Enum for the animation key frame interpolation type
  66788. */
  66789. export enum AnimationKeyInterpolation {
  66790. /**
  66791. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66792. */
  66793. STEP = 1
  66794. }
  66795. }
  66796. declare module BABYLON {
  66797. /**
  66798. * Represents the range of an animation
  66799. */
  66800. export class AnimationRange {
  66801. /**The name of the animation range**/
  66802. name: string;
  66803. /**The starting frame of the animation */
  66804. from: number;
  66805. /**The ending frame of the animation*/
  66806. to: number;
  66807. /**
  66808. * Initializes the range of an animation
  66809. * @param name The name of the animation range
  66810. * @param from The starting frame of the animation
  66811. * @param to The ending frame of the animation
  66812. */
  66813. constructor(
  66814. /**The name of the animation range**/
  66815. name: string,
  66816. /**The starting frame of the animation */
  66817. from: number,
  66818. /**The ending frame of the animation*/
  66819. to: number);
  66820. /**
  66821. * Makes a copy of the animation range
  66822. * @returns A copy of the animation range
  66823. */
  66824. clone(): AnimationRange;
  66825. }
  66826. }
  66827. declare module BABYLON {
  66828. /**
  66829. * Composed of a frame, and an action function
  66830. */
  66831. export class AnimationEvent {
  66832. /** The frame for which the event is triggered **/
  66833. frame: number;
  66834. /** The event to perform when triggered **/
  66835. action: (currentFrame: number) => void;
  66836. /** Specifies if the event should be triggered only once**/
  66837. onlyOnce?: boolean | undefined;
  66838. /**
  66839. * Specifies if the animation event is done
  66840. */
  66841. isDone: boolean;
  66842. /**
  66843. * Initializes the animation event
  66844. * @param frame The frame for which the event is triggered
  66845. * @param action The event to perform when triggered
  66846. * @param onlyOnce Specifies if the event should be triggered only once
  66847. */
  66848. constructor(
  66849. /** The frame for which the event is triggered **/
  66850. frame: number,
  66851. /** The event to perform when triggered **/
  66852. action: (currentFrame: number) => void,
  66853. /** Specifies if the event should be triggered only once**/
  66854. onlyOnce?: boolean | undefined);
  66855. /** @hidden */
  66856. _clone(): AnimationEvent;
  66857. }
  66858. }
  66859. declare module BABYLON {
  66860. /**
  66861. * Interface used to define a behavior
  66862. */
  66863. export interface Behavior<T> {
  66864. /** gets or sets behavior's name */
  66865. name: string;
  66866. /**
  66867. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66868. */
  66869. init(): void;
  66870. /**
  66871. * Called when the behavior is attached to a target
  66872. * @param target defines the target where the behavior is attached to
  66873. */
  66874. attach(target: T): void;
  66875. /**
  66876. * Called when the behavior is detached from its target
  66877. */
  66878. detach(): void;
  66879. }
  66880. /**
  66881. * Interface implemented by classes supporting behaviors
  66882. */
  66883. export interface IBehaviorAware<T> {
  66884. /**
  66885. * Attach a behavior
  66886. * @param behavior defines the behavior to attach
  66887. * @returns the current host
  66888. */
  66889. addBehavior(behavior: Behavior<T>): T;
  66890. /**
  66891. * Remove a behavior from the current object
  66892. * @param behavior defines the behavior to detach
  66893. * @returns the current host
  66894. */
  66895. removeBehavior(behavior: Behavior<T>): T;
  66896. /**
  66897. * Gets a behavior using its name to search
  66898. * @param name defines the name to search
  66899. * @returns the behavior or null if not found
  66900. */
  66901. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66902. }
  66903. }
  66904. declare module BABYLON {
  66905. /**
  66906. * @hidden
  66907. */
  66908. export class IntersectionInfo {
  66909. bu: Nullable<number>;
  66910. bv: Nullable<number>;
  66911. distance: number;
  66912. faceId: number;
  66913. subMeshId: number;
  66914. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66915. }
  66916. }
  66917. declare module BABYLON {
  66918. /**
  66919. * Class used to store bounding sphere information
  66920. */
  66921. export class BoundingSphere {
  66922. /**
  66923. * Gets the center of the bounding sphere in local space
  66924. */
  66925. readonly center: Vector3;
  66926. /**
  66927. * Radius of the bounding sphere in local space
  66928. */
  66929. radius: number;
  66930. /**
  66931. * Gets the center of the bounding sphere in world space
  66932. */
  66933. readonly centerWorld: Vector3;
  66934. /**
  66935. * Radius of the bounding sphere in world space
  66936. */
  66937. radiusWorld: number;
  66938. /**
  66939. * Gets the minimum vector in local space
  66940. */
  66941. readonly minimum: Vector3;
  66942. /**
  66943. * Gets the maximum vector in local space
  66944. */
  66945. readonly maximum: Vector3;
  66946. private _worldMatrix;
  66947. private static readonly TmpVector3;
  66948. /**
  66949. * Creates a new bounding sphere
  66950. * @param min defines the minimum vector (in local space)
  66951. * @param max defines the maximum vector (in local space)
  66952. * @param worldMatrix defines the new world matrix
  66953. */
  66954. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66955. /**
  66956. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66957. * @param min defines the new minimum vector (in local space)
  66958. * @param max defines the new maximum vector (in local space)
  66959. * @param worldMatrix defines the new world matrix
  66960. */
  66961. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66962. /**
  66963. * Scale the current bounding sphere by applying a scale factor
  66964. * @param factor defines the scale factor to apply
  66965. * @returns the current bounding box
  66966. */
  66967. scale(factor: number): BoundingSphere;
  66968. /**
  66969. * Gets the world matrix of the bounding box
  66970. * @returns a matrix
  66971. */
  66972. getWorldMatrix(): DeepImmutable<Matrix>;
  66973. /** @hidden */
  66974. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66975. /**
  66976. * Tests if the bounding sphere is intersecting the frustum planes
  66977. * @param frustumPlanes defines the frustum planes to test
  66978. * @returns true if there is an intersection
  66979. */
  66980. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66981. /**
  66982. * Tests if the bounding sphere center is in between the frustum planes.
  66983. * Used for optimistic fast inclusion.
  66984. * @param frustumPlanes defines the frustum planes to test
  66985. * @returns true if the sphere center is in between the frustum planes
  66986. */
  66987. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66988. /**
  66989. * Tests if a point is inside the bounding sphere
  66990. * @param point defines the point to test
  66991. * @returns true if the point is inside the bounding sphere
  66992. */
  66993. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66994. /**
  66995. * Checks if two sphere intersct
  66996. * @param sphere0 sphere 0
  66997. * @param sphere1 sphere 1
  66998. * @returns true if the speres intersect
  66999. */
  67000. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  67001. }
  67002. }
  67003. declare module BABYLON {
  67004. /**
  67005. * Class used to store bounding box information
  67006. */
  67007. export class BoundingBox implements ICullable {
  67008. /**
  67009. * Gets the 8 vectors representing the bounding box in local space
  67010. */
  67011. readonly vectors: Vector3[];
  67012. /**
  67013. * Gets the center of the bounding box in local space
  67014. */
  67015. readonly center: Vector3;
  67016. /**
  67017. * Gets the center of the bounding box in world space
  67018. */
  67019. readonly centerWorld: Vector3;
  67020. /**
  67021. * Gets the extend size in local space
  67022. */
  67023. readonly extendSize: Vector3;
  67024. /**
  67025. * Gets the extend size in world space
  67026. */
  67027. readonly extendSizeWorld: Vector3;
  67028. /**
  67029. * Gets the OBB (object bounding box) directions
  67030. */
  67031. readonly directions: Vector3[];
  67032. /**
  67033. * Gets the 8 vectors representing the bounding box in world space
  67034. */
  67035. readonly vectorsWorld: Vector3[];
  67036. /**
  67037. * Gets the minimum vector in world space
  67038. */
  67039. readonly minimumWorld: Vector3;
  67040. /**
  67041. * Gets the maximum vector in world space
  67042. */
  67043. readonly maximumWorld: Vector3;
  67044. /**
  67045. * Gets the minimum vector in local space
  67046. */
  67047. readonly minimum: Vector3;
  67048. /**
  67049. * Gets the maximum vector in local space
  67050. */
  67051. readonly maximum: Vector3;
  67052. private _worldMatrix;
  67053. private static readonly TmpVector3;
  67054. /**
  67055. * @hidden
  67056. */
  67057. _tag: number;
  67058. /**
  67059. * Creates a new bounding box
  67060. * @param min defines the minimum vector (in local space)
  67061. * @param max defines the maximum vector (in local space)
  67062. * @param worldMatrix defines the new world matrix
  67063. */
  67064. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  67065. /**
  67066. * Recreates the entire bounding box from scratch as if we call the constructor in place
  67067. * @param min defines the new minimum vector (in local space)
  67068. * @param max defines the new maximum vector (in local space)
  67069. * @param worldMatrix defines the new world matrix
  67070. */
  67071. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  67072. /**
  67073. * Scale the current bounding box by applying a scale factor
  67074. * @param factor defines the scale factor to apply
  67075. * @returns the current bounding box
  67076. */
  67077. scale(factor: number): BoundingBox;
  67078. /**
  67079. * Gets the world matrix of the bounding box
  67080. * @returns a matrix
  67081. */
  67082. getWorldMatrix(): DeepImmutable<Matrix>;
  67083. /** @hidden */
  67084. _update(world: DeepImmutable<Matrix>): void;
  67085. /**
  67086. * Tests if the bounding box is intersecting the frustum planes
  67087. * @param frustumPlanes defines the frustum planes to test
  67088. * @returns true if there is an intersection
  67089. */
  67090. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67091. /**
  67092. * Tests if the bounding box is entirely inside the frustum planes
  67093. * @param frustumPlanes defines the frustum planes to test
  67094. * @returns true if there is an inclusion
  67095. */
  67096. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67097. /**
  67098. * Tests if a point is inside the bounding box
  67099. * @param point defines the point to test
  67100. * @returns true if the point is inside the bounding box
  67101. */
  67102. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  67103. /**
  67104. * Tests if the bounding box intersects with a bounding sphere
  67105. * @param sphere defines the sphere to test
  67106. * @returns true if there is an intersection
  67107. */
  67108. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  67109. /**
  67110. * Tests if the bounding box intersects with a box defined by a min and max vectors
  67111. * @param min defines the min vector to use
  67112. * @param max defines the max vector to use
  67113. * @returns true if there is an intersection
  67114. */
  67115. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  67116. /**
  67117. * Tests if two bounding boxes are intersections
  67118. * @param box0 defines the first box to test
  67119. * @param box1 defines the second box to test
  67120. * @returns true if there is an intersection
  67121. */
  67122. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  67123. /**
  67124. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  67125. * @param minPoint defines the minimum vector of the bounding box
  67126. * @param maxPoint defines the maximum vector of the bounding box
  67127. * @param sphereCenter defines the sphere center
  67128. * @param sphereRadius defines the sphere radius
  67129. * @returns true if there is an intersection
  67130. */
  67131. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  67132. /**
  67133. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  67134. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67135. * @param frustumPlanes defines the frustum planes to test
  67136. * @return true if there is an inclusion
  67137. */
  67138. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67139. /**
  67140. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  67141. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67142. * @param frustumPlanes defines the frustum planes to test
  67143. * @return true if there is an intersection
  67144. */
  67145. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67146. }
  67147. }
  67148. declare module BABYLON {
  67149. /** @hidden */
  67150. export class Collider {
  67151. /** Define if a collision was found */
  67152. collisionFound: boolean;
  67153. /**
  67154. * Define last intersection point in local space
  67155. */
  67156. intersectionPoint: Vector3;
  67157. /**
  67158. * Define last collided mesh
  67159. */
  67160. collidedMesh: Nullable<AbstractMesh>;
  67161. private _collisionPoint;
  67162. private _planeIntersectionPoint;
  67163. private _tempVector;
  67164. private _tempVector2;
  67165. private _tempVector3;
  67166. private _tempVector4;
  67167. private _edge;
  67168. private _baseToVertex;
  67169. private _destinationPoint;
  67170. private _slidePlaneNormal;
  67171. private _displacementVector;
  67172. /** @hidden */
  67173. _radius: Vector3;
  67174. /** @hidden */
  67175. _retry: number;
  67176. private _velocity;
  67177. private _basePoint;
  67178. private _epsilon;
  67179. /** @hidden */
  67180. _velocityWorldLength: number;
  67181. /** @hidden */
  67182. _basePointWorld: Vector3;
  67183. private _velocityWorld;
  67184. private _normalizedVelocity;
  67185. /** @hidden */
  67186. _initialVelocity: Vector3;
  67187. /** @hidden */
  67188. _initialPosition: Vector3;
  67189. private _nearestDistance;
  67190. private _collisionMask;
  67191. collisionMask: number;
  67192. /**
  67193. * Gets the plane normal used to compute the sliding response (in local space)
  67194. */
  67195. readonly slidePlaneNormal: Vector3;
  67196. /** @hidden */
  67197. _initialize(source: Vector3, dir: Vector3, e: number): void;
  67198. /** @hidden */
  67199. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  67200. /** @hidden */
  67201. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  67202. /** @hidden */
  67203. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  67204. /** @hidden */
  67205. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  67206. /** @hidden */
  67207. _getResponse(pos: Vector3, vel: Vector3): void;
  67208. }
  67209. }
  67210. declare module BABYLON {
  67211. /**
  67212. * Interface for cullable objects
  67213. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  67214. */
  67215. export interface ICullable {
  67216. /**
  67217. * Checks if the object or part of the object is in the frustum
  67218. * @param frustumPlanes Camera near/planes
  67219. * @returns true if the object is in frustum otherwise false
  67220. */
  67221. isInFrustum(frustumPlanes: Plane[]): boolean;
  67222. /**
  67223. * Checks if a cullable object (mesh...) is in the camera frustum
  67224. * Unlike isInFrustum this cheks the full bounding box
  67225. * @param frustumPlanes Camera near/planes
  67226. * @returns true if the object is in frustum otherwise false
  67227. */
  67228. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  67229. }
  67230. /**
  67231. * Info for a bounding data of a mesh
  67232. */
  67233. export class BoundingInfo implements ICullable {
  67234. /**
  67235. * Bounding box for the mesh
  67236. */
  67237. readonly boundingBox: BoundingBox;
  67238. /**
  67239. * Bounding sphere for the mesh
  67240. */
  67241. readonly boundingSphere: BoundingSphere;
  67242. private _isLocked;
  67243. private static readonly TmpVector3;
  67244. /**
  67245. * Constructs bounding info
  67246. * @param minimum min vector of the bounding box/sphere
  67247. * @param maximum max vector of the bounding box/sphere
  67248. * @param worldMatrix defines the new world matrix
  67249. */
  67250. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  67251. /**
  67252. * Recreates the entire bounding info from scratch as if we call the constructor in place
  67253. * @param min defines the new minimum vector (in local space)
  67254. * @param max defines the new maximum vector (in local space)
  67255. * @param worldMatrix defines the new world matrix
  67256. */
  67257. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  67258. /**
  67259. * min vector of the bounding box/sphere
  67260. */
  67261. readonly minimum: Vector3;
  67262. /**
  67263. * max vector of the bounding box/sphere
  67264. */
  67265. readonly maximum: Vector3;
  67266. /**
  67267. * If the info is locked and won't be updated to avoid perf overhead
  67268. */
  67269. isLocked: boolean;
  67270. /**
  67271. * Updates the bounding sphere and box
  67272. * @param world world matrix to be used to update
  67273. */
  67274. update(world: DeepImmutable<Matrix>): void;
  67275. /**
  67276. * Recreate the bounding info to be centered around a specific point given a specific extend.
  67277. * @param center New center of the bounding info
  67278. * @param extend New extend of the bounding info
  67279. * @returns the current bounding info
  67280. */
  67281. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  67282. /**
  67283. * Scale the current bounding info by applying a scale factor
  67284. * @param factor defines the scale factor to apply
  67285. * @returns the current bounding info
  67286. */
  67287. scale(factor: number): BoundingInfo;
  67288. /**
  67289. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  67290. * @param frustumPlanes defines the frustum to test
  67291. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  67292. * @returns true if the bounding info is in the frustum planes
  67293. */
  67294. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  67295. /**
  67296. * Gets the world distance between the min and max points of the bounding box
  67297. */
  67298. readonly diagonalLength: number;
  67299. /**
  67300. * Checks if a cullable object (mesh...) is in the camera frustum
  67301. * Unlike isInFrustum this cheks the full bounding box
  67302. * @param frustumPlanes Camera near/planes
  67303. * @returns true if the object is in frustum otherwise false
  67304. */
  67305. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67306. /** @hidden */
  67307. _checkCollision(collider: Collider): boolean;
  67308. /**
  67309. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  67310. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67311. * @param point the point to check intersection with
  67312. * @returns if the point intersects
  67313. */
  67314. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  67315. /**
  67316. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  67317. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67318. * @param boundingInfo the bounding info to check intersection with
  67319. * @param precise if the intersection should be done using OBB
  67320. * @returns if the bounding info intersects
  67321. */
  67322. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  67323. }
  67324. }
  67325. declare module BABYLON {
  67326. /**
  67327. * Defines an array and its length.
  67328. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  67329. */
  67330. export interface ISmartArrayLike<T> {
  67331. /**
  67332. * The data of the array.
  67333. */
  67334. data: Array<T>;
  67335. /**
  67336. * The active length of the array.
  67337. */
  67338. length: number;
  67339. }
  67340. /**
  67341. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67342. */
  67343. export class SmartArray<T> implements ISmartArrayLike<T> {
  67344. /**
  67345. * The full set of data from the array.
  67346. */
  67347. data: Array<T>;
  67348. /**
  67349. * The active length of the array.
  67350. */
  67351. length: number;
  67352. protected _id: number;
  67353. /**
  67354. * Instantiates a Smart Array.
  67355. * @param capacity defines the default capacity of the array.
  67356. */
  67357. constructor(capacity: number);
  67358. /**
  67359. * Pushes a value at the end of the active data.
  67360. * @param value defines the object to push in the array.
  67361. */
  67362. push(value: T): void;
  67363. /**
  67364. * Iterates over the active data and apply the lambda to them.
  67365. * @param func defines the action to apply on each value.
  67366. */
  67367. forEach(func: (content: T) => void): void;
  67368. /**
  67369. * Sorts the full sets of data.
  67370. * @param compareFn defines the comparison function to apply.
  67371. */
  67372. sort(compareFn: (a: T, b: T) => number): void;
  67373. /**
  67374. * Resets the active data to an empty array.
  67375. */
  67376. reset(): void;
  67377. /**
  67378. * Releases all the data from the array as well as the array.
  67379. */
  67380. dispose(): void;
  67381. /**
  67382. * Concats the active data with a given array.
  67383. * @param array defines the data to concatenate with.
  67384. */
  67385. concat(array: any): void;
  67386. /**
  67387. * Returns the position of a value in the active data.
  67388. * @param value defines the value to find the index for
  67389. * @returns the index if found in the active data otherwise -1
  67390. */
  67391. indexOf(value: T): number;
  67392. /**
  67393. * Returns whether an element is part of the active data.
  67394. * @param value defines the value to look for
  67395. * @returns true if found in the active data otherwise false
  67396. */
  67397. contains(value: T): boolean;
  67398. private static _GlobalId;
  67399. }
  67400. /**
  67401. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67402. * The data in this array can only be present once
  67403. */
  67404. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  67405. private _duplicateId;
  67406. /**
  67407. * Pushes a value at the end of the active data.
  67408. * THIS DOES NOT PREVENT DUPPLICATE DATA
  67409. * @param value defines the object to push in the array.
  67410. */
  67411. push(value: T): void;
  67412. /**
  67413. * Pushes a value at the end of the active data.
  67414. * If the data is already present, it won t be added again
  67415. * @param value defines the object to push in the array.
  67416. * @returns true if added false if it was already present
  67417. */
  67418. pushNoDuplicate(value: T): boolean;
  67419. /**
  67420. * Resets the active data to an empty array.
  67421. */
  67422. reset(): void;
  67423. /**
  67424. * Concats the active data with a given array.
  67425. * This ensures no dupplicate will be present in the result.
  67426. * @param array defines the data to concatenate with.
  67427. */
  67428. concatWithNoDuplicate(array: any): void;
  67429. }
  67430. }
  67431. declare module BABYLON {
  67432. /**
  67433. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67434. * separate meshes. This can be use to improve performances.
  67435. * @see http://doc.babylonjs.com/how_to/multi_materials
  67436. */
  67437. export class MultiMaterial extends Material {
  67438. private _subMaterials;
  67439. /**
  67440. * Gets or Sets the list of Materials used within the multi material.
  67441. * They need to be ordered according to the submeshes order in the associated mesh
  67442. */
  67443. subMaterials: Nullable<Material>[];
  67444. /**
  67445. * Function used to align with Node.getChildren()
  67446. * @returns the list of Materials used within the multi material
  67447. */
  67448. getChildren(): Nullable<Material>[];
  67449. /**
  67450. * Instantiates a new Multi Material
  67451. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67452. * separate meshes. This can be use to improve performances.
  67453. * @see http://doc.babylonjs.com/how_to/multi_materials
  67454. * @param name Define the name in the scene
  67455. * @param scene Define the scene the material belongs to
  67456. */
  67457. constructor(name: string, scene: Scene);
  67458. private _hookArray;
  67459. /**
  67460. * Get one of the submaterial by its index in the submaterials array
  67461. * @param index The index to look the sub material at
  67462. * @returns The Material if the index has been defined
  67463. */
  67464. getSubMaterial(index: number): Nullable<Material>;
  67465. /**
  67466. * Get the list of active textures for the whole sub materials list.
  67467. * @returns All the textures that will be used during the rendering
  67468. */
  67469. getActiveTextures(): BaseTexture[];
  67470. /**
  67471. * Gets the current class name of the material e.g. "MultiMaterial"
  67472. * Mainly use in serialization.
  67473. * @returns the class name
  67474. */
  67475. getClassName(): string;
  67476. /**
  67477. * Checks if the material is ready to render the requested sub mesh
  67478. * @param mesh Define the mesh the submesh belongs to
  67479. * @param subMesh Define the sub mesh to look readyness for
  67480. * @param useInstances Define whether or not the material is used with instances
  67481. * @returns true if ready, otherwise false
  67482. */
  67483. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  67484. /**
  67485. * Clones the current material and its related sub materials
  67486. * @param name Define the name of the newly cloned material
  67487. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  67488. * @returns the cloned material
  67489. */
  67490. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  67491. /**
  67492. * Serializes the materials into a JSON representation.
  67493. * @returns the JSON representation
  67494. */
  67495. serialize(): any;
  67496. /**
  67497. * Dispose the material and release its associated resources
  67498. * @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)
  67499. * @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)
  67500. * @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)
  67501. */
  67502. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  67503. /**
  67504. * Creates a MultiMaterial from parsed MultiMaterial data.
  67505. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  67506. * @param scene defines the hosting scene
  67507. * @returns a new MultiMaterial
  67508. */
  67509. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  67510. }
  67511. }
  67512. declare module BABYLON {
  67513. /**
  67514. * Class used to represent data loading progression
  67515. */
  67516. export class SceneLoaderFlags {
  67517. private static _ForceFullSceneLoadingForIncremental;
  67518. private static _ShowLoadingScreen;
  67519. private static _CleanBoneMatrixWeights;
  67520. private static _loggingLevel;
  67521. /**
  67522. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  67523. */
  67524. static ForceFullSceneLoadingForIncremental: boolean;
  67525. /**
  67526. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  67527. */
  67528. static ShowLoadingScreen: boolean;
  67529. /**
  67530. * Defines the current logging level (while loading the scene)
  67531. * @ignorenaming
  67532. */
  67533. static loggingLevel: number;
  67534. /**
  67535. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  67536. */
  67537. static CleanBoneMatrixWeights: boolean;
  67538. }
  67539. }
  67540. declare module BABYLON {
  67541. /**
  67542. * 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.
  67543. * @see https://doc.babylonjs.com/how_to/transformnode
  67544. */
  67545. export class TransformNode extends Node {
  67546. /**
  67547. * Object will not rotate to face the camera
  67548. */
  67549. static BILLBOARDMODE_NONE: number;
  67550. /**
  67551. * Object will rotate to face the camera but only on the x axis
  67552. */
  67553. static BILLBOARDMODE_X: number;
  67554. /**
  67555. * Object will rotate to face the camera but only on the y axis
  67556. */
  67557. static BILLBOARDMODE_Y: number;
  67558. /**
  67559. * Object will rotate to face the camera but only on the z axis
  67560. */
  67561. static BILLBOARDMODE_Z: number;
  67562. /**
  67563. * Object will rotate to face the camera
  67564. */
  67565. static BILLBOARDMODE_ALL: number;
  67566. private _forward;
  67567. private _forwardInverted;
  67568. private _up;
  67569. private _right;
  67570. private _rightInverted;
  67571. private _position;
  67572. private _rotation;
  67573. private _rotationQuaternion;
  67574. protected _scaling: Vector3;
  67575. protected _isDirty: boolean;
  67576. private _transformToBoneReferal;
  67577. private _billboardMode;
  67578. /**
  67579. * Gets or sets the billboard mode. Default is 0.
  67580. *
  67581. * | Value | Type | Description |
  67582. * | --- | --- | --- |
  67583. * | 0 | BILLBOARDMODE_NONE | |
  67584. * | 1 | BILLBOARDMODE_X | |
  67585. * | 2 | BILLBOARDMODE_Y | |
  67586. * | 4 | BILLBOARDMODE_Z | |
  67587. * | 7 | BILLBOARDMODE_ALL | |
  67588. *
  67589. */
  67590. billboardMode: number;
  67591. private _preserveParentRotationForBillboard;
  67592. /**
  67593. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  67594. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  67595. */
  67596. preserveParentRotationForBillboard: boolean;
  67597. /**
  67598. * 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
  67599. */
  67600. scalingDeterminant: number;
  67601. private _infiniteDistance;
  67602. /**
  67603. * Gets or sets the distance of the object to max, often used by skybox
  67604. */
  67605. infiniteDistance: boolean;
  67606. /**
  67607. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  67608. * By default the system will update normals to compensate
  67609. */
  67610. ignoreNonUniformScaling: boolean;
  67611. /**
  67612. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  67613. */
  67614. reIntegrateRotationIntoRotationQuaternion: boolean;
  67615. /** @hidden */
  67616. _poseMatrix: Nullable<Matrix>;
  67617. /** @hidden */
  67618. _localMatrix: Matrix;
  67619. private _usePivotMatrix;
  67620. private _absolutePosition;
  67621. private _pivotMatrix;
  67622. private _pivotMatrixInverse;
  67623. protected _postMultiplyPivotMatrix: boolean;
  67624. protected _isWorldMatrixFrozen: boolean;
  67625. /** @hidden */
  67626. _indexInSceneTransformNodesArray: number;
  67627. /**
  67628. * An event triggered after the world matrix is updated
  67629. */
  67630. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  67631. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  67632. /**
  67633. * Gets a string identifying the name of the class
  67634. * @returns "TransformNode" string
  67635. */
  67636. getClassName(): string;
  67637. /**
  67638. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  67639. */
  67640. position: Vector3;
  67641. /**
  67642. * 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)).
  67643. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  67644. */
  67645. rotation: Vector3;
  67646. /**
  67647. * 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)).
  67648. */
  67649. scaling: Vector3;
  67650. /**
  67651. * 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).
  67652. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  67653. */
  67654. rotationQuaternion: Nullable<Quaternion>;
  67655. /**
  67656. * The forward direction of that transform in world space.
  67657. */
  67658. readonly forward: Vector3;
  67659. /**
  67660. * The up direction of that transform in world space.
  67661. */
  67662. readonly up: Vector3;
  67663. /**
  67664. * The right direction of that transform in world space.
  67665. */
  67666. readonly right: Vector3;
  67667. /**
  67668. * Copies the parameter passed Matrix into the mesh Pose matrix.
  67669. * @param matrix the matrix to copy the pose from
  67670. * @returns this TransformNode.
  67671. */
  67672. updatePoseMatrix(matrix: Matrix): TransformNode;
  67673. /**
  67674. * Returns the mesh Pose matrix.
  67675. * @returns the pose matrix
  67676. */
  67677. getPoseMatrix(): Matrix;
  67678. /** @hidden */
  67679. _isSynchronized(): boolean;
  67680. /** @hidden */
  67681. _initCache(): void;
  67682. /**
  67683. * Flag the transform node as dirty (Forcing it to update everything)
  67684. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  67685. * @returns this transform node
  67686. */
  67687. markAsDirty(property: string): TransformNode;
  67688. /**
  67689. * Returns the current mesh absolute position.
  67690. * Returns a Vector3.
  67691. */
  67692. readonly absolutePosition: Vector3;
  67693. /**
  67694. * Sets a new matrix to apply before all other transformation
  67695. * @param matrix defines the transform matrix
  67696. * @returns the current TransformNode
  67697. */
  67698. setPreTransformMatrix(matrix: Matrix): TransformNode;
  67699. /**
  67700. * Sets a new pivot matrix to the current node
  67701. * @param matrix defines the new pivot matrix to use
  67702. * @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
  67703. * @returns the current TransformNode
  67704. */
  67705. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67706. /**
  67707. * Returns the mesh pivot matrix.
  67708. * Default : Identity.
  67709. * @returns the matrix
  67710. */
  67711. getPivotMatrix(): Matrix;
  67712. /**
  67713. * Prevents the World matrix to be computed any longer.
  67714. * @returns the TransformNode.
  67715. */
  67716. freezeWorldMatrix(): TransformNode;
  67717. /**
  67718. * Allows back the World matrix computation.
  67719. * @returns the TransformNode.
  67720. */
  67721. unfreezeWorldMatrix(): this;
  67722. /**
  67723. * True if the World matrix has been frozen.
  67724. */
  67725. readonly isWorldMatrixFrozen: boolean;
  67726. /**
  67727. * Retuns the mesh absolute position in the World.
  67728. * @returns a Vector3.
  67729. */
  67730. getAbsolutePosition(): Vector3;
  67731. /**
  67732. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67733. * @param absolutePosition the absolute position to set
  67734. * @returns the TransformNode.
  67735. */
  67736. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67737. /**
  67738. * Sets the mesh position in its local space.
  67739. * @param vector3 the position to set in localspace
  67740. * @returns the TransformNode.
  67741. */
  67742. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67743. /**
  67744. * Returns the mesh position in the local space from the current World matrix values.
  67745. * @returns a new Vector3.
  67746. */
  67747. getPositionExpressedInLocalSpace(): Vector3;
  67748. /**
  67749. * Translates the mesh along the passed Vector3 in its local space.
  67750. * @param vector3 the distance to translate in localspace
  67751. * @returns the TransformNode.
  67752. */
  67753. locallyTranslate(vector3: Vector3): TransformNode;
  67754. private static _lookAtVectorCache;
  67755. /**
  67756. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67757. * @param targetPoint the position (must be in same space as current mesh) to look at
  67758. * @param yawCor optional yaw (y-axis) correction in radians
  67759. * @param pitchCor optional pitch (x-axis) correction in radians
  67760. * @param rollCor optional roll (z-axis) correction in radians
  67761. * @param space the choosen space of the target
  67762. * @returns the TransformNode.
  67763. */
  67764. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67765. /**
  67766. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67767. * This Vector3 is expressed in the World space.
  67768. * @param localAxis axis to rotate
  67769. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67770. */
  67771. getDirection(localAxis: Vector3): Vector3;
  67772. /**
  67773. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67774. * localAxis is expressed in the mesh local space.
  67775. * result is computed in the Wordl space from the mesh World matrix.
  67776. * @param localAxis axis to rotate
  67777. * @param result the resulting transformnode
  67778. * @returns this TransformNode.
  67779. */
  67780. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67781. /**
  67782. * Sets this transform node rotation to the given local axis.
  67783. * @param localAxis the axis in local space
  67784. * @param yawCor optional yaw (y-axis) correction in radians
  67785. * @param pitchCor optional pitch (x-axis) correction in radians
  67786. * @param rollCor optional roll (z-axis) correction in radians
  67787. * @returns this TransformNode
  67788. */
  67789. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67790. /**
  67791. * Sets a new pivot point to the current node
  67792. * @param point defines the new pivot point to use
  67793. * @param space defines if the point is in world or local space (local by default)
  67794. * @returns the current TransformNode
  67795. */
  67796. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67797. /**
  67798. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67799. * @returns the pivot point
  67800. */
  67801. getPivotPoint(): Vector3;
  67802. /**
  67803. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67804. * @param result the vector3 to store the result
  67805. * @returns this TransformNode.
  67806. */
  67807. getPivotPointToRef(result: Vector3): TransformNode;
  67808. /**
  67809. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67810. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67811. */
  67812. getAbsolutePivotPoint(): Vector3;
  67813. /**
  67814. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67815. * @param result vector3 to store the result
  67816. * @returns this TransformNode.
  67817. */
  67818. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67819. /**
  67820. * Defines the passed node as the parent of the current node.
  67821. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67822. * @see https://doc.babylonjs.com/how_to/parenting
  67823. * @param node the node ot set as the parent
  67824. * @returns this TransformNode.
  67825. */
  67826. setParent(node: Nullable<Node>): TransformNode;
  67827. private _nonUniformScaling;
  67828. /**
  67829. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67830. */
  67831. readonly nonUniformScaling: boolean;
  67832. /** @hidden */
  67833. _updateNonUniformScalingState(value: boolean): boolean;
  67834. /**
  67835. * Attach the current TransformNode to another TransformNode associated with a bone
  67836. * @param bone Bone affecting the TransformNode
  67837. * @param affectedTransformNode TransformNode associated with the bone
  67838. * @returns this object
  67839. */
  67840. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67841. /**
  67842. * Detach the transform node if its associated with a bone
  67843. * @returns this object
  67844. */
  67845. detachFromBone(): TransformNode;
  67846. private static _rotationAxisCache;
  67847. /**
  67848. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67849. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67850. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67851. * The passed axis is also normalized.
  67852. * @param axis the axis to rotate around
  67853. * @param amount the amount to rotate in radians
  67854. * @param space Space to rotate in (Default: local)
  67855. * @returns the TransformNode.
  67856. */
  67857. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67858. /**
  67859. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67860. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67861. * The passed axis is also normalized. .
  67862. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67863. * @param point the point to rotate around
  67864. * @param axis the axis to rotate around
  67865. * @param amount the amount to rotate in radians
  67866. * @returns the TransformNode
  67867. */
  67868. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67869. /**
  67870. * Translates the mesh along the axis vector for the passed distance in the given space.
  67871. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67872. * @param axis the axis to translate in
  67873. * @param distance the distance to translate
  67874. * @param space Space to rotate in (Default: local)
  67875. * @returns the TransformNode.
  67876. */
  67877. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67878. /**
  67879. * Adds a rotation step to the mesh current rotation.
  67880. * x, y, z are Euler angles expressed in radians.
  67881. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67882. * This means this rotation is made in the mesh local space only.
  67883. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67884. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67885. * ```javascript
  67886. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67887. * ```
  67888. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67889. * 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.
  67890. * @param x Rotation to add
  67891. * @param y Rotation to add
  67892. * @param z Rotation to add
  67893. * @returns the TransformNode.
  67894. */
  67895. addRotation(x: number, y: number, z: number): TransformNode;
  67896. /**
  67897. * @hidden
  67898. */
  67899. protected _getEffectiveParent(): Nullable<Node>;
  67900. /**
  67901. * Computes the world matrix of the node
  67902. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67903. * @returns the world matrix
  67904. */
  67905. computeWorldMatrix(force?: boolean): Matrix;
  67906. protected _afterComputeWorldMatrix(): void;
  67907. /**
  67908. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67909. * @param func callback function to add
  67910. *
  67911. * @returns the TransformNode.
  67912. */
  67913. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67914. /**
  67915. * Removes a registered callback function.
  67916. * @param func callback function to remove
  67917. * @returns the TransformNode.
  67918. */
  67919. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67920. /**
  67921. * Gets the position of the current mesh in camera space
  67922. * @param camera defines the camera to use
  67923. * @returns a position
  67924. */
  67925. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67926. /**
  67927. * Returns the distance from the mesh to the active camera
  67928. * @param camera defines the camera to use
  67929. * @returns the distance
  67930. */
  67931. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67932. /**
  67933. * Clone the current transform node
  67934. * @param name Name of the new clone
  67935. * @param newParent New parent for the clone
  67936. * @param doNotCloneChildren Do not clone children hierarchy
  67937. * @returns the new transform node
  67938. */
  67939. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67940. /**
  67941. * Serializes the objects information.
  67942. * @param currentSerializationObject defines the object to serialize in
  67943. * @returns the serialized object
  67944. */
  67945. serialize(currentSerializationObject?: any): any;
  67946. /**
  67947. * Returns a new TransformNode object parsed from the source provided.
  67948. * @param parsedTransformNode is the source.
  67949. * @param scene the scne the object belongs to
  67950. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67951. * @returns a new TransformNode object parsed from the source provided.
  67952. */
  67953. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67954. /**
  67955. * Get all child-transformNodes of this node
  67956. * @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
  67957. * @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
  67958. * @returns an array of TransformNode
  67959. */
  67960. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67961. /**
  67962. * Releases resources associated with this transform node.
  67963. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67964. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67965. */
  67966. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67967. }
  67968. }
  67969. declare module BABYLON {
  67970. /**
  67971. * Class used to override all child animations of a given target
  67972. */
  67973. export class AnimationPropertiesOverride {
  67974. /**
  67975. * Gets or sets a value indicating if animation blending must be used
  67976. */
  67977. enableBlending: boolean;
  67978. /**
  67979. * Gets or sets the blending speed to use when enableBlending is true
  67980. */
  67981. blendingSpeed: number;
  67982. /**
  67983. * Gets or sets the default loop mode to use
  67984. */
  67985. loopMode: number;
  67986. }
  67987. }
  67988. declare module BABYLON {
  67989. /**
  67990. * Class used to store bone information
  67991. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67992. */
  67993. export class Bone extends Node {
  67994. /**
  67995. * defines the bone name
  67996. */
  67997. name: string;
  67998. private static _tmpVecs;
  67999. private static _tmpQuat;
  68000. private static _tmpMats;
  68001. /**
  68002. * Gets the list of child bones
  68003. */
  68004. children: Bone[];
  68005. /** Gets the animations associated with this bone */
  68006. animations: Animation[];
  68007. /**
  68008. * Gets or sets bone length
  68009. */
  68010. length: number;
  68011. /**
  68012. * @hidden Internal only
  68013. * Set this value to map this bone to a different index in the transform matrices
  68014. * Set this value to -1 to exclude the bone from the transform matrices
  68015. */
  68016. _index: Nullable<number>;
  68017. private _skeleton;
  68018. private _localMatrix;
  68019. private _restPose;
  68020. private _baseMatrix;
  68021. private _absoluteTransform;
  68022. private _invertedAbsoluteTransform;
  68023. private _parent;
  68024. private _scalingDeterminant;
  68025. private _worldTransform;
  68026. private _localScaling;
  68027. private _localRotation;
  68028. private _localPosition;
  68029. private _needToDecompose;
  68030. private _needToCompose;
  68031. /** @hidden */
  68032. _linkedTransformNode: Nullable<TransformNode>;
  68033. /** @hidden */
  68034. _waitingTransformNodeId: Nullable<string>;
  68035. /** @hidden */
  68036. /** @hidden */
  68037. _matrix: Matrix;
  68038. /**
  68039. * Create a new bone
  68040. * @param name defines the bone name
  68041. * @param skeleton defines the parent skeleton
  68042. * @param parentBone defines the parent (can be null if the bone is the root)
  68043. * @param localMatrix defines the local matrix
  68044. * @param restPose defines the rest pose matrix
  68045. * @param baseMatrix defines the base matrix
  68046. * @param index defines index of the bone in the hiearchy
  68047. */
  68048. constructor(
  68049. /**
  68050. * defines the bone name
  68051. */
  68052. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  68053. /**
  68054. * Gets the current object class name.
  68055. * @return the class name
  68056. */
  68057. getClassName(): string;
  68058. /**
  68059. * Gets the parent skeleton
  68060. * @returns a skeleton
  68061. */
  68062. getSkeleton(): Skeleton;
  68063. /**
  68064. * Gets parent bone
  68065. * @returns a bone or null if the bone is the root of the bone hierarchy
  68066. */
  68067. getParent(): Nullable<Bone>;
  68068. /**
  68069. * Returns an array containing the root bones
  68070. * @returns an array containing the root bones
  68071. */
  68072. getChildren(): Array<Bone>;
  68073. /**
  68074. * Sets the parent bone
  68075. * @param parent defines the parent (can be null if the bone is the root)
  68076. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  68077. */
  68078. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  68079. /**
  68080. * Gets the local matrix
  68081. * @returns a matrix
  68082. */
  68083. getLocalMatrix(): Matrix;
  68084. /**
  68085. * Gets the base matrix (initial matrix which remains unchanged)
  68086. * @returns a matrix
  68087. */
  68088. getBaseMatrix(): Matrix;
  68089. /**
  68090. * Gets the rest pose matrix
  68091. * @returns a matrix
  68092. */
  68093. getRestPose(): Matrix;
  68094. /**
  68095. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  68096. */
  68097. getWorldMatrix(): Matrix;
  68098. /**
  68099. * Sets the local matrix to rest pose matrix
  68100. */
  68101. returnToRest(): void;
  68102. /**
  68103. * Gets the inverse of the absolute transform matrix.
  68104. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  68105. * @returns a matrix
  68106. */
  68107. getInvertedAbsoluteTransform(): Matrix;
  68108. /**
  68109. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  68110. * @returns a matrix
  68111. */
  68112. getAbsoluteTransform(): Matrix;
  68113. /**
  68114. * Links with the given transform node.
  68115. * The local matrix of this bone is copied from the transform node every frame.
  68116. * @param transformNode defines the transform node to link to
  68117. */
  68118. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  68119. /** Gets or sets current position (in local space) */
  68120. position: Vector3;
  68121. /** Gets or sets current rotation (in local space) */
  68122. rotation: Vector3;
  68123. /** Gets or sets current rotation quaternion (in local space) */
  68124. rotationQuaternion: Quaternion;
  68125. /** Gets or sets current scaling (in local space) */
  68126. scaling: Vector3;
  68127. /**
  68128. * Gets the animation properties override
  68129. */
  68130. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  68131. private _decompose;
  68132. private _compose;
  68133. /**
  68134. * Update the base and local matrices
  68135. * @param matrix defines the new base or local matrix
  68136. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  68137. * @param updateLocalMatrix defines if the local matrix should be updated
  68138. */
  68139. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  68140. /** @hidden */
  68141. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  68142. /**
  68143. * Flag the bone as dirty (Forcing it to update everything)
  68144. */
  68145. markAsDirty(): void;
  68146. private _markAsDirtyAndCompose;
  68147. private _markAsDirtyAndDecompose;
  68148. /**
  68149. * Translate the bone in local or world space
  68150. * @param vec The amount to translate the bone
  68151. * @param space The space that the translation is in
  68152. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68153. */
  68154. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68155. /**
  68156. * Set the postion of the bone in local or world space
  68157. * @param position The position to set the bone
  68158. * @param space The space that the position is in
  68159. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68160. */
  68161. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68162. /**
  68163. * Set the absolute position of the bone (world space)
  68164. * @param position The position to set the bone
  68165. * @param mesh The mesh that this bone is attached to
  68166. */
  68167. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  68168. /**
  68169. * Scale the bone on the x, y and z axes (in local space)
  68170. * @param x The amount to scale the bone on the x axis
  68171. * @param y The amount to scale the bone on the y axis
  68172. * @param z The amount to scale the bone on the z axis
  68173. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  68174. */
  68175. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  68176. /**
  68177. * Set the bone scaling in local space
  68178. * @param scale defines the scaling vector
  68179. */
  68180. setScale(scale: Vector3): void;
  68181. /**
  68182. * Gets the current scaling in local space
  68183. * @returns the current scaling vector
  68184. */
  68185. getScale(): Vector3;
  68186. /**
  68187. * Gets the current scaling in local space and stores it in a target vector
  68188. * @param result defines the target vector
  68189. */
  68190. getScaleToRef(result: Vector3): void;
  68191. /**
  68192. * Set the yaw, pitch, and roll of the bone in local or world space
  68193. * @param yaw The rotation of the bone on the y axis
  68194. * @param pitch The rotation of the bone on the x axis
  68195. * @param roll The rotation of the bone on the z axis
  68196. * @param space The space that the axes of rotation are in
  68197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68198. */
  68199. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  68200. /**
  68201. * Add a rotation to the bone on an axis in local or world space
  68202. * @param axis The axis to rotate the bone on
  68203. * @param amount The amount to rotate the bone
  68204. * @param space The space that the axis is in
  68205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68206. */
  68207. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  68208. /**
  68209. * Set the rotation of the bone to a particular axis angle in local or world space
  68210. * @param axis The axis to rotate the bone on
  68211. * @param angle The angle that the bone should be rotated to
  68212. * @param space The space that the axis is in
  68213. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68214. */
  68215. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  68216. /**
  68217. * Set the euler rotation of the bone in local of world space
  68218. * @param rotation The euler rotation that the bone should be set to
  68219. * @param space The space that the rotation is in
  68220. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68221. */
  68222. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68223. /**
  68224. * Set the quaternion rotation of the bone in local of world space
  68225. * @param quat The quaternion rotation that the bone should be set to
  68226. * @param space The space that the rotation is in
  68227. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68228. */
  68229. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  68230. /**
  68231. * Set the rotation matrix of the bone in local of world space
  68232. * @param rotMat The rotation matrix that the bone should be set to
  68233. * @param space The space that the rotation is in
  68234. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68235. */
  68236. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  68237. private _rotateWithMatrix;
  68238. private _getNegativeRotationToRef;
  68239. /**
  68240. * Get the position of the bone in local or world space
  68241. * @param space The space that the returned position is in
  68242. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68243. * @returns The position of the bone
  68244. */
  68245. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68246. /**
  68247. * Copy the position of the bone to a vector3 in local or world space
  68248. * @param space The space that the returned position is in
  68249. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68250. * @param result The vector3 to copy the position to
  68251. */
  68252. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  68253. /**
  68254. * Get the absolute position of the bone (world space)
  68255. * @param mesh The mesh that this bone is attached to
  68256. * @returns The absolute position of the bone
  68257. */
  68258. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  68259. /**
  68260. * Copy the absolute position of the bone (world space) to the result param
  68261. * @param mesh The mesh that this bone is attached to
  68262. * @param result The vector3 to copy the absolute position to
  68263. */
  68264. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  68265. /**
  68266. * Compute the absolute transforms of this bone and its children
  68267. */
  68268. computeAbsoluteTransforms(): void;
  68269. /**
  68270. * Get the world direction from an axis that is in the local space of the bone
  68271. * @param localAxis The local direction that is used to compute the world direction
  68272. * @param mesh The mesh that this bone is attached to
  68273. * @returns The world direction
  68274. */
  68275. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68276. /**
  68277. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  68278. * @param localAxis The local direction that is used to compute the world direction
  68279. * @param mesh The mesh that this bone is attached to
  68280. * @param result The vector3 that the world direction will be copied to
  68281. */
  68282. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68283. /**
  68284. * Get the euler rotation of the bone in local or world space
  68285. * @param space The space that the rotation should be in
  68286. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68287. * @returns The euler rotation
  68288. */
  68289. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68290. /**
  68291. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  68292. * @param space The space that the rotation should be in
  68293. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68294. * @param result The vector3 that the rotation should be copied to
  68295. */
  68296. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68297. /**
  68298. * Get the quaternion rotation of the bone in either local or world space
  68299. * @param space The space that the rotation should be in
  68300. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68301. * @returns The quaternion rotation
  68302. */
  68303. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  68304. /**
  68305. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  68306. * @param space The space that the rotation should be in
  68307. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68308. * @param result The quaternion that the rotation should be copied to
  68309. */
  68310. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  68311. /**
  68312. * Get the rotation matrix of the bone in local or world space
  68313. * @param space The space that the rotation should be in
  68314. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68315. * @returns The rotation matrix
  68316. */
  68317. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  68318. /**
  68319. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  68320. * @param space The space that the rotation should be in
  68321. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68322. * @param result The quaternion that the rotation should be copied to
  68323. */
  68324. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  68325. /**
  68326. * Get the world position of a point that is in the local space of the bone
  68327. * @param position The local position
  68328. * @param mesh The mesh that this bone is attached to
  68329. * @returns The world position
  68330. */
  68331. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68332. /**
  68333. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  68334. * @param position The local position
  68335. * @param mesh The mesh that this bone is attached to
  68336. * @param result The vector3 that the world position should be copied to
  68337. */
  68338. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68339. /**
  68340. * Get the local position of a point that is in world space
  68341. * @param position The world position
  68342. * @param mesh The mesh that this bone is attached to
  68343. * @returns The local position
  68344. */
  68345. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68346. /**
  68347. * Get the local position of a point that is in world space and copy it to the result param
  68348. * @param position The world position
  68349. * @param mesh The mesh that this bone is attached to
  68350. * @param result The vector3 that the local position should be copied to
  68351. */
  68352. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68353. }
  68354. }
  68355. declare module BABYLON {
  68356. /**
  68357. * Enum that determines the text-wrapping mode to use.
  68358. */
  68359. export enum InspectableType {
  68360. /**
  68361. * Checkbox for booleans
  68362. */
  68363. Checkbox = 0,
  68364. /**
  68365. * Sliders for numbers
  68366. */
  68367. Slider = 1,
  68368. /**
  68369. * Vector3
  68370. */
  68371. Vector3 = 2,
  68372. /**
  68373. * Quaternions
  68374. */
  68375. Quaternion = 3,
  68376. /**
  68377. * Color3
  68378. */
  68379. Color3 = 4
  68380. }
  68381. /**
  68382. * Interface used to define custom inspectable properties.
  68383. * This interface is used by the inspector to display custom property grids
  68384. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68385. */
  68386. export interface IInspectable {
  68387. /**
  68388. * Gets the label to display
  68389. */
  68390. label: string;
  68391. /**
  68392. * Gets the name of the property to edit
  68393. */
  68394. propertyName: string;
  68395. /**
  68396. * Gets the type of the editor to use
  68397. */
  68398. type: InspectableType;
  68399. /**
  68400. * Gets the minimum value of the property when using in "slider" mode
  68401. */
  68402. min?: number;
  68403. /**
  68404. * Gets the maximum value of the property when using in "slider" mode
  68405. */
  68406. max?: number;
  68407. /**
  68408. * Gets the setp to use when using in "slider" mode
  68409. */
  68410. step?: number;
  68411. }
  68412. }
  68413. declare module BABYLON {
  68414. /**
  68415. * This represents the required contract to create a new type of texture loader.
  68416. */
  68417. export interface IInternalTextureLoader {
  68418. /**
  68419. * Defines wether the loader supports cascade loading the different faces.
  68420. */
  68421. supportCascades: boolean;
  68422. /**
  68423. * This returns if the loader support the current file information.
  68424. * @param extension defines the file extension of the file being loaded
  68425. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68426. * @param fallback defines the fallback internal texture if any
  68427. * @param isBase64 defines whether the texture is encoded as a base64
  68428. * @param isBuffer defines whether the texture data are stored as a buffer
  68429. * @returns true if the loader can load the specified file
  68430. */
  68431. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68432. /**
  68433. * Transform the url before loading if required.
  68434. * @param rootUrl the url of the texture
  68435. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68436. * @returns the transformed texture
  68437. */
  68438. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68439. /**
  68440. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68441. * @param rootUrl the url of the texture
  68442. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68443. * @returns the fallback texture
  68444. */
  68445. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68446. /**
  68447. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68448. * @param data contains the texture data
  68449. * @param texture defines the BabylonJS internal texture
  68450. * @param createPolynomials will be true if polynomials have been requested
  68451. * @param onLoad defines the callback to trigger once the texture is ready
  68452. * @param onError defines the callback to trigger in case of error
  68453. */
  68454. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68455. /**
  68456. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68457. * @param data contains the texture data
  68458. * @param texture defines the BabylonJS internal texture
  68459. * @param callback defines the method to call once ready to upload
  68460. */
  68461. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68462. }
  68463. }
  68464. declare module BABYLON {
  68465. interface Engine {
  68466. /**
  68467. * Creates a depth stencil cube texture.
  68468. * This is only available in WebGL 2.
  68469. * @param size The size of face edge in the cube texture.
  68470. * @param options The options defining the cube texture.
  68471. * @returns The cube texture
  68472. */
  68473. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  68474. /**
  68475. * Creates a cube texture
  68476. * @param rootUrl defines the url where the files to load is located
  68477. * @param scene defines the current scene
  68478. * @param files defines the list of files to load (1 per face)
  68479. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68480. * @param onLoad defines an optional callback raised when the texture is loaded
  68481. * @param onError defines an optional callback raised if there is an issue to load the texture
  68482. * @param format defines the format of the data
  68483. * @param forcedExtension defines the extension to use to pick the right loader
  68484. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68485. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68486. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68487. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  68488. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  68489. * @returns the cube texture as an InternalTexture
  68490. */
  68491. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  68492. /**
  68493. * Creates a cube texture
  68494. * @param rootUrl defines the url where the files to load is located
  68495. * @param scene defines the current scene
  68496. * @param files defines the list of files to load (1 per face)
  68497. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68498. * @param onLoad defines an optional callback raised when the texture is loaded
  68499. * @param onError defines an optional callback raised if there is an issue to load the texture
  68500. * @param format defines the format of the data
  68501. * @param forcedExtension defines the extension to use to pick the right loader
  68502. * @returns the cube texture as an InternalTexture
  68503. */
  68504. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  68505. /**
  68506. * Creates a cube texture
  68507. * @param rootUrl defines the url where the files to load is located
  68508. * @param scene defines the current scene
  68509. * @param files defines the list of files to load (1 per face)
  68510. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68511. * @param onLoad defines an optional callback raised when the texture is loaded
  68512. * @param onError defines an optional callback raised if there is an issue to load the texture
  68513. * @param format defines the format of the data
  68514. * @param forcedExtension defines the extension to use to pick the right loader
  68515. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68516. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68517. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68518. * @returns the cube texture as an InternalTexture
  68519. */
  68520. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  68521. /** @hidden */
  68522. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68523. /** @hidden */
  68524. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68525. /** @hidden */
  68526. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68527. /** @hidden */
  68528. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68529. }
  68530. }
  68531. declare module BABYLON {
  68532. /**
  68533. * Class for creating a cube texture
  68534. */
  68535. export class CubeTexture extends BaseTexture {
  68536. private _delayedOnLoad;
  68537. /**
  68538. * The url of the texture
  68539. */
  68540. url: string;
  68541. /**
  68542. * Gets or sets the center of the bounding box associated with the cube texture.
  68543. * It must define where the camera used to render the texture was set
  68544. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68545. */
  68546. boundingBoxPosition: Vector3;
  68547. private _boundingBoxSize;
  68548. /**
  68549. * Gets or sets the size of the bounding box associated with the cube texture
  68550. * When defined, the cubemap will switch to local mode
  68551. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  68552. * @example https://www.babylonjs-playground.com/#RNASML
  68553. */
  68554. /**
  68555. * Returns the bounding box size
  68556. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68557. */
  68558. boundingBoxSize: Vector3;
  68559. protected _rotationY: number;
  68560. /**
  68561. * Sets texture matrix rotation angle around Y axis in radians.
  68562. */
  68563. /**
  68564. * Gets texture matrix rotation angle around Y axis radians.
  68565. */
  68566. rotationY: number;
  68567. /**
  68568. * Are mip maps generated for this texture or not.
  68569. */
  68570. readonly noMipmap: boolean;
  68571. private _noMipmap;
  68572. private _files;
  68573. private _extensions;
  68574. private _textureMatrix;
  68575. private _format;
  68576. private _createPolynomials;
  68577. /** @hidden */
  68578. _prefiltered: boolean;
  68579. /**
  68580. * Creates a cube texture from an array of image urls
  68581. * @param files defines an array of image urls
  68582. * @param scene defines the hosting scene
  68583. * @param noMipmap specifies if mip maps are not used
  68584. * @returns a cube texture
  68585. */
  68586. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  68587. /**
  68588. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  68589. * @param url defines the url of the prefiltered texture
  68590. * @param scene defines the scene the texture is attached to
  68591. * @param forcedExtension defines the extension of the file if different from the url
  68592. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68593. * @return the prefiltered texture
  68594. */
  68595. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  68596. /**
  68597. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  68598. * as prefiltered data.
  68599. * @param rootUrl defines the url of the texture or the root name of the six images
  68600. * @param scene defines the scene the texture is attached to
  68601. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  68602. * @param noMipmap defines if mipmaps should be created or not
  68603. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  68604. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  68605. * @param onError defines a callback triggered in case of error during load
  68606. * @param format defines the internal format to use for the texture once loaded
  68607. * @param prefiltered defines whether or not the texture is created from prefiltered data
  68608. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  68609. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68610. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68611. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68612. * @return the cube texture
  68613. */
  68614. 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);
  68615. /**
  68616. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  68617. */
  68618. readonly isPrefiltered: boolean;
  68619. /**
  68620. * Get the current class name of the texture useful for serialization or dynamic coding.
  68621. * @returns "CubeTexture"
  68622. */
  68623. getClassName(): string;
  68624. /**
  68625. * Update the url (and optional buffer) of this texture if url was null during construction.
  68626. * @param url the url of the texture
  68627. * @param forcedExtension defines the extension to use
  68628. * @param onLoad callback called when the texture is loaded (defaults to null)
  68629. */
  68630. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  68631. /**
  68632. * Delays loading of the cube texture
  68633. * @param forcedExtension defines the extension to use
  68634. */
  68635. delayLoad(forcedExtension?: string): void;
  68636. /**
  68637. * Returns the reflection texture matrix
  68638. * @returns the reflection texture matrix
  68639. */
  68640. getReflectionTextureMatrix(): Matrix;
  68641. /**
  68642. * Sets the reflection texture matrix
  68643. * @param value Reflection texture matrix
  68644. */
  68645. setReflectionTextureMatrix(value: Matrix): void;
  68646. /**
  68647. * Parses text to create a cube texture
  68648. * @param parsedTexture define the serialized text to read from
  68649. * @param scene defines the hosting scene
  68650. * @param rootUrl defines the root url of the cube texture
  68651. * @returns a cube texture
  68652. */
  68653. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  68654. /**
  68655. * Makes a clone, or deep copy, of the cube texture
  68656. * @returns a new cube texture
  68657. */
  68658. clone(): CubeTexture;
  68659. }
  68660. }
  68661. declare module BABYLON {
  68662. /** @hidden */
  68663. export var postprocessVertexShader: {
  68664. name: string;
  68665. shader: string;
  68666. };
  68667. }
  68668. declare module BABYLON {
  68669. /**
  68670. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  68671. * This is the base of the follow, arc rotate cameras and Free camera
  68672. * @see http://doc.babylonjs.com/features/cameras
  68673. */
  68674. export class TargetCamera extends Camera {
  68675. private static _RigCamTransformMatrix;
  68676. private static _TargetTransformMatrix;
  68677. private static _TargetFocalPoint;
  68678. /**
  68679. * Define the current direction the camera is moving to
  68680. */
  68681. cameraDirection: Vector3;
  68682. /**
  68683. * Define the current rotation the camera is rotating to
  68684. */
  68685. cameraRotation: Vector2;
  68686. /**
  68687. * When set, the up vector of the camera will be updated by the rotation of the camera
  68688. */
  68689. updateUpVectorFromRotation: boolean;
  68690. private _tmpQuaternion;
  68691. /**
  68692. * Define the current rotation of the camera
  68693. */
  68694. rotation: Vector3;
  68695. /**
  68696. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  68697. */
  68698. rotationQuaternion: Quaternion;
  68699. /**
  68700. * Define the current speed of the camera
  68701. */
  68702. speed: number;
  68703. /**
  68704. * Add cconstraint to the camera to prevent it to move freely in all directions and
  68705. * around all axis.
  68706. */
  68707. noRotationConstraint: boolean;
  68708. /**
  68709. * Define the current target of the camera as an object or a position.
  68710. */
  68711. lockedTarget: any;
  68712. /** @hidden */
  68713. _currentTarget: Vector3;
  68714. /** @hidden */
  68715. _initialFocalDistance: number;
  68716. /** @hidden */
  68717. _viewMatrix: Matrix;
  68718. /** @hidden */
  68719. _camMatrix: Matrix;
  68720. /** @hidden */
  68721. _cameraTransformMatrix: Matrix;
  68722. /** @hidden */
  68723. _cameraRotationMatrix: Matrix;
  68724. /** @hidden */
  68725. _referencePoint: Vector3;
  68726. /** @hidden */
  68727. _transformedReferencePoint: Vector3;
  68728. protected _globalCurrentTarget: Vector3;
  68729. protected _globalCurrentUpVector: Vector3;
  68730. /** @hidden */
  68731. _reset: () => void;
  68732. private _defaultUp;
  68733. /**
  68734. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  68735. * This is the base of the follow, arc rotate cameras and Free camera
  68736. * @see http://doc.babylonjs.com/features/cameras
  68737. * @param name Defines the name of the camera in the scene
  68738. * @param position Defines the start position of the camera in the scene
  68739. * @param scene Defines the scene the camera belongs to
  68740. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68741. */
  68742. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68743. /**
  68744. * Gets the position in front of the camera at a given distance.
  68745. * @param distance The distance from the camera we want the position to be
  68746. * @returns the position
  68747. */
  68748. getFrontPosition(distance: number): Vector3;
  68749. /** @hidden */
  68750. _getLockedTargetPosition(): Nullable<Vector3>;
  68751. private _storedPosition;
  68752. private _storedRotation;
  68753. private _storedRotationQuaternion;
  68754. /**
  68755. * Store current camera state of the camera (fov, position, rotation, etc..)
  68756. * @returns the camera
  68757. */
  68758. storeState(): Camera;
  68759. /**
  68760. * Restored camera state. You must call storeState() first
  68761. * @returns whether it was successful or not
  68762. * @hidden
  68763. */
  68764. _restoreStateValues(): boolean;
  68765. /** @hidden */
  68766. _initCache(): void;
  68767. /** @hidden */
  68768. _updateCache(ignoreParentClass?: boolean): void;
  68769. /** @hidden */
  68770. _isSynchronizedViewMatrix(): boolean;
  68771. /** @hidden */
  68772. _computeLocalCameraSpeed(): number;
  68773. /**
  68774. * Defines the target the camera should look at.
  68775. * This will automatically adapt alpha beta and radius to fit within the new target.
  68776. * @param target Defines the new target as a Vector or a mesh
  68777. */
  68778. setTarget(target: Vector3): void;
  68779. /**
  68780. * Return the current target position of the camera. This value is expressed in local space.
  68781. * @returns the target position
  68782. */
  68783. getTarget(): Vector3;
  68784. /** @hidden */
  68785. _decideIfNeedsToMove(): boolean;
  68786. /** @hidden */
  68787. _updatePosition(): void;
  68788. /** @hidden */
  68789. _checkInputs(): void;
  68790. protected _updateCameraRotationMatrix(): void;
  68791. /**
  68792. * 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)
  68793. * @returns the current camera
  68794. */
  68795. private _rotateUpVectorWithCameraRotationMatrix;
  68796. private _cachedRotationZ;
  68797. private _cachedQuaternionRotationZ;
  68798. /** @hidden */
  68799. _getViewMatrix(): Matrix;
  68800. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  68801. /**
  68802. * @hidden
  68803. */
  68804. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  68805. /**
  68806. * @hidden
  68807. */
  68808. _updateRigCameras(): void;
  68809. private _getRigCamPositionAndTarget;
  68810. /**
  68811. * Gets the current object class name.
  68812. * @return the class name
  68813. */
  68814. getClassName(): string;
  68815. }
  68816. }
  68817. declare module BABYLON {
  68818. /**
  68819. * @ignore
  68820. * This is a list of all the different input types that are available in the application.
  68821. * Fo instance: ArcRotateCameraGamepadInput...
  68822. */
  68823. export var CameraInputTypes: {};
  68824. /**
  68825. * This is the contract to implement in order to create a new input class.
  68826. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  68827. */
  68828. export interface ICameraInput<TCamera extends Camera> {
  68829. /**
  68830. * Defines the camera the input is attached to.
  68831. */
  68832. camera: Nullable<TCamera>;
  68833. /**
  68834. * Gets the class name of the current intput.
  68835. * @returns the class name
  68836. */
  68837. getClassName(): string;
  68838. /**
  68839. * Get the friendly name associated with the input class.
  68840. * @returns the input friendly name
  68841. */
  68842. getSimpleName(): string;
  68843. /**
  68844. * Attach the input controls to a specific dom element to get the input from.
  68845. * @param element Defines the element the controls should be listened from
  68846. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68847. */
  68848. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68849. /**
  68850. * Detach the current controls from the specified dom element.
  68851. * @param element Defines the element to stop listening the inputs from
  68852. */
  68853. detachControl(element: Nullable<HTMLElement>): void;
  68854. /**
  68855. * Update the current camera state depending on the inputs that have been used this frame.
  68856. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68857. */
  68858. checkInputs?: () => void;
  68859. }
  68860. /**
  68861. * Represents a map of input types to input instance or input index to input instance.
  68862. */
  68863. export interface CameraInputsMap<TCamera extends Camera> {
  68864. /**
  68865. * Accessor to the input by input type.
  68866. */
  68867. [name: string]: ICameraInput<TCamera>;
  68868. /**
  68869. * Accessor to the input by input index.
  68870. */
  68871. [idx: number]: ICameraInput<TCamera>;
  68872. }
  68873. /**
  68874. * This represents the input manager used within a camera.
  68875. * It helps dealing with all the different kind of input attached to a camera.
  68876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68877. */
  68878. export class CameraInputsManager<TCamera extends Camera> {
  68879. /**
  68880. * Defines the list of inputs attahed to the camera.
  68881. */
  68882. attached: CameraInputsMap<TCamera>;
  68883. /**
  68884. * Defines the dom element the camera is collecting inputs from.
  68885. * This is null if the controls have not been attached.
  68886. */
  68887. attachedElement: Nullable<HTMLElement>;
  68888. /**
  68889. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68890. */
  68891. noPreventDefault: boolean;
  68892. /**
  68893. * Defined the camera the input manager belongs to.
  68894. */
  68895. camera: TCamera;
  68896. /**
  68897. * Update the current camera state depending on the inputs that have been used this frame.
  68898. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68899. */
  68900. checkInputs: () => void;
  68901. /**
  68902. * Instantiate a new Camera Input Manager.
  68903. * @param camera Defines the camera the input manager blongs to
  68904. */
  68905. constructor(camera: TCamera);
  68906. /**
  68907. * Add an input method to a camera
  68908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68909. * @param input camera input method
  68910. */
  68911. add(input: ICameraInput<TCamera>): void;
  68912. /**
  68913. * Remove a specific input method from a camera
  68914. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68915. * @param inputToRemove camera input method
  68916. */
  68917. remove(inputToRemove: ICameraInput<TCamera>): void;
  68918. /**
  68919. * Remove a specific input type from a camera
  68920. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68921. * @param inputType the type of the input to remove
  68922. */
  68923. removeByType(inputType: string): void;
  68924. private _addCheckInputs;
  68925. /**
  68926. * Attach the input controls to the currently attached dom element to listen the events from.
  68927. * @param input Defines the input to attach
  68928. */
  68929. attachInput(input: ICameraInput<TCamera>): void;
  68930. /**
  68931. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68932. * @param element Defines the dom element to collect the events from
  68933. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68934. */
  68935. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68936. /**
  68937. * Detach the current manager inputs controls from a specific dom element.
  68938. * @param element Defines the dom element to collect the events from
  68939. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68940. */
  68941. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68942. /**
  68943. * Rebuild the dynamic inputCheck function from the current list of
  68944. * defined inputs in the manager.
  68945. */
  68946. rebuildInputCheck(): void;
  68947. /**
  68948. * Remove all attached input methods from a camera
  68949. */
  68950. clear(): void;
  68951. /**
  68952. * Serialize the current input manager attached to a camera.
  68953. * This ensures than once parsed,
  68954. * the input associated to the camera will be identical to the current ones
  68955. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68956. */
  68957. serialize(serializedCamera: any): void;
  68958. /**
  68959. * Parses an input manager serialized JSON to restore the previous list of inputs
  68960. * and states associated to a camera.
  68961. * @param parsedCamera Defines the JSON to parse
  68962. */
  68963. parse(parsedCamera: any): void;
  68964. }
  68965. }
  68966. declare module BABYLON {
  68967. /**
  68968. * Gather the list of keyboard event types as constants.
  68969. */
  68970. export class KeyboardEventTypes {
  68971. /**
  68972. * The keydown event is fired when a key becomes active (pressed).
  68973. */
  68974. static readonly KEYDOWN: number;
  68975. /**
  68976. * The keyup event is fired when a key has been released.
  68977. */
  68978. static readonly KEYUP: number;
  68979. }
  68980. /**
  68981. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68982. */
  68983. export class KeyboardInfo {
  68984. /**
  68985. * Defines the type of event (KeyboardEventTypes)
  68986. */
  68987. type: number;
  68988. /**
  68989. * Defines the related dom event
  68990. */
  68991. event: KeyboardEvent;
  68992. /**
  68993. * Instantiates a new keyboard info.
  68994. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68995. * @param type Defines the type of event (KeyboardEventTypes)
  68996. * @param event Defines the related dom event
  68997. */
  68998. constructor(
  68999. /**
  69000. * Defines the type of event (KeyboardEventTypes)
  69001. */
  69002. type: number,
  69003. /**
  69004. * Defines the related dom event
  69005. */
  69006. event: KeyboardEvent);
  69007. }
  69008. /**
  69009. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  69010. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  69011. */
  69012. export class KeyboardInfoPre extends KeyboardInfo {
  69013. /**
  69014. * Defines the type of event (KeyboardEventTypes)
  69015. */
  69016. type: number;
  69017. /**
  69018. * Defines the related dom event
  69019. */
  69020. event: KeyboardEvent;
  69021. /**
  69022. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  69023. */
  69024. skipOnPointerObservable: boolean;
  69025. /**
  69026. * Instantiates a new keyboard pre info.
  69027. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  69028. * @param type Defines the type of event (KeyboardEventTypes)
  69029. * @param event Defines the related dom event
  69030. */
  69031. constructor(
  69032. /**
  69033. * Defines the type of event (KeyboardEventTypes)
  69034. */
  69035. type: number,
  69036. /**
  69037. * Defines the related dom event
  69038. */
  69039. event: KeyboardEvent);
  69040. }
  69041. }
  69042. declare module BABYLON {
  69043. /**
  69044. * Manage the keyboard inputs to control the movement of a free camera.
  69045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69046. */
  69047. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  69048. /**
  69049. * Defines the camera the input is attached to.
  69050. */
  69051. camera: FreeCamera;
  69052. /**
  69053. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  69054. */
  69055. keysUp: number[];
  69056. /**
  69057. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  69058. */
  69059. keysDown: number[];
  69060. /**
  69061. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  69062. */
  69063. keysLeft: number[];
  69064. /**
  69065. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  69066. */
  69067. keysRight: number[];
  69068. private _keys;
  69069. private _onCanvasBlurObserver;
  69070. private _onKeyboardObserver;
  69071. private _engine;
  69072. private _scene;
  69073. /**
  69074. * Attach the input controls to a specific dom element to get the input from.
  69075. * @param element Defines the element the controls should be listened from
  69076. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69077. */
  69078. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69079. /**
  69080. * Detach the current controls from the specified dom element.
  69081. * @param element Defines the element to stop listening the inputs from
  69082. */
  69083. detachControl(element: Nullable<HTMLElement>): void;
  69084. /**
  69085. * Update the current camera state depending on the inputs that have been used this frame.
  69086. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69087. */
  69088. checkInputs(): void;
  69089. /**
  69090. * Gets the class name of the current intput.
  69091. * @returns the class name
  69092. */
  69093. getClassName(): string;
  69094. /** @hidden */
  69095. _onLostFocus(): void;
  69096. /**
  69097. * Get the friendly name associated with the input class.
  69098. * @returns the input friendly name
  69099. */
  69100. getSimpleName(): string;
  69101. }
  69102. }
  69103. declare module BABYLON {
  69104. /**
  69105. * Interface describing all the common properties and methods a shadow light needs to implement.
  69106. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  69107. * as well as binding the different shadow properties to the effects.
  69108. */
  69109. export interface IShadowLight extends Light {
  69110. /**
  69111. * The light id in the scene (used in scene.findLighById for instance)
  69112. */
  69113. id: string;
  69114. /**
  69115. * The position the shdow will be casted from.
  69116. */
  69117. position: Vector3;
  69118. /**
  69119. * In 2d mode (needCube being false), the direction used to cast the shadow.
  69120. */
  69121. direction: Vector3;
  69122. /**
  69123. * The transformed position. Position of the light in world space taking parenting in account.
  69124. */
  69125. transformedPosition: Vector3;
  69126. /**
  69127. * The transformed direction. Direction of the light in world space taking parenting in account.
  69128. */
  69129. transformedDirection: Vector3;
  69130. /**
  69131. * The friendly name of the light in the scene.
  69132. */
  69133. name: string;
  69134. /**
  69135. * Defines the shadow projection clipping minimum z value.
  69136. */
  69137. shadowMinZ: number;
  69138. /**
  69139. * Defines the shadow projection clipping maximum z value.
  69140. */
  69141. shadowMaxZ: number;
  69142. /**
  69143. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69144. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69145. */
  69146. computeTransformedInformation(): boolean;
  69147. /**
  69148. * Gets the scene the light belongs to.
  69149. * @returns The scene
  69150. */
  69151. getScene(): Scene;
  69152. /**
  69153. * Callback defining a custom Projection Matrix Builder.
  69154. * This can be used to override the default projection matrix computation.
  69155. */
  69156. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69157. /**
  69158. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69159. * @param matrix The materix to updated with the projection information
  69160. * @param viewMatrix The transform matrix of the light
  69161. * @param renderList The list of mesh to render in the map
  69162. * @returns The current light
  69163. */
  69164. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69165. /**
  69166. * Gets the current depth scale used in ESM.
  69167. * @returns The scale
  69168. */
  69169. getDepthScale(): number;
  69170. /**
  69171. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69172. * @returns true if a cube texture needs to be use
  69173. */
  69174. needCube(): boolean;
  69175. /**
  69176. * Detects if the projection matrix requires to be recomputed this frame.
  69177. * @returns true if it requires to be recomputed otherwise, false.
  69178. */
  69179. needProjectionMatrixCompute(): boolean;
  69180. /**
  69181. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69182. */
  69183. forceProjectionMatrixCompute(): void;
  69184. /**
  69185. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69186. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69187. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69188. */
  69189. getShadowDirection(faceIndex?: number): Vector3;
  69190. /**
  69191. * Gets the minZ used for shadow according to both the scene and the light.
  69192. * @param activeCamera The camera we are returning the min for
  69193. * @returns the depth min z
  69194. */
  69195. getDepthMinZ(activeCamera: Camera): number;
  69196. /**
  69197. * Gets the maxZ used for shadow according to both the scene and the light.
  69198. * @param activeCamera The camera we are returning the max for
  69199. * @returns the depth max z
  69200. */
  69201. getDepthMaxZ(activeCamera: Camera): number;
  69202. }
  69203. /**
  69204. * Base implementation IShadowLight
  69205. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  69206. */
  69207. export abstract class ShadowLight extends Light implements IShadowLight {
  69208. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  69209. protected _position: Vector3;
  69210. protected _setPosition(value: Vector3): void;
  69211. /**
  69212. * Sets the position the shadow will be casted from. Also use as the light position for both
  69213. * point and spot lights.
  69214. */
  69215. /**
  69216. * Sets the position the shadow will be casted from. Also use as the light position for both
  69217. * point and spot lights.
  69218. */
  69219. position: Vector3;
  69220. protected _direction: Vector3;
  69221. protected _setDirection(value: Vector3): void;
  69222. /**
  69223. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  69224. * Also use as the light direction on spot and directional lights.
  69225. */
  69226. /**
  69227. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  69228. * Also use as the light direction on spot and directional lights.
  69229. */
  69230. direction: Vector3;
  69231. private _shadowMinZ;
  69232. /**
  69233. * Gets the shadow projection clipping minimum z value.
  69234. */
  69235. /**
  69236. * Sets the shadow projection clipping minimum z value.
  69237. */
  69238. shadowMinZ: number;
  69239. private _shadowMaxZ;
  69240. /**
  69241. * Sets the shadow projection clipping maximum z value.
  69242. */
  69243. /**
  69244. * Gets the shadow projection clipping maximum z value.
  69245. */
  69246. shadowMaxZ: number;
  69247. /**
  69248. * Callback defining a custom Projection Matrix Builder.
  69249. * This can be used to override the default projection matrix computation.
  69250. */
  69251. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69252. /**
  69253. * The transformed position. Position of the light in world space taking parenting in account.
  69254. */
  69255. transformedPosition: Vector3;
  69256. /**
  69257. * The transformed direction. Direction of the light in world space taking parenting in account.
  69258. */
  69259. transformedDirection: Vector3;
  69260. private _needProjectionMatrixCompute;
  69261. /**
  69262. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69263. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69264. */
  69265. computeTransformedInformation(): boolean;
  69266. /**
  69267. * Return the depth scale used for the shadow map.
  69268. * @returns the depth scale.
  69269. */
  69270. getDepthScale(): number;
  69271. /**
  69272. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69273. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69274. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69275. */
  69276. getShadowDirection(faceIndex?: number): Vector3;
  69277. /**
  69278. * Returns the ShadowLight absolute position in the World.
  69279. * @returns the position vector in world space
  69280. */
  69281. getAbsolutePosition(): Vector3;
  69282. /**
  69283. * Sets the ShadowLight direction toward the passed target.
  69284. * @param target The point to target in local space
  69285. * @returns the updated ShadowLight direction
  69286. */
  69287. setDirectionToTarget(target: Vector3): Vector3;
  69288. /**
  69289. * Returns the light rotation in euler definition.
  69290. * @returns the x y z rotation in local space.
  69291. */
  69292. getRotation(): Vector3;
  69293. /**
  69294. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69295. * @returns true if a cube texture needs to be use
  69296. */
  69297. needCube(): boolean;
  69298. /**
  69299. * Detects if the projection matrix requires to be recomputed this frame.
  69300. * @returns true if it requires to be recomputed otherwise, false.
  69301. */
  69302. needProjectionMatrixCompute(): boolean;
  69303. /**
  69304. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69305. */
  69306. forceProjectionMatrixCompute(): void;
  69307. /** @hidden */
  69308. _initCache(): void;
  69309. /** @hidden */
  69310. _isSynchronized(): boolean;
  69311. /**
  69312. * Computes the world matrix of the node
  69313. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69314. * @returns the world matrix
  69315. */
  69316. computeWorldMatrix(force?: boolean): Matrix;
  69317. /**
  69318. * Gets the minZ used for shadow according to both the scene and the light.
  69319. * @param activeCamera The camera we are returning the min for
  69320. * @returns the depth min z
  69321. */
  69322. getDepthMinZ(activeCamera: Camera): number;
  69323. /**
  69324. * Gets the maxZ used for shadow according to both the scene and the light.
  69325. * @param activeCamera The camera we are returning the max for
  69326. * @returns the depth max z
  69327. */
  69328. getDepthMaxZ(activeCamera: Camera): number;
  69329. /**
  69330. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69331. * @param matrix The materix to updated with the projection information
  69332. * @param viewMatrix The transform matrix of the light
  69333. * @param renderList The list of mesh to render in the map
  69334. * @returns The current light
  69335. */
  69336. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69337. }
  69338. }
  69339. declare module BABYLON {
  69340. /**
  69341. * "Static Class" containing the most commonly used helper while dealing with material for
  69342. * rendering purpose.
  69343. *
  69344. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  69345. *
  69346. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  69347. */
  69348. export class MaterialHelper {
  69349. /**
  69350. * Bind the current view position to an effect.
  69351. * @param effect The effect to be bound
  69352. * @param scene The scene the eyes position is used from
  69353. */
  69354. static BindEyePosition(effect: Effect, scene: Scene): void;
  69355. /**
  69356. * Helps preparing the defines values about the UVs in used in the effect.
  69357. * UVs are shared as much as we can accross channels in the shaders.
  69358. * @param texture The texture we are preparing the UVs for
  69359. * @param defines The defines to update
  69360. * @param key The channel key "diffuse", "specular"... used in the shader
  69361. */
  69362. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  69363. /**
  69364. * Binds a texture matrix value to its corrsponding uniform
  69365. * @param texture The texture to bind the matrix for
  69366. * @param uniformBuffer The uniform buffer receivin the data
  69367. * @param key The channel key "diffuse", "specular"... used in the shader
  69368. */
  69369. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  69370. /**
  69371. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  69372. * @param mesh defines the current mesh
  69373. * @param scene defines the current scene
  69374. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  69375. * @param pointsCloud defines if point cloud rendering has to be turned on
  69376. * @param fogEnabled defines if fog has to be turned on
  69377. * @param alphaTest defines if alpha testing has to be turned on
  69378. * @param defines defines the current list of defines
  69379. */
  69380. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  69381. /**
  69382. * Helper used to prepare the list of defines associated with frame values for shader compilation
  69383. * @param scene defines the current scene
  69384. * @param engine defines the current engine
  69385. * @param defines specifies the list of active defines
  69386. * @param useInstances defines if instances have to be turned on
  69387. * @param useClipPlane defines if clip plane have to be turned on
  69388. */
  69389. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  69390. /**
  69391. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  69392. * @param mesh The mesh containing the geometry data we will draw
  69393. * @param defines The defines to update
  69394. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  69395. * @param useBones Precise whether bones should be used or not (override mesh info)
  69396. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  69397. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  69398. * @returns false if defines are considered not dirty and have not been checked
  69399. */
  69400. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  69401. /**
  69402. * Prepares the defines related to multiview
  69403. * @param scene The scene we are intending to draw
  69404. * @param defines The defines to update
  69405. */
  69406. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  69407. /**
  69408. * Prepares the defines related to the light information passed in parameter
  69409. * @param scene The scene we are intending to draw
  69410. * @param mesh The mesh the effect is compiling for
  69411. * @param defines The defines to update
  69412. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  69413. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  69414. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  69415. * @returns true if normals will be required for the rest of the effect
  69416. */
  69417. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  69418. /**
  69419. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  69420. * that won t be acctive due to defines being turned off.
  69421. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  69422. * @param samplersList The samplers list
  69423. * @param defines The defines helping in the list generation
  69424. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  69425. */
  69426. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  69427. /**
  69428. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  69429. * @param defines The defines to update while falling back
  69430. * @param fallbacks The authorized effect fallbacks
  69431. * @param maxSimultaneousLights The maximum number of lights allowed
  69432. * @param rank the current rank of the Effect
  69433. * @returns The newly affected rank
  69434. */
  69435. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  69436. /**
  69437. * Prepares the list of attributes required for morph targets according to the effect defines.
  69438. * @param attribs The current list of supported attribs
  69439. * @param mesh The mesh to prepare the morph targets attributes for
  69440. * @param defines The current Defines of the effect
  69441. */
  69442. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  69443. /**
  69444. * Prepares the list of attributes required for bones according to the effect defines.
  69445. * @param attribs The current list of supported attribs
  69446. * @param mesh The mesh to prepare the bones attributes for
  69447. * @param defines The current Defines of the effect
  69448. * @param fallbacks The current efffect fallback strategy
  69449. */
  69450. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  69451. /**
  69452. * Prepares the list of attributes required for instances according to the effect defines.
  69453. * @param attribs The current list of supported attribs
  69454. * @param defines The current Defines of the effect
  69455. */
  69456. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  69457. /**
  69458. * Binds the light shadow information to the effect for the given mesh.
  69459. * @param light The light containing the generator
  69460. * @param scene The scene the lights belongs to
  69461. * @param mesh The mesh we are binding the information to render
  69462. * @param lightIndex The light index in the effect used to render the mesh
  69463. * @param effect The effect we are binding the data to
  69464. */
  69465. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  69466. /**
  69467. * Binds the light information to the effect.
  69468. * @param light The light containing the generator
  69469. * @param effect The effect we are binding the data to
  69470. * @param lightIndex The light index in the effect used to render
  69471. */
  69472. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  69473. /**
  69474. * Binds the lights information from the scene to the effect for the given mesh.
  69475. * @param scene The scene the lights belongs to
  69476. * @param mesh The mesh we are binding the information to render
  69477. * @param effect The effect we are binding the data to
  69478. * @param defines The generated defines for the effect
  69479. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  69480. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  69481. */
  69482. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  69483. private static _tempFogColor;
  69484. /**
  69485. * Binds the fog information from the scene to the effect for the given mesh.
  69486. * @param scene The scene the lights belongs to
  69487. * @param mesh The mesh we are binding the information to render
  69488. * @param effect The effect we are binding the data to
  69489. * @param linearSpace Defines if the fog effect is applied in linear space
  69490. */
  69491. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  69492. /**
  69493. * Binds the bones information from the mesh to the effect.
  69494. * @param mesh The mesh we are binding the information to render
  69495. * @param effect The effect we are binding the data to
  69496. */
  69497. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  69498. /**
  69499. * Binds the morph targets information from the mesh to the effect.
  69500. * @param abstractMesh The mesh we are binding the information to render
  69501. * @param effect The effect we are binding the data to
  69502. */
  69503. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  69504. /**
  69505. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  69506. * @param defines The generated defines used in the effect
  69507. * @param effect The effect we are binding the data to
  69508. * @param scene The scene we are willing to render with logarithmic scale for
  69509. */
  69510. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  69511. /**
  69512. * Binds the clip plane information from the scene to the effect.
  69513. * @param scene The scene the clip plane information are extracted from
  69514. * @param effect The effect we are binding the data to
  69515. */
  69516. static BindClipPlane(effect: Effect, scene: Scene): void;
  69517. }
  69518. }
  69519. declare module BABYLON {
  69520. /** @hidden */
  69521. export var kernelBlurVaryingDeclaration: {
  69522. name: string;
  69523. shader: string;
  69524. };
  69525. }
  69526. declare module BABYLON {
  69527. /** @hidden */
  69528. export var kernelBlurFragment: {
  69529. name: string;
  69530. shader: string;
  69531. };
  69532. }
  69533. declare module BABYLON {
  69534. /** @hidden */
  69535. export var kernelBlurFragment2: {
  69536. name: string;
  69537. shader: string;
  69538. };
  69539. }
  69540. declare module BABYLON {
  69541. /** @hidden */
  69542. export var kernelBlurPixelShader: {
  69543. name: string;
  69544. shader: string;
  69545. };
  69546. }
  69547. declare module BABYLON {
  69548. /** @hidden */
  69549. export var kernelBlurVertex: {
  69550. name: string;
  69551. shader: string;
  69552. };
  69553. }
  69554. declare module BABYLON {
  69555. /** @hidden */
  69556. export var kernelBlurVertexShader: {
  69557. name: string;
  69558. shader: string;
  69559. };
  69560. }
  69561. declare module BABYLON {
  69562. /**
  69563. * The Blur Post Process which blurs an image based on a kernel and direction.
  69564. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  69565. */
  69566. export class BlurPostProcess extends PostProcess {
  69567. /** The direction in which to blur the image. */
  69568. direction: Vector2;
  69569. private blockCompilation;
  69570. protected _kernel: number;
  69571. protected _idealKernel: number;
  69572. protected _packedFloat: boolean;
  69573. private _staticDefines;
  69574. /**
  69575. * Sets the length in pixels of the blur sample region
  69576. */
  69577. /**
  69578. * Gets the length in pixels of the blur sample region
  69579. */
  69580. kernel: number;
  69581. /**
  69582. * Sets wether or not the blur needs to unpack/repack floats
  69583. */
  69584. /**
  69585. * Gets wether or not the blur is unpacking/repacking floats
  69586. */
  69587. packedFloat: boolean;
  69588. /**
  69589. * Creates a new instance BlurPostProcess
  69590. * @param name The name of the effect.
  69591. * @param direction The direction in which to blur the image.
  69592. * @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.
  69593. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  69594. * @param camera The camera to apply the render pass to.
  69595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69596. * @param engine The engine which the post process will be applied. (default: current engine)
  69597. * @param reusable If the post process can be reused on the same frame. (default: false)
  69598. * @param textureType Type of textures used when performing the post process. (default: 0)
  69599. * @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)
  69600. */
  69601. constructor(name: string,
  69602. /** The direction in which to blur the image. */
  69603. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  69604. /**
  69605. * Updates the effect with the current post process compile time values and recompiles the shader.
  69606. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69607. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69608. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69609. * @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
  69610. * @param onCompiled Called when the shader has been compiled.
  69611. * @param onError Called if there is an error when compiling a shader.
  69612. */
  69613. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69614. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69615. /**
  69616. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  69617. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  69618. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  69619. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  69620. * The gaps between physical kernels are compensated for in the weighting of the samples
  69621. * @param idealKernel Ideal blur kernel.
  69622. * @return Nearest best kernel.
  69623. */
  69624. protected _nearestBestKernel(idealKernel: number): number;
  69625. /**
  69626. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  69627. * @param x The point on the Gaussian distribution to sample.
  69628. * @return the value of the Gaussian function at x.
  69629. */
  69630. protected _gaussianWeight(x: number): number;
  69631. /**
  69632. * Generates a string that can be used as a floating point number in GLSL.
  69633. * @param x Value to print.
  69634. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  69635. * @return GLSL float string.
  69636. */
  69637. protected _glslFloat(x: number, decimalFigures?: number): string;
  69638. }
  69639. }
  69640. declare module BABYLON {
  69641. /** @hidden */
  69642. export var shadowMapPixelShader: {
  69643. name: string;
  69644. shader: string;
  69645. };
  69646. }
  69647. declare module BABYLON {
  69648. /** @hidden */
  69649. export var bonesDeclaration: {
  69650. name: string;
  69651. shader: string;
  69652. };
  69653. }
  69654. declare module BABYLON {
  69655. /** @hidden */
  69656. export var morphTargetsVertexGlobalDeclaration: {
  69657. name: string;
  69658. shader: string;
  69659. };
  69660. }
  69661. declare module BABYLON {
  69662. /** @hidden */
  69663. export var morphTargetsVertexDeclaration: {
  69664. name: string;
  69665. shader: string;
  69666. };
  69667. }
  69668. declare module BABYLON {
  69669. /** @hidden */
  69670. export var instancesDeclaration: {
  69671. name: string;
  69672. shader: string;
  69673. };
  69674. }
  69675. declare module BABYLON {
  69676. /** @hidden */
  69677. export var helperFunctions: {
  69678. name: string;
  69679. shader: string;
  69680. };
  69681. }
  69682. declare module BABYLON {
  69683. /** @hidden */
  69684. export var morphTargetsVertex: {
  69685. name: string;
  69686. shader: string;
  69687. };
  69688. }
  69689. declare module BABYLON {
  69690. /** @hidden */
  69691. export var instancesVertex: {
  69692. name: string;
  69693. shader: string;
  69694. };
  69695. }
  69696. declare module BABYLON {
  69697. /** @hidden */
  69698. export var bonesVertex: {
  69699. name: string;
  69700. shader: string;
  69701. };
  69702. }
  69703. declare module BABYLON {
  69704. /** @hidden */
  69705. export var shadowMapVertexShader: {
  69706. name: string;
  69707. shader: string;
  69708. };
  69709. }
  69710. declare module BABYLON {
  69711. /** @hidden */
  69712. export var depthBoxBlurPixelShader: {
  69713. name: string;
  69714. shader: string;
  69715. };
  69716. }
  69717. declare module BABYLON {
  69718. /**
  69719. * Defines the options associated with the creation of a custom shader for a shadow generator.
  69720. */
  69721. export interface ICustomShaderOptions {
  69722. /**
  69723. * Gets or sets the custom shader name to use
  69724. */
  69725. shaderName: string;
  69726. /**
  69727. * The list of attribute names used in the shader
  69728. */
  69729. attributes?: string[];
  69730. /**
  69731. * The list of unifrom names used in the shader
  69732. */
  69733. uniforms?: string[];
  69734. /**
  69735. * The list of sampler names used in the shader
  69736. */
  69737. samplers?: string[];
  69738. /**
  69739. * The list of defines used in the shader
  69740. */
  69741. defines?: string[];
  69742. }
  69743. /**
  69744. * Interface to implement to create a shadow generator compatible with BJS.
  69745. */
  69746. export interface IShadowGenerator {
  69747. /**
  69748. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69749. * @returns The render target texture if present otherwise, null
  69750. */
  69751. getShadowMap(): Nullable<RenderTargetTexture>;
  69752. /**
  69753. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69754. * @returns The render target texture if the shadow map is present otherwise, null
  69755. */
  69756. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69757. /**
  69758. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69759. * @param subMesh The submesh we want to render in the shadow map
  69760. * @param useInstances Defines wether will draw in the map using instances
  69761. * @returns true if ready otherwise, false
  69762. */
  69763. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69764. /**
  69765. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69766. * @param defines Defines of the material we want to update
  69767. * @param lightIndex Index of the light in the enabled light list of the material
  69768. */
  69769. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  69770. /**
  69771. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69772. * defined in the generator but impacting the effect).
  69773. * It implies the unifroms available on the materials are the standard BJS ones.
  69774. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69775. * @param effect The effect we are binfing the information for
  69776. */
  69777. bindShadowLight(lightIndex: string, effect: Effect): void;
  69778. /**
  69779. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69780. * (eq to shadow prjection matrix * light transform matrix)
  69781. * @returns The transform matrix used to create the shadow map
  69782. */
  69783. getTransformMatrix(): Matrix;
  69784. /**
  69785. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69786. * Cube and 2D textures for instance.
  69787. */
  69788. recreateShadowMap(): void;
  69789. /**
  69790. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69791. * @param onCompiled Callback triggered at the and of the effects compilation
  69792. * @param options Sets of optional options forcing the compilation with different modes
  69793. */
  69794. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69795. useInstances: boolean;
  69796. }>): void;
  69797. /**
  69798. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69799. * @param options Sets of optional options forcing the compilation with different modes
  69800. * @returns A promise that resolves when the compilation completes
  69801. */
  69802. forceCompilationAsync(options?: Partial<{
  69803. useInstances: boolean;
  69804. }>): Promise<void>;
  69805. /**
  69806. * Serializes the shadow generator setup to a json object.
  69807. * @returns The serialized JSON object
  69808. */
  69809. serialize(): any;
  69810. /**
  69811. * Disposes the Shadow map and related Textures and effects.
  69812. */
  69813. dispose(): void;
  69814. }
  69815. /**
  69816. * Default implementation IShadowGenerator.
  69817. * This is the main object responsible of generating shadows in the framework.
  69818. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  69819. */
  69820. export class ShadowGenerator implements IShadowGenerator {
  69821. /**
  69822. * Shadow generator mode None: no filtering applied.
  69823. */
  69824. static readonly FILTER_NONE: number;
  69825. /**
  69826. * Shadow generator mode ESM: Exponential Shadow Mapping.
  69827. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69828. */
  69829. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69830. /**
  69831. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69832. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69833. */
  69834. static readonly FILTER_POISSONSAMPLING: number;
  69835. /**
  69836. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69837. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69838. */
  69839. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69840. /**
  69841. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69842. * edge artifacts on steep falloff.
  69843. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69844. */
  69845. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69846. /**
  69847. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69848. * edge artifacts on steep falloff.
  69849. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69850. */
  69851. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69852. /**
  69853. * Shadow generator mode PCF: Percentage Closer Filtering
  69854. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69855. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69856. */
  69857. static readonly FILTER_PCF: number;
  69858. /**
  69859. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69860. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69861. * Contact Hardening
  69862. */
  69863. static readonly FILTER_PCSS: number;
  69864. /**
  69865. * Reserved for PCF and PCSS
  69866. * Highest Quality.
  69867. *
  69868. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69869. *
  69870. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69871. */
  69872. static readonly QUALITY_HIGH: number;
  69873. /**
  69874. * Reserved for PCF and PCSS
  69875. * Good tradeoff for quality/perf cross devices
  69876. *
  69877. * Execute PCF on a 3*3 kernel.
  69878. *
  69879. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69880. */
  69881. static readonly QUALITY_MEDIUM: number;
  69882. /**
  69883. * Reserved for PCF and PCSS
  69884. * The lowest quality but the fastest.
  69885. *
  69886. * Execute PCF on a 1*1 kernel.
  69887. *
  69888. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69889. */
  69890. static readonly QUALITY_LOW: number;
  69891. /** Gets or sets the custom shader name to use */
  69892. customShaderOptions: ICustomShaderOptions;
  69893. /**
  69894. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69895. */
  69896. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69897. /**
  69898. * Observable triggered before a mesh is rendered in the shadow map.
  69899. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69900. */
  69901. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69902. private _bias;
  69903. /**
  69904. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69905. */
  69906. /**
  69907. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69908. */
  69909. bias: number;
  69910. private _normalBias;
  69911. /**
  69912. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69913. */
  69914. /**
  69915. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69916. */
  69917. normalBias: number;
  69918. private _blurBoxOffset;
  69919. /**
  69920. * Gets the blur box offset: offset applied during the blur pass.
  69921. * Only useful if useKernelBlur = false
  69922. */
  69923. /**
  69924. * Sets the blur box offset: offset applied during the blur pass.
  69925. * Only useful if useKernelBlur = false
  69926. */
  69927. blurBoxOffset: number;
  69928. private _blurScale;
  69929. /**
  69930. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69931. * 2 means half of the size.
  69932. */
  69933. /**
  69934. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69935. * 2 means half of the size.
  69936. */
  69937. blurScale: number;
  69938. private _blurKernel;
  69939. /**
  69940. * Gets the blur kernel: kernel size of the blur pass.
  69941. * Only useful if useKernelBlur = true
  69942. */
  69943. /**
  69944. * Sets the blur kernel: kernel size of the blur pass.
  69945. * Only useful if useKernelBlur = true
  69946. */
  69947. blurKernel: number;
  69948. private _useKernelBlur;
  69949. /**
  69950. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69951. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69952. */
  69953. /**
  69954. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69955. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69956. */
  69957. useKernelBlur: boolean;
  69958. private _depthScale;
  69959. /**
  69960. * Gets the depth scale used in ESM mode.
  69961. */
  69962. /**
  69963. * Sets the depth scale used in ESM mode.
  69964. * This can override the scale stored on the light.
  69965. */
  69966. depthScale: number;
  69967. private _filter;
  69968. /**
  69969. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69970. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69971. */
  69972. /**
  69973. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69974. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69975. */
  69976. filter: number;
  69977. /**
  69978. * Gets if the current filter is set to Poisson Sampling.
  69979. */
  69980. /**
  69981. * Sets the current filter to Poisson Sampling.
  69982. */
  69983. usePoissonSampling: boolean;
  69984. /**
  69985. * Gets if the current filter is set to ESM.
  69986. */
  69987. /**
  69988. * Sets the current filter is to ESM.
  69989. */
  69990. useExponentialShadowMap: boolean;
  69991. /**
  69992. * Gets if the current filter is set to filtered ESM.
  69993. */
  69994. /**
  69995. * Gets if the current filter is set to filtered ESM.
  69996. */
  69997. useBlurExponentialShadowMap: boolean;
  69998. /**
  69999. * Gets if the current filter is set to "close ESM" (using the inverse of the
  70000. * exponential to prevent steep falloff artifacts).
  70001. */
  70002. /**
  70003. * Sets the current filter to "close ESM" (using the inverse of the
  70004. * exponential to prevent steep falloff artifacts).
  70005. */
  70006. useCloseExponentialShadowMap: boolean;
  70007. /**
  70008. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  70009. * exponential to prevent steep falloff artifacts).
  70010. */
  70011. /**
  70012. * Sets the current filter to filtered "close ESM" (using the inverse of the
  70013. * exponential to prevent steep falloff artifacts).
  70014. */
  70015. useBlurCloseExponentialShadowMap: boolean;
  70016. /**
  70017. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  70018. */
  70019. /**
  70020. * Sets the current filter to "PCF" (percentage closer filtering).
  70021. */
  70022. usePercentageCloserFiltering: boolean;
  70023. private _filteringQuality;
  70024. /**
  70025. * Gets the PCF or PCSS Quality.
  70026. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  70027. */
  70028. /**
  70029. * Sets the PCF or PCSS Quality.
  70030. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  70031. */
  70032. filteringQuality: number;
  70033. /**
  70034. * Gets if the current filter is set to "PCSS" (contact hardening).
  70035. */
  70036. /**
  70037. * Sets the current filter to "PCSS" (contact hardening).
  70038. */
  70039. useContactHardeningShadow: boolean;
  70040. private _contactHardeningLightSizeUVRatio;
  70041. /**
  70042. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  70043. * Using a ratio helps keeping shape stability independently of the map size.
  70044. *
  70045. * It does not account for the light projection as it was having too much
  70046. * instability during the light setup or during light position changes.
  70047. *
  70048. * Only valid if useContactHardeningShadow is true.
  70049. */
  70050. /**
  70051. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  70052. * Using a ratio helps keeping shape stability independently of the map size.
  70053. *
  70054. * It does not account for the light projection as it was having too much
  70055. * instability during the light setup or during light position changes.
  70056. *
  70057. * Only valid if useContactHardeningShadow is true.
  70058. */
  70059. contactHardeningLightSizeUVRatio: number;
  70060. private _darkness;
  70061. /**
  70062. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  70063. * 0 means strongest and 1 would means no shadow.
  70064. * @returns the darkness.
  70065. */
  70066. getDarkness(): number;
  70067. /**
  70068. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  70069. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  70070. * @returns the shadow generator allowing fluent coding.
  70071. */
  70072. setDarkness(darkness: number): ShadowGenerator;
  70073. private _transparencyShadow;
  70074. /**
  70075. * Sets the ability to have transparent shadow (boolean).
  70076. * @param transparent True if transparent else False
  70077. * @returns the shadow generator allowing fluent coding
  70078. */
  70079. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  70080. private _shadowMap;
  70081. private _shadowMap2;
  70082. /**
  70083. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  70084. * @returns The render target texture if present otherwise, null
  70085. */
  70086. getShadowMap(): Nullable<RenderTargetTexture>;
  70087. /**
  70088. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  70089. * @returns The render target texture if the shadow map is present otherwise, null
  70090. */
  70091. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  70092. /**
  70093. * Helper function to add a mesh and its descendants to the list of shadow casters.
  70094. * @param mesh Mesh to add
  70095. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  70096. * @returns the Shadow Generator itself
  70097. */
  70098. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  70099. /**
  70100. * Helper function to remove a mesh and its descendants from the list of shadow casters
  70101. * @param mesh Mesh to remove
  70102. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  70103. * @returns the Shadow Generator itself
  70104. */
  70105. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  70106. /**
  70107. * Controls the extent to which the shadows fade out at the edge of the frustum
  70108. * Used only by directionals and spots
  70109. */
  70110. frustumEdgeFalloff: number;
  70111. private _light;
  70112. /**
  70113. * Returns the associated light object.
  70114. * @returns the light generating the shadow
  70115. */
  70116. getLight(): IShadowLight;
  70117. /**
  70118. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  70119. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  70120. * It might on the other hand introduce peter panning.
  70121. */
  70122. forceBackFacesOnly: boolean;
  70123. private _scene;
  70124. private _lightDirection;
  70125. private _effect;
  70126. private _viewMatrix;
  70127. private _projectionMatrix;
  70128. private _transformMatrix;
  70129. private _cachedPosition;
  70130. private _cachedDirection;
  70131. private _cachedDefines;
  70132. private _currentRenderID;
  70133. private _boxBlurPostprocess;
  70134. private _kernelBlurXPostprocess;
  70135. private _kernelBlurYPostprocess;
  70136. private _blurPostProcesses;
  70137. private _mapSize;
  70138. private _currentFaceIndex;
  70139. private _currentFaceIndexCache;
  70140. private _textureType;
  70141. private _defaultTextureMatrix;
  70142. /** @hidden */
  70143. static _SceneComponentInitialization: (scene: Scene) => void;
  70144. /**
  70145. * Creates a ShadowGenerator object.
  70146. * A ShadowGenerator is the required tool to use the shadows.
  70147. * Each light casting shadows needs to use its own ShadowGenerator.
  70148. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  70149. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  70150. * @param light The light object generating the shadows.
  70151. * @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.
  70152. */
  70153. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  70154. private _initializeGenerator;
  70155. private _initializeShadowMap;
  70156. private _initializeBlurRTTAndPostProcesses;
  70157. private _renderForShadowMap;
  70158. private _renderSubMeshForShadowMap;
  70159. private _applyFilterValues;
  70160. /**
  70161. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70162. * @param onCompiled Callback triggered at the and of the effects compilation
  70163. * @param options Sets of optional options forcing the compilation with different modes
  70164. */
  70165. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  70166. useInstances: boolean;
  70167. }>): void;
  70168. /**
  70169. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70170. * @param options Sets of optional options forcing the compilation with different modes
  70171. * @returns A promise that resolves when the compilation completes
  70172. */
  70173. forceCompilationAsync(options?: Partial<{
  70174. useInstances: boolean;
  70175. }>): Promise<void>;
  70176. /**
  70177. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  70178. * @param subMesh The submesh we want to render in the shadow map
  70179. * @param useInstances Defines wether will draw in the map using instances
  70180. * @returns true if ready otherwise, false
  70181. */
  70182. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70183. /**
  70184. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  70185. * @param defines Defines of the material we want to update
  70186. * @param lightIndex Index of the light in the enabled light list of the material
  70187. */
  70188. prepareDefines(defines: any, lightIndex: number): void;
  70189. /**
  70190. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  70191. * defined in the generator but impacting the effect).
  70192. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  70193. * @param effect The effect we are binfing the information for
  70194. */
  70195. bindShadowLight(lightIndex: string, effect: Effect): void;
  70196. /**
  70197. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  70198. * (eq to shadow prjection matrix * light transform matrix)
  70199. * @returns The transform matrix used to create the shadow map
  70200. */
  70201. getTransformMatrix(): Matrix;
  70202. /**
  70203. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  70204. * Cube and 2D textures for instance.
  70205. */
  70206. recreateShadowMap(): void;
  70207. private _disposeBlurPostProcesses;
  70208. private _disposeRTTandPostProcesses;
  70209. /**
  70210. * Disposes the ShadowGenerator.
  70211. * Returns nothing.
  70212. */
  70213. dispose(): void;
  70214. /**
  70215. * Serializes the shadow generator setup to a json object.
  70216. * @returns The serialized JSON object
  70217. */
  70218. serialize(): any;
  70219. /**
  70220. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  70221. * @param parsedShadowGenerator The JSON object to parse
  70222. * @param scene The scene to create the shadow map for
  70223. * @returns The parsed shadow generator
  70224. */
  70225. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  70226. }
  70227. }
  70228. declare module BABYLON {
  70229. /**
  70230. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  70231. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  70232. * 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.
  70233. */
  70234. export abstract class Light extends Node {
  70235. /**
  70236. * Falloff Default: light is falling off following the material specification:
  70237. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  70238. */
  70239. static readonly FALLOFF_DEFAULT: number;
  70240. /**
  70241. * Falloff Physical: light is falling off following the inverse squared distance law.
  70242. */
  70243. static readonly FALLOFF_PHYSICAL: number;
  70244. /**
  70245. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  70246. * to enhance interoperability with other engines.
  70247. */
  70248. static readonly FALLOFF_GLTF: number;
  70249. /**
  70250. * Falloff Standard: light is falling off like in the standard material
  70251. * to enhance interoperability with other materials.
  70252. */
  70253. static readonly FALLOFF_STANDARD: number;
  70254. /**
  70255. * If every light affecting the material is in this lightmapMode,
  70256. * material.lightmapTexture adds or multiplies
  70257. * (depends on material.useLightmapAsShadowmap)
  70258. * after every other light calculations.
  70259. */
  70260. static readonly LIGHTMAP_DEFAULT: number;
  70261. /**
  70262. * material.lightmapTexture as only diffuse lighting from this light
  70263. * adds only specular lighting from this light
  70264. * adds dynamic shadows
  70265. */
  70266. static readonly LIGHTMAP_SPECULAR: number;
  70267. /**
  70268. * material.lightmapTexture as only lighting
  70269. * no light calculation from this light
  70270. * only adds dynamic shadows from this light
  70271. */
  70272. static readonly LIGHTMAP_SHADOWSONLY: number;
  70273. /**
  70274. * Each light type uses the default quantity according to its type:
  70275. * point/spot lights use luminous intensity
  70276. * directional lights use illuminance
  70277. */
  70278. static readonly INTENSITYMODE_AUTOMATIC: number;
  70279. /**
  70280. * lumen (lm)
  70281. */
  70282. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  70283. /**
  70284. * candela (lm/sr)
  70285. */
  70286. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  70287. /**
  70288. * lux (lm/m^2)
  70289. */
  70290. static readonly INTENSITYMODE_ILLUMINANCE: number;
  70291. /**
  70292. * nit (cd/m^2)
  70293. */
  70294. static readonly INTENSITYMODE_LUMINANCE: number;
  70295. /**
  70296. * Light type const id of the point light.
  70297. */
  70298. static readonly LIGHTTYPEID_POINTLIGHT: number;
  70299. /**
  70300. * Light type const id of the directional light.
  70301. */
  70302. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  70303. /**
  70304. * Light type const id of the spot light.
  70305. */
  70306. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  70307. /**
  70308. * Light type const id of the hemispheric light.
  70309. */
  70310. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  70311. /**
  70312. * Diffuse gives the basic color to an object.
  70313. */
  70314. diffuse: Color3;
  70315. /**
  70316. * Specular produces a highlight color on an object.
  70317. * Note: This is note affecting PBR materials.
  70318. */
  70319. specular: Color3;
  70320. /**
  70321. * Defines the falloff type for this light. This lets overrriding how punctual light are
  70322. * falling off base on range or angle.
  70323. * This can be set to any values in Light.FALLOFF_x.
  70324. *
  70325. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  70326. * other types of materials.
  70327. */
  70328. falloffType: number;
  70329. /**
  70330. * Strength of the light.
  70331. * Note: By default it is define in the framework own unit.
  70332. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  70333. */
  70334. intensity: number;
  70335. private _range;
  70336. protected _inverseSquaredRange: number;
  70337. /**
  70338. * Defines how far from the source the light is impacting in scene units.
  70339. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70340. */
  70341. /**
  70342. * Defines how far from the source the light is impacting in scene units.
  70343. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70344. */
  70345. range: number;
  70346. /**
  70347. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  70348. * of light.
  70349. */
  70350. private _photometricScale;
  70351. private _intensityMode;
  70352. /**
  70353. * Gets the photometric scale used to interpret the intensity.
  70354. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70355. */
  70356. /**
  70357. * Sets the photometric scale used to interpret the intensity.
  70358. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70359. */
  70360. intensityMode: number;
  70361. private _radius;
  70362. /**
  70363. * Gets the light radius used by PBR Materials to simulate soft area lights.
  70364. */
  70365. /**
  70366. * sets the light radius used by PBR Materials to simulate soft area lights.
  70367. */
  70368. radius: number;
  70369. private _renderPriority;
  70370. /**
  70371. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  70372. * exceeding the number allowed of the materials.
  70373. */
  70374. renderPriority: number;
  70375. private _shadowEnabled;
  70376. /**
  70377. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70378. * the current shadow generator.
  70379. */
  70380. /**
  70381. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70382. * the current shadow generator.
  70383. */
  70384. shadowEnabled: boolean;
  70385. private _includedOnlyMeshes;
  70386. /**
  70387. * Gets the only meshes impacted by this light.
  70388. */
  70389. /**
  70390. * Sets the only meshes impacted by this light.
  70391. */
  70392. includedOnlyMeshes: AbstractMesh[];
  70393. private _excludedMeshes;
  70394. /**
  70395. * Gets the meshes not impacted by this light.
  70396. */
  70397. /**
  70398. * Sets the meshes not impacted by this light.
  70399. */
  70400. excludedMeshes: AbstractMesh[];
  70401. private _excludeWithLayerMask;
  70402. /**
  70403. * Gets the layer id use to find what meshes are not impacted by the light.
  70404. * Inactive if 0
  70405. */
  70406. /**
  70407. * Sets the layer id use to find what meshes are not impacted by the light.
  70408. * Inactive if 0
  70409. */
  70410. excludeWithLayerMask: number;
  70411. private _includeOnlyWithLayerMask;
  70412. /**
  70413. * Gets the layer id use to find what meshes are impacted by the light.
  70414. * Inactive if 0
  70415. */
  70416. /**
  70417. * Sets the layer id use to find what meshes are impacted by the light.
  70418. * Inactive if 0
  70419. */
  70420. includeOnlyWithLayerMask: number;
  70421. private _lightmapMode;
  70422. /**
  70423. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70424. */
  70425. /**
  70426. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70427. */
  70428. lightmapMode: number;
  70429. /**
  70430. * Shadow generator associted to the light.
  70431. * @hidden Internal use only.
  70432. */
  70433. _shadowGenerator: Nullable<IShadowGenerator>;
  70434. /**
  70435. * @hidden Internal use only.
  70436. */
  70437. _excludedMeshesIds: string[];
  70438. /**
  70439. * @hidden Internal use only.
  70440. */
  70441. _includedOnlyMeshesIds: string[];
  70442. /**
  70443. * The current light unifom buffer.
  70444. * @hidden Internal use only.
  70445. */
  70446. _uniformBuffer: UniformBuffer;
  70447. /**
  70448. * Creates a Light object in the scene.
  70449. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70450. * @param name The firendly name of the light
  70451. * @param scene The scene the light belongs too
  70452. */
  70453. constructor(name: string, scene: Scene);
  70454. protected abstract _buildUniformLayout(): void;
  70455. /**
  70456. * Sets the passed Effect "effect" with the Light information.
  70457. * @param effect The effect to update
  70458. * @param lightIndex The index of the light in the effect to update
  70459. * @returns The light
  70460. */
  70461. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  70462. /**
  70463. * Returns the string "Light".
  70464. * @returns the class name
  70465. */
  70466. getClassName(): string;
  70467. /** @hidden */
  70468. readonly _isLight: boolean;
  70469. /**
  70470. * Converts the light information to a readable string for debug purpose.
  70471. * @param fullDetails Supports for multiple levels of logging within scene loading
  70472. * @returns the human readable light info
  70473. */
  70474. toString(fullDetails?: boolean): string;
  70475. /** @hidden */
  70476. protected _syncParentEnabledState(): void;
  70477. /**
  70478. * Set the enabled state of this node.
  70479. * @param value - the new enabled state
  70480. */
  70481. setEnabled(value: boolean): void;
  70482. /**
  70483. * Returns the Light associated shadow generator if any.
  70484. * @return the associated shadow generator.
  70485. */
  70486. getShadowGenerator(): Nullable<IShadowGenerator>;
  70487. /**
  70488. * Returns a Vector3, the absolute light position in the World.
  70489. * @returns the world space position of the light
  70490. */
  70491. getAbsolutePosition(): Vector3;
  70492. /**
  70493. * Specifies if the light will affect the passed mesh.
  70494. * @param mesh The mesh to test against the light
  70495. * @return true the mesh is affected otherwise, false.
  70496. */
  70497. canAffectMesh(mesh: AbstractMesh): boolean;
  70498. /**
  70499. * Sort function to order lights for rendering.
  70500. * @param a First Light object to compare to second.
  70501. * @param b Second Light object to compare first.
  70502. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  70503. */
  70504. static CompareLightsPriority(a: Light, b: Light): number;
  70505. /**
  70506. * Releases resources associated with this node.
  70507. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  70508. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  70509. */
  70510. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  70511. /**
  70512. * Returns the light type ID (integer).
  70513. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70514. */
  70515. getTypeID(): number;
  70516. /**
  70517. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  70518. * @returns the scaled intensity in intensity mode unit
  70519. */
  70520. getScaledIntensity(): number;
  70521. /**
  70522. * Returns a new Light object, named "name", from the current one.
  70523. * @param name The name of the cloned light
  70524. * @returns the new created light
  70525. */
  70526. clone(name: string): Nullable<Light>;
  70527. /**
  70528. * Serializes the current light into a Serialization object.
  70529. * @returns the serialized object.
  70530. */
  70531. serialize(): any;
  70532. /**
  70533. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  70534. * This new light is named "name" and added to the passed scene.
  70535. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  70536. * @param name The friendly name of the light
  70537. * @param scene The scene the new light will belong to
  70538. * @returns the constructor function
  70539. */
  70540. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  70541. /**
  70542. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  70543. * @param parsedLight The JSON representation of the light
  70544. * @param scene The scene to create the parsed light in
  70545. * @returns the created light after parsing
  70546. */
  70547. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  70548. private _hookArrayForExcluded;
  70549. private _hookArrayForIncludedOnly;
  70550. private _resyncMeshes;
  70551. /**
  70552. * Forces the meshes to update their light related information in their rendering used effects
  70553. * @hidden Internal Use Only
  70554. */
  70555. _markMeshesAsLightDirty(): void;
  70556. /**
  70557. * Recomputes the cached photometric scale if needed.
  70558. */
  70559. private _computePhotometricScale;
  70560. /**
  70561. * Returns the Photometric Scale according to the light type and intensity mode.
  70562. */
  70563. private _getPhotometricScale;
  70564. /**
  70565. * Reorder the light in the scene according to their defined priority.
  70566. * @hidden Internal Use Only
  70567. */
  70568. _reorderLightsInScene(): void;
  70569. /**
  70570. * Prepares the list of defines specific to the light type.
  70571. * @param defines the list of defines
  70572. * @param lightIndex defines the index of the light for the effect
  70573. */
  70574. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70575. }
  70576. }
  70577. declare module BABYLON {
  70578. /**
  70579. * Interface used to define Action
  70580. */
  70581. export interface IAction {
  70582. /**
  70583. * Trigger for the action
  70584. */
  70585. trigger: number;
  70586. /** Options of the trigger */
  70587. triggerOptions: any;
  70588. /**
  70589. * Gets the trigger parameters
  70590. * @returns the trigger parameters
  70591. */
  70592. getTriggerParameter(): any;
  70593. /**
  70594. * Internal only - executes current action event
  70595. * @hidden
  70596. */
  70597. _executeCurrent(evt?: ActionEvent): void;
  70598. /**
  70599. * Serialize placeholder for child classes
  70600. * @param parent of child
  70601. * @returns the serialized object
  70602. */
  70603. serialize(parent: any): any;
  70604. /**
  70605. * Internal only
  70606. * @hidden
  70607. */
  70608. _prepare(): void;
  70609. /**
  70610. * Internal only - manager for action
  70611. * @hidden
  70612. */
  70613. _actionManager: AbstractActionManager;
  70614. }
  70615. /**
  70616. * The action to be carried out following a trigger
  70617. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  70618. */
  70619. export class Action implements IAction {
  70620. /** the trigger, with or without parameters, for the action */
  70621. triggerOptions: any;
  70622. /**
  70623. * Trigger for the action
  70624. */
  70625. trigger: number;
  70626. /**
  70627. * Internal only - manager for action
  70628. * @hidden
  70629. */
  70630. _actionManager: ActionManager;
  70631. private _nextActiveAction;
  70632. private _child;
  70633. private _condition?;
  70634. private _triggerParameter;
  70635. /**
  70636. * An event triggered prior to action being executed.
  70637. */
  70638. onBeforeExecuteObservable: Observable<Action>;
  70639. /**
  70640. * Creates a new Action
  70641. * @param triggerOptions the trigger, with or without parameters, for the action
  70642. * @param condition an optional determinant of action
  70643. */
  70644. constructor(
  70645. /** the trigger, with or without parameters, for the action */
  70646. triggerOptions: any, condition?: Condition);
  70647. /**
  70648. * Internal only
  70649. * @hidden
  70650. */
  70651. _prepare(): void;
  70652. /**
  70653. * Gets the trigger parameters
  70654. * @returns the trigger parameters
  70655. */
  70656. getTriggerParameter(): any;
  70657. /**
  70658. * Internal only - executes current action event
  70659. * @hidden
  70660. */
  70661. _executeCurrent(evt?: ActionEvent): void;
  70662. /**
  70663. * Execute placeholder for child classes
  70664. * @param evt optional action event
  70665. */
  70666. execute(evt?: ActionEvent): void;
  70667. /**
  70668. * Skips to next active action
  70669. */
  70670. skipToNextActiveAction(): void;
  70671. /**
  70672. * Adds action to chain of actions, may be a DoNothingAction
  70673. * @param action defines the next action to execute
  70674. * @returns The action passed in
  70675. * @see https://www.babylonjs-playground.com/#1T30HR#0
  70676. */
  70677. then(action: Action): Action;
  70678. /**
  70679. * Internal only
  70680. * @hidden
  70681. */
  70682. _getProperty(propertyPath: string): string;
  70683. /**
  70684. * Internal only
  70685. * @hidden
  70686. */
  70687. _getEffectiveTarget(target: any, propertyPath: string): any;
  70688. /**
  70689. * Serialize placeholder for child classes
  70690. * @param parent of child
  70691. * @returns the serialized object
  70692. */
  70693. serialize(parent: any): any;
  70694. /**
  70695. * Internal only called by serialize
  70696. * @hidden
  70697. */
  70698. protected _serialize(serializedAction: any, parent?: any): any;
  70699. /**
  70700. * Internal only
  70701. * @hidden
  70702. */
  70703. static _SerializeValueAsString: (value: any) => string;
  70704. /**
  70705. * Internal only
  70706. * @hidden
  70707. */
  70708. static _GetTargetProperty: (target: Scene | Node) => {
  70709. name: string;
  70710. targetType: string;
  70711. value: string;
  70712. };
  70713. }
  70714. }
  70715. declare module BABYLON {
  70716. /**
  70717. * A Condition applied to an Action
  70718. */
  70719. export class Condition {
  70720. /**
  70721. * Internal only - manager for action
  70722. * @hidden
  70723. */
  70724. _actionManager: ActionManager;
  70725. /**
  70726. * Internal only
  70727. * @hidden
  70728. */
  70729. _evaluationId: number;
  70730. /**
  70731. * Internal only
  70732. * @hidden
  70733. */
  70734. _currentResult: boolean;
  70735. /**
  70736. * Creates a new Condition
  70737. * @param actionManager the manager of the action the condition is applied to
  70738. */
  70739. constructor(actionManager: ActionManager);
  70740. /**
  70741. * Check if the current condition is valid
  70742. * @returns a boolean
  70743. */
  70744. isValid(): boolean;
  70745. /**
  70746. * Internal only
  70747. * @hidden
  70748. */
  70749. _getProperty(propertyPath: string): string;
  70750. /**
  70751. * Internal only
  70752. * @hidden
  70753. */
  70754. _getEffectiveTarget(target: any, propertyPath: string): any;
  70755. /**
  70756. * Serialize placeholder for child classes
  70757. * @returns the serialized object
  70758. */
  70759. serialize(): any;
  70760. /**
  70761. * Internal only
  70762. * @hidden
  70763. */
  70764. protected _serialize(serializedCondition: any): any;
  70765. }
  70766. /**
  70767. * Defines specific conditional operators as extensions of Condition
  70768. */
  70769. export class ValueCondition extends Condition {
  70770. /** path to specify the property of the target the conditional operator uses */
  70771. propertyPath: string;
  70772. /** the value compared by the conditional operator against the current value of the property */
  70773. value: any;
  70774. /** the conditional operator, default ValueCondition.IsEqual */
  70775. operator: number;
  70776. /**
  70777. * Internal only
  70778. * @hidden
  70779. */
  70780. private static _IsEqual;
  70781. /**
  70782. * Internal only
  70783. * @hidden
  70784. */
  70785. private static _IsDifferent;
  70786. /**
  70787. * Internal only
  70788. * @hidden
  70789. */
  70790. private static _IsGreater;
  70791. /**
  70792. * Internal only
  70793. * @hidden
  70794. */
  70795. private static _IsLesser;
  70796. /**
  70797. * returns the number for IsEqual
  70798. */
  70799. static readonly IsEqual: number;
  70800. /**
  70801. * Returns the number for IsDifferent
  70802. */
  70803. static readonly IsDifferent: number;
  70804. /**
  70805. * Returns the number for IsGreater
  70806. */
  70807. static readonly IsGreater: number;
  70808. /**
  70809. * Returns the number for IsLesser
  70810. */
  70811. static readonly IsLesser: number;
  70812. /**
  70813. * Internal only The action manager for the condition
  70814. * @hidden
  70815. */
  70816. _actionManager: ActionManager;
  70817. /**
  70818. * Internal only
  70819. * @hidden
  70820. */
  70821. private _target;
  70822. /**
  70823. * Internal only
  70824. * @hidden
  70825. */
  70826. private _effectiveTarget;
  70827. /**
  70828. * Internal only
  70829. * @hidden
  70830. */
  70831. private _property;
  70832. /**
  70833. * Creates a new ValueCondition
  70834. * @param actionManager manager for the action the condition applies to
  70835. * @param target for the action
  70836. * @param propertyPath path to specify the property of the target the conditional operator uses
  70837. * @param value the value compared by the conditional operator against the current value of the property
  70838. * @param operator the conditional operator, default ValueCondition.IsEqual
  70839. */
  70840. constructor(actionManager: ActionManager, target: any,
  70841. /** path to specify the property of the target the conditional operator uses */
  70842. propertyPath: string,
  70843. /** the value compared by the conditional operator against the current value of the property */
  70844. value: any,
  70845. /** the conditional operator, default ValueCondition.IsEqual */
  70846. operator?: number);
  70847. /**
  70848. * Compares the given value with the property value for the specified conditional operator
  70849. * @returns the result of the comparison
  70850. */
  70851. isValid(): boolean;
  70852. /**
  70853. * Serialize the ValueCondition into a JSON compatible object
  70854. * @returns serialization object
  70855. */
  70856. serialize(): any;
  70857. /**
  70858. * Gets the name of the conditional operator for the ValueCondition
  70859. * @param operator the conditional operator
  70860. * @returns the name
  70861. */
  70862. static GetOperatorName(operator: number): string;
  70863. }
  70864. /**
  70865. * Defines a predicate condition as an extension of Condition
  70866. */
  70867. export class PredicateCondition extends Condition {
  70868. /** defines the predicate function used to validate the condition */
  70869. predicate: () => boolean;
  70870. /**
  70871. * Internal only - manager for action
  70872. * @hidden
  70873. */
  70874. _actionManager: ActionManager;
  70875. /**
  70876. * Creates a new PredicateCondition
  70877. * @param actionManager manager for the action the condition applies to
  70878. * @param predicate defines the predicate function used to validate the condition
  70879. */
  70880. constructor(actionManager: ActionManager,
  70881. /** defines the predicate function used to validate the condition */
  70882. predicate: () => boolean);
  70883. /**
  70884. * @returns the validity of the predicate condition
  70885. */
  70886. isValid(): boolean;
  70887. }
  70888. /**
  70889. * Defines a state condition as an extension of Condition
  70890. */
  70891. export class StateCondition extends Condition {
  70892. /** Value to compare with target state */
  70893. value: string;
  70894. /**
  70895. * Internal only - manager for action
  70896. * @hidden
  70897. */
  70898. _actionManager: ActionManager;
  70899. /**
  70900. * Internal only
  70901. * @hidden
  70902. */
  70903. private _target;
  70904. /**
  70905. * Creates a new StateCondition
  70906. * @param actionManager manager for the action the condition applies to
  70907. * @param target of the condition
  70908. * @param value to compare with target state
  70909. */
  70910. constructor(actionManager: ActionManager, target: any,
  70911. /** Value to compare with target state */
  70912. value: string);
  70913. /**
  70914. * Gets a boolean indicating if the current condition is met
  70915. * @returns the validity of the state
  70916. */
  70917. isValid(): boolean;
  70918. /**
  70919. * Serialize the StateCondition into a JSON compatible object
  70920. * @returns serialization object
  70921. */
  70922. serialize(): any;
  70923. }
  70924. }
  70925. declare module BABYLON {
  70926. /**
  70927. * This defines an action responsible to toggle a boolean once triggered.
  70928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70929. */
  70930. export class SwitchBooleanAction extends Action {
  70931. /**
  70932. * The path to the boolean property in the target object
  70933. */
  70934. propertyPath: string;
  70935. private _target;
  70936. private _effectiveTarget;
  70937. private _property;
  70938. /**
  70939. * Instantiate the action
  70940. * @param triggerOptions defines the trigger options
  70941. * @param target defines the object containing the boolean
  70942. * @param propertyPath defines the path to the boolean property in the target object
  70943. * @param condition defines the trigger related conditions
  70944. */
  70945. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70946. /** @hidden */
  70947. _prepare(): void;
  70948. /**
  70949. * Execute the action toggle the boolean value.
  70950. */
  70951. execute(): void;
  70952. /**
  70953. * Serializes the actions and its related information.
  70954. * @param parent defines the object to serialize in
  70955. * @returns the serialized object
  70956. */
  70957. serialize(parent: any): any;
  70958. }
  70959. /**
  70960. * This defines an action responsible to set a the state field of the target
  70961. * to a desired value once triggered.
  70962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70963. */
  70964. export class SetStateAction extends Action {
  70965. /**
  70966. * The value to store in the state field.
  70967. */
  70968. value: string;
  70969. private _target;
  70970. /**
  70971. * Instantiate the action
  70972. * @param triggerOptions defines the trigger options
  70973. * @param target defines the object containing the state property
  70974. * @param value defines the value to store in the state field
  70975. * @param condition defines the trigger related conditions
  70976. */
  70977. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70978. /**
  70979. * Execute the action and store the value on the target state property.
  70980. */
  70981. execute(): void;
  70982. /**
  70983. * Serializes the actions and its related information.
  70984. * @param parent defines the object to serialize in
  70985. * @returns the serialized object
  70986. */
  70987. serialize(parent: any): any;
  70988. }
  70989. /**
  70990. * This defines an action responsible to set a property of the target
  70991. * to a desired value once triggered.
  70992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70993. */
  70994. export class SetValueAction extends Action {
  70995. /**
  70996. * The path of the property to set in the target.
  70997. */
  70998. propertyPath: string;
  70999. /**
  71000. * The value to set in the property
  71001. */
  71002. value: any;
  71003. private _target;
  71004. private _effectiveTarget;
  71005. private _property;
  71006. /**
  71007. * Instantiate the action
  71008. * @param triggerOptions defines the trigger options
  71009. * @param target defines the object containing the property
  71010. * @param propertyPath defines the path of the property to set in the target
  71011. * @param value defines the value to set in the property
  71012. * @param condition defines the trigger related conditions
  71013. */
  71014. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  71015. /** @hidden */
  71016. _prepare(): void;
  71017. /**
  71018. * Execute the action and set the targetted property to the desired value.
  71019. */
  71020. execute(): void;
  71021. /**
  71022. * Serializes the actions and its related information.
  71023. * @param parent defines the object to serialize in
  71024. * @returns the serialized object
  71025. */
  71026. serialize(parent: any): any;
  71027. }
  71028. /**
  71029. * This defines an action responsible to increment the target value
  71030. * to a desired value once triggered.
  71031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71032. */
  71033. export class IncrementValueAction extends Action {
  71034. /**
  71035. * The path of the property to increment in the target.
  71036. */
  71037. propertyPath: string;
  71038. /**
  71039. * The value we should increment the property by.
  71040. */
  71041. value: any;
  71042. private _target;
  71043. private _effectiveTarget;
  71044. private _property;
  71045. /**
  71046. * Instantiate the action
  71047. * @param triggerOptions defines the trigger options
  71048. * @param target defines the object containing the property
  71049. * @param propertyPath defines the path of the property to increment in the target
  71050. * @param value defines the value value we should increment the property by
  71051. * @param condition defines the trigger related conditions
  71052. */
  71053. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  71054. /** @hidden */
  71055. _prepare(): void;
  71056. /**
  71057. * Execute the action and increment the target of the value amount.
  71058. */
  71059. execute(): void;
  71060. /**
  71061. * Serializes the actions and its related information.
  71062. * @param parent defines the object to serialize in
  71063. * @returns the serialized object
  71064. */
  71065. serialize(parent: any): any;
  71066. }
  71067. /**
  71068. * This defines an action responsible to start an animation once triggered.
  71069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71070. */
  71071. export class PlayAnimationAction extends Action {
  71072. /**
  71073. * Where the animation should start (animation frame)
  71074. */
  71075. from: number;
  71076. /**
  71077. * Where the animation should stop (animation frame)
  71078. */
  71079. to: number;
  71080. /**
  71081. * Define if the animation should loop or stop after the first play.
  71082. */
  71083. loop?: boolean;
  71084. private _target;
  71085. /**
  71086. * Instantiate the action
  71087. * @param triggerOptions defines the trigger options
  71088. * @param target defines the target animation or animation name
  71089. * @param from defines from where the animation should start (animation frame)
  71090. * @param end defines where the animation should stop (animation frame)
  71091. * @param loop defines if the animation should loop or stop after the first play
  71092. * @param condition defines the trigger related conditions
  71093. */
  71094. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  71095. /** @hidden */
  71096. _prepare(): void;
  71097. /**
  71098. * Execute the action and play the animation.
  71099. */
  71100. execute(): void;
  71101. /**
  71102. * Serializes the actions and its related information.
  71103. * @param parent defines the object to serialize in
  71104. * @returns the serialized object
  71105. */
  71106. serialize(parent: any): any;
  71107. }
  71108. /**
  71109. * This defines an action responsible to stop an animation once triggered.
  71110. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71111. */
  71112. export class StopAnimationAction extends Action {
  71113. private _target;
  71114. /**
  71115. * Instantiate the action
  71116. * @param triggerOptions defines the trigger options
  71117. * @param target defines the target animation or animation name
  71118. * @param condition defines the trigger related conditions
  71119. */
  71120. constructor(triggerOptions: any, target: any, condition?: Condition);
  71121. /** @hidden */
  71122. _prepare(): void;
  71123. /**
  71124. * Execute the action and stop the animation.
  71125. */
  71126. execute(): void;
  71127. /**
  71128. * Serializes the actions and its related information.
  71129. * @param parent defines the object to serialize in
  71130. * @returns the serialized object
  71131. */
  71132. serialize(parent: any): any;
  71133. }
  71134. /**
  71135. * This defines an action responsible that does nothing once triggered.
  71136. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71137. */
  71138. export class DoNothingAction extends Action {
  71139. /**
  71140. * Instantiate the action
  71141. * @param triggerOptions defines the trigger options
  71142. * @param condition defines the trigger related conditions
  71143. */
  71144. constructor(triggerOptions?: any, condition?: Condition);
  71145. /**
  71146. * Execute the action and do nothing.
  71147. */
  71148. execute(): void;
  71149. /**
  71150. * Serializes the actions and its related information.
  71151. * @param parent defines the object to serialize in
  71152. * @returns the serialized object
  71153. */
  71154. serialize(parent: any): any;
  71155. }
  71156. /**
  71157. * This defines an action responsible to trigger several actions once triggered.
  71158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71159. */
  71160. export class CombineAction extends Action {
  71161. /**
  71162. * The list of aggregated animations to run.
  71163. */
  71164. children: Action[];
  71165. /**
  71166. * Instantiate the action
  71167. * @param triggerOptions defines the trigger options
  71168. * @param children defines the list of aggregated animations to run
  71169. * @param condition defines the trigger related conditions
  71170. */
  71171. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  71172. /** @hidden */
  71173. _prepare(): void;
  71174. /**
  71175. * Execute the action and executes all the aggregated actions.
  71176. */
  71177. execute(evt: ActionEvent): void;
  71178. /**
  71179. * Serializes the actions and its related information.
  71180. * @param parent defines the object to serialize in
  71181. * @returns the serialized object
  71182. */
  71183. serialize(parent: any): any;
  71184. }
  71185. /**
  71186. * This defines an action responsible to run code (external event) once triggered.
  71187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71188. */
  71189. export class ExecuteCodeAction extends Action {
  71190. /**
  71191. * The callback function to run.
  71192. */
  71193. func: (evt: ActionEvent) => void;
  71194. /**
  71195. * Instantiate the action
  71196. * @param triggerOptions defines the trigger options
  71197. * @param func defines the callback function to run
  71198. * @param condition defines the trigger related conditions
  71199. */
  71200. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  71201. /**
  71202. * Execute the action and run the attached code.
  71203. */
  71204. execute(evt: ActionEvent): void;
  71205. }
  71206. /**
  71207. * This defines an action responsible to set the parent property of the target once triggered.
  71208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71209. */
  71210. export class SetParentAction extends Action {
  71211. private _parent;
  71212. private _target;
  71213. /**
  71214. * Instantiate the action
  71215. * @param triggerOptions defines the trigger options
  71216. * @param target defines the target containing the parent property
  71217. * @param parent defines from where the animation should start (animation frame)
  71218. * @param condition defines the trigger related conditions
  71219. */
  71220. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  71221. /** @hidden */
  71222. _prepare(): void;
  71223. /**
  71224. * Execute the action and set the parent property.
  71225. */
  71226. execute(): void;
  71227. /**
  71228. * Serializes the actions and its related information.
  71229. * @param parent defines the object to serialize in
  71230. * @returns the serialized object
  71231. */
  71232. serialize(parent: any): any;
  71233. }
  71234. }
  71235. declare module BABYLON {
  71236. /**
  71237. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  71238. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  71239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71240. */
  71241. export class ActionManager extends AbstractActionManager {
  71242. /**
  71243. * Nothing
  71244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71245. */
  71246. static readonly NothingTrigger: number;
  71247. /**
  71248. * On pick
  71249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71250. */
  71251. static readonly OnPickTrigger: number;
  71252. /**
  71253. * On left pick
  71254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71255. */
  71256. static readonly OnLeftPickTrigger: number;
  71257. /**
  71258. * On right pick
  71259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71260. */
  71261. static readonly OnRightPickTrigger: number;
  71262. /**
  71263. * On center pick
  71264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71265. */
  71266. static readonly OnCenterPickTrigger: number;
  71267. /**
  71268. * On pick down
  71269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71270. */
  71271. static readonly OnPickDownTrigger: number;
  71272. /**
  71273. * On double pick
  71274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71275. */
  71276. static readonly OnDoublePickTrigger: number;
  71277. /**
  71278. * On pick up
  71279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71280. */
  71281. static readonly OnPickUpTrigger: number;
  71282. /**
  71283. * On pick out.
  71284. * This trigger will only be raised if you also declared a OnPickDown
  71285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71286. */
  71287. static readonly OnPickOutTrigger: number;
  71288. /**
  71289. * On long press
  71290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71291. */
  71292. static readonly OnLongPressTrigger: number;
  71293. /**
  71294. * On pointer over
  71295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71296. */
  71297. static readonly OnPointerOverTrigger: number;
  71298. /**
  71299. * On pointer out
  71300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71301. */
  71302. static readonly OnPointerOutTrigger: number;
  71303. /**
  71304. * On every frame
  71305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71306. */
  71307. static readonly OnEveryFrameTrigger: number;
  71308. /**
  71309. * On intersection enter
  71310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71311. */
  71312. static readonly OnIntersectionEnterTrigger: number;
  71313. /**
  71314. * On intersection exit
  71315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71316. */
  71317. static readonly OnIntersectionExitTrigger: number;
  71318. /**
  71319. * On key down
  71320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71321. */
  71322. static readonly OnKeyDownTrigger: number;
  71323. /**
  71324. * On key up
  71325. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71326. */
  71327. static readonly OnKeyUpTrigger: number;
  71328. private _scene;
  71329. /**
  71330. * Creates a new action manager
  71331. * @param scene defines the hosting scene
  71332. */
  71333. constructor(scene: Scene);
  71334. /**
  71335. * Releases all associated resources
  71336. */
  71337. dispose(): void;
  71338. /**
  71339. * Gets hosting scene
  71340. * @returns the hosting scene
  71341. */
  71342. getScene(): Scene;
  71343. /**
  71344. * Does this action manager handles actions of any of the given triggers
  71345. * @param triggers defines the triggers to be tested
  71346. * @return a boolean indicating whether one (or more) of the triggers is handled
  71347. */
  71348. hasSpecificTriggers(triggers: number[]): boolean;
  71349. /**
  71350. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  71351. * speed.
  71352. * @param triggerA defines the trigger to be tested
  71353. * @param triggerB defines the trigger to be tested
  71354. * @return a boolean indicating whether one (or more) of the triggers is handled
  71355. */
  71356. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  71357. /**
  71358. * Does this action manager handles actions of a given trigger
  71359. * @param trigger defines the trigger to be tested
  71360. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  71361. * @return whether the trigger is handled
  71362. */
  71363. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  71364. /**
  71365. * Does this action manager has pointer triggers
  71366. */
  71367. readonly hasPointerTriggers: boolean;
  71368. /**
  71369. * Does this action manager has pick triggers
  71370. */
  71371. readonly hasPickTriggers: boolean;
  71372. /**
  71373. * Registers an action to this action manager
  71374. * @param action defines the action to be registered
  71375. * @return the action amended (prepared) after registration
  71376. */
  71377. registerAction(action: IAction): Nullable<IAction>;
  71378. /**
  71379. * Unregisters an action to this action manager
  71380. * @param action defines the action to be unregistered
  71381. * @return a boolean indicating whether the action has been unregistered
  71382. */
  71383. unregisterAction(action: IAction): Boolean;
  71384. /**
  71385. * Process a specific trigger
  71386. * @param trigger defines the trigger to process
  71387. * @param evt defines the event details to be processed
  71388. */
  71389. processTrigger(trigger: number, evt?: IActionEvent): void;
  71390. /** @hidden */
  71391. _getEffectiveTarget(target: any, propertyPath: string): any;
  71392. /** @hidden */
  71393. _getProperty(propertyPath: string): string;
  71394. /**
  71395. * Serialize this manager to a JSON object
  71396. * @param name defines the property name to store this manager
  71397. * @returns a JSON representation of this manager
  71398. */
  71399. serialize(name: string): any;
  71400. /**
  71401. * Creates a new ActionManager from a JSON data
  71402. * @param parsedActions defines the JSON data to read from
  71403. * @param object defines the hosting mesh
  71404. * @param scene defines the hosting scene
  71405. */
  71406. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  71407. /**
  71408. * Get a trigger name by index
  71409. * @param trigger defines the trigger index
  71410. * @returns a trigger name
  71411. */
  71412. static GetTriggerName(trigger: number): string;
  71413. }
  71414. }
  71415. declare module BABYLON {
  71416. /**
  71417. * Class representing a ray with position and direction
  71418. */
  71419. export class Ray {
  71420. /** origin point */
  71421. origin: Vector3;
  71422. /** direction */
  71423. direction: Vector3;
  71424. /** length of the ray */
  71425. length: number;
  71426. private static readonly TmpVector3;
  71427. private _tmpRay;
  71428. /**
  71429. * Creates a new ray
  71430. * @param origin origin point
  71431. * @param direction direction
  71432. * @param length length of the ray
  71433. */
  71434. constructor(
  71435. /** origin point */
  71436. origin: Vector3,
  71437. /** direction */
  71438. direction: Vector3,
  71439. /** length of the ray */
  71440. length?: number);
  71441. /**
  71442. * Checks if the ray intersects a box
  71443. * @param minimum bound of the box
  71444. * @param maximum bound of the box
  71445. * @param intersectionTreshold extra extend to be added to the box in all direction
  71446. * @returns if the box was hit
  71447. */
  71448. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  71449. /**
  71450. * Checks if the ray intersects a box
  71451. * @param box the bounding box to check
  71452. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  71453. * @returns if the box was hit
  71454. */
  71455. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  71456. /**
  71457. * If the ray hits a sphere
  71458. * @param sphere the bounding sphere to check
  71459. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  71460. * @returns true if it hits the sphere
  71461. */
  71462. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  71463. /**
  71464. * If the ray hits a triange
  71465. * @param vertex0 triangle vertex
  71466. * @param vertex1 triangle vertex
  71467. * @param vertex2 triangle vertex
  71468. * @returns intersection information if hit
  71469. */
  71470. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  71471. /**
  71472. * Checks if ray intersects a plane
  71473. * @param plane the plane to check
  71474. * @returns the distance away it was hit
  71475. */
  71476. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  71477. /**
  71478. * Checks if ray intersects a mesh
  71479. * @param mesh the mesh to check
  71480. * @param fastCheck if only the bounding box should checked
  71481. * @returns picking info of the intersecton
  71482. */
  71483. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  71484. /**
  71485. * Checks if ray intersects a mesh
  71486. * @param meshes the meshes to check
  71487. * @param fastCheck if only the bounding box should checked
  71488. * @param results array to store result in
  71489. * @returns Array of picking infos
  71490. */
  71491. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  71492. private _comparePickingInfo;
  71493. private static smallnum;
  71494. private static rayl;
  71495. /**
  71496. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  71497. * @param sega the first point of the segment to test the intersection against
  71498. * @param segb the second point of the segment to test the intersection against
  71499. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  71500. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  71501. */
  71502. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  71503. /**
  71504. * Update the ray from viewport position
  71505. * @param x position
  71506. * @param y y position
  71507. * @param viewportWidth viewport width
  71508. * @param viewportHeight viewport height
  71509. * @param world world matrix
  71510. * @param view view matrix
  71511. * @param projection projection matrix
  71512. * @returns this ray updated
  71513. */
  71514. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71515. /**
  71516. * Creates a ray with origin and direction of 0,0,0
  71517. * @returns the new ray
  71518. */
  71519. static Zero(): Ray;
  71520. /**
  71521. * Creates a new ray from screen space and viewport
  71522. * @param x position
  71523. * @param y y position
  71524. * @param viewportWidth viewport width
  71525. * @param viewportHeight viewport height
  71526. * @param world world matrix
  71527. * @param view view matrix
  71528. * @param projection projection matrix
  71529. * @returns new ray
  71530. */
  71531. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71532. /**
  71533. * 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
  71534. * transformed to the given world matrix.
  71535. * @param origin The origin point
  71536. * @param end The end point
  71537. * @param world a matrix to transform the ray to. Default is the identity matrix.
  71538. * @returns the new ray
  71539. */
  71540. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  71541. /**
  71542. * Transforms a ray by a matrix
  71543. * @param ray ray to transform
  71544. * @param matrix matrix to apply
  71545. * @returns the resulting new ray
  71546. */
  71547. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  71548. /**
  71549. * Transforms a ray by a matrix
  71550. * @param ray ray to transform
  71551. * @param matrix matrix to apply
  71552. * @param result ray to store result in
  71553. */
  71554. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  71555. /**
  71556. * Unproject a ray from screen space to object space
  71557. * @param sourceX defines the screen space x coordinate to use
  71558. * @param sourceY defines the screen space y coordinate to use
  71559. * @param viewportWidth defines the current width of the viewport
  71560. * @param viewportHeight defines the current height of the viewport
  71561. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71562. * @param view defines the view matrix to use
  71563. * @param projection defines the projection matrix to use
  71564. */
  71565. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  71566. }
  71567. /**
  71568. * Type used to define predicate used to select faces when a mesh intersection is detected
  71569. */
  71570. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  71571. interface Scene {
  71572. /** @hidden */
  71573. _tempPickingRay: Nullable<Ray>;
  71574. /** @hidden */
  71575. _cachedRayForTransform: Ray;
  71576. /** @hidden */
  71577. _pickWithRayInverseMatrix: Matrix;
  71578. /** @hidden */
  71579. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  71580. /** @hidden */
  71581. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  71582. }
  71583. }
  71584. declare module BABYLON {
  71585. /**
  71586. * Groups all the scene component constants in one place to ease maintenance.
  71587. * @hidden
  71588. */
  71589. export class SceneComponentConstants {
  71590. static readonly NAME_EFFECTLAYER: string;
  71591. static readonly NAME_LAYER: string;
  71592. static readonly NAME_LENSFLARESYSTEM: string;
  71593. static readonly NAME_BOUNDINGBOXRENDERER: string;
  71594. static readonly NAME_PARTICLESYSTEM: string;
  71595. static readonly NAME_GAMEPAD: string;
  71596. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  71597. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  71598. static readonly NAME_DEPTHRENDERER: string;
  71599. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  71600. static readonly NAME_SPRITE: string;
  71601. static readonly NAME_OUTLINERENDERER: string;
  71602. static readonly NAME_PROCEDURALTEXTURE: string;
  71603. static readonly NAME_SHADOWGENERATOR: string;
  71604. static readonly NAME_OCTREE: string;
  71605. static readonly NAME_PHYSICSENGINE: string;
  71606. static readonly NAME_AUDIO: string;
  71607. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  71608. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71609. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  71610. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71611. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  71612. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  71613. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  71614. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  71615. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  71616. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  71617. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  71618. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  71619. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  71620. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  71621. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  71622. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  71623. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  71624. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  71625. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  71626. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  71627. static readonly STEP_AFTERRENDER_AUDIO: number;
  71628. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  71629. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  71630. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  71631. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  71632. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  71633. static readonly STEP_POINTERMOVE_SPRITE: number;
  71634. static readonly STEP_POINTERDOWN_SPRITE: number;
  71635. static readonly STEP_POINTERUP_SPRITE: number;
  71636. }
  71637. /**
  71638. * This represents a scene component.
  71639. *
  71640. * This is used to decouple the dependency the scene is having on the different workloads like
  71641. * layers, post processes...
  71642. */
  71643. export interface ISceneComponent {
  71644. /**
  71645. * The name of the component. Each component must have a unique name.
  71646. */
  71647. name: string;
  71648. /**
  71649. * The scene the component belongs to.
  71650. */
  71651. scene: Scene;
  71652. /**
  71653. * Register the component to one instance of a scene.
  71654. */
  71655. register(): void;
  71656. /**
  71657. * Rebuilds the elements related to this component in case of
  71658. * context lost for instance.
  71659. */
  71660. rebuild(): void;
  71661. /**
  71662. * Disposes the component and the associated ressources.
  71663. */
  71664. dispose(): void;
  71665. }
  71666. /**
  71667. * This represents a SERIALIZABLE scene component.
  71668. *
  71669. * This extends Scene Component to add Serialization methods on top.
  71670. */
  71671. export interface ISceneSerializableComponent extends ISceneComponent {
  71672. /**
  71673. * Adds all the element from the container to the scene
  71674. * @param container the container holding the elements
  71675. */
  71676. addFromContainer(container: AbstractScene): void;
  71677. /**
  71678. * Removes all the elements in the container from the scene
  71679. * @param container contains the elements to remove
  71680. * @param dispose if the removed element should be disposed (default: false)
  71681. */
  71682. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71683. /**
  71684. * Serializes the component data to the specified json object
  71685. * @param serializationObject The object to serialize to
  71686. */
  71687. serialize(serializationObject: any): void;
  71688. }
  71689. /**
  71690. * Strong typing of a Mesh related stage step action
  71691. */
  71692. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  71693. /**
  71694. * Strong typing of a Evaluate Sub Mesh related stage step action
  71695. */
  71696. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  71697. /**
  71698. * Strong typing of a Active Mesh related stage step action
  71699. */
  71700. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  71701. /**
  71702. * Strong typing of a Camera related stage step action
  71703. */
  71704. export type CameraStageAction = (camera: Camera) => void;
  71705. /**
  71706. * Strong typing of a Camera Frame buffer related stage step action
  71707. */
  71708. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  71709. /**
  71710. * Strong typing of a Render Target related stage step action
  71711. */
  71712. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  71713. /**
  71714. * Strong typing of a RenderingGroup related stage step action
  71715. */
  71716. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  71717. /**
  71718. * Strong typing of a Mesh Render related stage step action
  71719. */
  71720. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  71721. /**
  71722. * Strong typing of a simple stage step action
  71723. */
  71724. export type SimpleStageAction = () => void;
  71725. /**
  71726. * Strong typing of a render target action.
  71727. */
  71728. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  71729. /**
  71730. * Strong typing of a pointer move action.
  71731. */
  71732. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  71733. /**
  71734. * Strong typing of a pointer up/down action.
  71735. */
  71736. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  71737. /**
  71738. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  71739. * @hidden
  71740. */
  71741. export class Stage<T extends Function> extends Array<{
  71742. index: number;
  71743. component: ISceneComponent;
  71744. action: T;
  71745. }> {
  71746. /**
  71747. * Hide ctor from the rest of the world.
  71748. * @param items The items to add.
  71749. */
  71750. private constructor();
  71751. /**
  71752. * Creates a new Stage.
  71753. * @returns A new instance of a Stage
  71754. */
  71755. static Create<T extends Function>(): Stage<T>;
  71756. /**
  71757. * Registers a step in an ordered way in the targeted stage.
  71758. * @param index Defines the position to register the step in
  71759. * @param component Defines the component attached to the step
  71760. * @param action Defines the action to launch during the step
  71761. */
  71762. registerStep(index: number, component: ISceneComponent, action: T): void;
  71763. /**
  71764. * Clears all the steps from the stage.
  71765. */
  71766. clear(): void;
  71767. }
  71768. }
  71769. declare module BABYLON {
  71770. interface Scene {
  71771. /** @hidden */
  71772. _pointerOverSprite: Nullable<Sprite>;
  71773. /** @hidden */
  71774. _pickedDownSprite: Nullable<Sprite>;
  71775. /** @hidden */
  71776. _tempSpritePickingRay: Nullable<Ray>;
  71777. /**
  71778. * All of the sprite managers added to this scene
  71779. * @see http://doc.babylonjs.com/babylon101/sprites
  71780. */
  71781. spriteManagers: Array<ISpriteManager>;
  71782. /**
  71783. * An event triggered when sprites rendering is about to start
  71784. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71785. */
  71786. onBeforeSpritesRenderingObservable: Observable<Scene>;
  71787. /**
  71788. * An event triggered when sprites rendering is done
  71789. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71790. */
  71791. onAfterSpritesRenderingObservable: Observable<Scene>;
  71792. /** @hidden */
  71793. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71794. /** Launch a ray to try to pick a sprite in the scene
  71795. * @param x position on screen
  71796. * @param y position on screen
  71797. * @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
  71798. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71799. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  71800. * @returns a PickingInfo
  71801. */
  71802. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71803. /** Use the given ray to pick a sprite in the scene
  71804. * @param ray The ray (in world space) to use to pick meshes
  71805. * @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
  71806. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71807. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  71808. * @returns a PickingInfo
  71809. */
  71810. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71811. /**
  71812. * Force the sprite under the pointer
  71813. * @param sprite defines the sprite to use
  71814. */
  71815. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  71816. /**
  71817. * Gets the sprite under the pointer
  71818. * @returns a Sprite or null if no sprite is under the pointer
  71819. */
  71820. getPointerOverSprite(): Nullable<Sprite>;
  71821. }
  71822. /**
  71823. * Defines the sprite scene component responsible to manage sprites
  71824. * in a given scene.
  71825. */
  71826. export class SpriteSceneComponent implements ISceneComponent {
  71827. /**
  71828. * The component name helpfull to identify the component in the list of scene components.
  71829. */
  71830. readonly name: string;
  71831. /**
  71832. * The scene the component belongs to.
  71833. */
  71834. scene: Scene;
  71835. /** @hidden */
  71836. private _spritePredicate;
  71837. /**
  71838. * Creates a new instance of the component for the given scene
  71839. * @param scene Defines the scene to register the component in
  71840. */
  71841. constructor(scene: Scene);
  71842. /**
  71843. * Registers the component in a given scene
  71844. */
  71845. register(): void;
  71846. /**
  71847. * Rebuilds the elements related to this component in case of
  71848. * context lost for instance.
  71849. */
  71850. rebuild(): void;
  71851. /**
  71852. * Disposes the component and the associated ressources.
  71853. */
  71854. dispose(): void;
  71855. private _pickSpriteButKeepRay;
  71856. private _pointerMove;
  71857. private _pointerDown;
  71858. private _pointerUp;
  71859. }
  71860. }
  71861. declare module BABYLON {
  71862. /** @hidden */
  71863. export var fogFragmentDeclaration: {
  71864. name: string;
  71865. shader: string;
  71866. };
  71867. }
  71868. declare module BABYLON {
  71869. /** @hidden */
  71870. export var fogFragment: {
  71871. name: string;
  71872. shader: string;
  71873. };
  71874. }
  71875. declare module BABYLON {
  71876. /** @hidden */
  71877. export var spritesPixelShader: {
  71878. name: string;
  71879. shader: string;
  71880. };
  71881. }
  71882. declare module BABYLON {
  71883. /** @hidden */
  71884. export var fogVertexDeclaration: {
  71885. name: string;
  71886. shader: string;
  71887. };
  71888. }
  71889. declare module BABYLON {
  71890. /** @hidden */
  71891. export var spritesVertexShader: {
  71892. name: string;
  71893. shader: string;
  71894. };
  71895. }
  71896. declare module BABYLON {
  71897. /**
  71898. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71899. */
  71900. export interface ISpriteManager extends IDisposable {
  71901. /**
  71902. * Restricts the camera to viewing objects with the same layerMask.
  71903. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71904. */
  71905. layerMask: number;
  71906. /**
  71907. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71908. */
  71909. isPickable: boolean;
  71910. /**
  71911. * Specifies the rendering group id for this mesh (0 by default)
  71912. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71913. */
  71914. renderingGroupId: number;
  71915. /**
  71916. * Defines the list of sprites managed by the manager.
  71917. */
  71918. sprites: Array<Sprite>;
  71919. /**
  71920. * Tests the intersection of a sprite with a specific ray.
  71921. * @param ray The ray we are sending to test the collision
  71922. * @param camera The camera space we are sending rays in
  71923. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71924. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71925. * @returns picking info or null.
  71926. */
  71927. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71928. /**
  71929. * Renders the list of sprites on screen.
  71930. */
  71931. render(): void;
  71932. }
  71933. /**
  71934. * Class used to manage multiple sprites on the same spritesheet
  71935. * @see http://doc.babylonjs.com/babylon101/sprites
  71936. */
  71937. export class SpriteManager implements ISpriteManager {
  71938. /** defines the manager's name */
  71939. name: string;
  71940. /** Gets the list of sprites */
  71941. sprites: Sprite[];
  71942. /** Gets or sets the rendering group id (0 by default) */
  71943. renderingGroupId: number;
  71944. /** Gets or sets camera layer mask */
  71945. layerMask: number;
  71946. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71947. fogEnabled: boolean;
  71948. /** Gets or sets a boolean indicating if the sprites are pickable */
  71949. isPickable: boolean;
  71950. /** Defines the default width of a cell in the spritesheet */
  71951. cellWidth: number;
  71952. /** Defines the default height of a cell in the spritesheet */
  71953. cellHeight: number;
  71954. /**
  71955. * An event triggered when the manager is disposed.
  71956. */
  71957. onDisposeObservable: Observable<SpriteManager>;
  71958. private _onDisposeObserver;
  71959. /**
  71960. * Callback called when the manager is disposed
  71961. */
  71962. onDispose: () => void;
  71963. private _capacity;
  71964. private _spriteTexture;
  71965. private _epsilon;
  71966. private _scene;
  71967. private _vertexData;
  71968. private _buffer;
  71969. private _vertexBuffers;
  71970. private _indexBuffer;
  71971. private _effectBase;
  71972. private _effectFog;
  71973. /**
  71974. * Gets or sets the spritesheet texture
  71975. */
  71976. texture: Texture;
  71977. /**
  71978. * Creates a new sprite manager
  71979. * @param name defines the manager's name
  71980. * @param imgUrl defines the sprite sheet url
  71981. * @param capacity defines the maximum allowed number of sprites
  71982. * @param cellSize defines the size of a sprite cell
  71983. * @param scene defines the hosting scene
  71984. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71985. * @param samplingMode defines the smapling mode to use with spritesheet
  71986. */
  71987. constructor(
  71988. /** defines the manager's name */
  71989. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71990. private _appendSpriteVertex;
  71991. /**
  71992. * Intersects the sprites with a ray
  71993. * @param ray defines the ray to intersect with
  71994. * @param camera defines the current active camera
  71995. * @param predicate defines a predicate used to select candidate sprites
  71996. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71997. * @returns null if no hit or a PickingInfo
  71998. */
  71999. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  72000. /**
  72001. * Render all child sprites
  72002. */
  72003. render(): void;
  72004. /**
  72005. * Release associated resources
  72006. */
  72007. dispose(): void;
  72008. }
  72009. }
  72010. declare module BABYLON {
  72011. /**
  72012. * Class used to represent a sprite
  72013. * @see http://doc.babylonjs.com/babylon101/sprites
  72014. */
  72015. export class Sprite {
  72016. /** defines the name */
  72017. name: string;
  72018. /** Gets or sets the current world position */
  72019. position: Vector3;
  72020. /** Gets or sets the main color */
  72021. color: Color4;
  72022. /** Gets or sets the width */
  72023. width: number;
  72024. /** Gets or sets the height */
  72025. height: number;
  72026. /** Gets or sets rotation angle */
  72027. angle: number;
  72028. /** Gets or sets the cell index in the sprite sheet */
  72029. cellIndex: number;
  72030. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  72031. invertU: number;
  72032. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  72033. invertV: number;
  72034. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  72035. disposeWhenFinishedAnimating: boolean;
  72036. /** Gets the list of attached animations */
  72037. animations: Animation[];
  72038. /** Gets or sets a boolean indicating if the sprite can be picked */
  72039. isPickable: boolean;
  72040. /**
  72041. * Gets or sets the associated action manager
  72042. */
  72043. actionManager: Nullable<ActionManager>;
  72044. private _animationStarted;
  72045. private _loopAnimation;
  72046. private _fromIndex;
  72047. private _toIndex;
  72048. private _delay;
  72049. private _direction;
  72050. private _manager;
  72051. private _time;
  72052. private _onAnimationEnd;
  72053. /**
  72054. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  72055. */
  72056. isVisible: boolean;
  72057. /**
  72058. * Gets or sets the sprite size
  72059. */
  72060. size: number;
  72061. /**
  72062. * Creates a new Sprite
  72063. * @param name defines the name
  72064. * @param manager defines the manager
  72065. */
  72066. constructor(
  72067. /** defines the name */
  72068. name: string, manager: ISpriteManager);
  72069. /**
  72070. * Starts an animation
  72071. * @param from defines the initial key
  72072. * @param to defines the end key
  72073. * @param loop defines if the animation must loop
  72074. * @param delay defines the start delay (in ms)
  72075. * @param onAnimationEnd defines a callback to call when animation ends
  72076. */
  72077. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  72078. /** Stops current animation (if any) */
  72079. stopAnimation(): void;
  72080. /** @hidden */
  72081. _animate(deltaTime: number): void;
  72082. /** Release associated resources */
  72083. dispose(): void;
  72084. }
  72085. }
  72086. declare module BABYLON {
  72087. /**
  72088. * Information about the result of picking within a scene
  72089. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  72090. */
  72091. export class PickingInfo {
  72092. /** @hidden */
  72093. _pickingUnavailable: boolean;
  72094. /**
  72095. * If the pick collided with an object
  72096. */
  72097. hit: boolean;
  72098. /**
  72099. * Distance away where the pick collided
  72100. */
  72101. distance: number;
  72102. /**
  72103. * The location of pick collision
  72104. */
  72105. pickedPoint: Nullable<Vector3>;
  72106. /**
  72107. * The mesh corresponding the the pick collision
  72108. */
  72109. pickedMesh: Nullable<AbstractMesh>;
  72110. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  72111. bu: number;
  72112. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  72113. bv: number;
  72114. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  72115. faceId: number;
  72116. /** Id of the the submesh that was picked */
  72117. subMeshId: number;
  72118. /** If a sprite was picked, this will be the sprite the pick collided with */
  72119. pickedSprite: Nullable<Sprite>;
  72120. /**
  72121. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  72122. */
  72123. originMesh: Nullable<AbstractMesh>;
  72124. /**
  72125. * The ray that was used to perform the picking.
  72126. */
  72127. ray: Nullable<Ray>;
  72128. /**
  72129. * Gets the normal correspodning to the face the pick collided with
  72130. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  72131. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  72132. * @returns The normal correspodning to the face the pick collided with
  72133. */
  72134. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  72135. /**
  72136. * Gets the texture coordinates of where the pick occured
  72137. * @returns the vector containing the coordnates of the texture
  72138. */
  72139. getTextureCoordinates(): Nullable<Vector2>;
  72140. }
  72141. }
  72142. declare module BABYLON {
  72143. /**
  72144. * Gather the list of pointer event types as constants.
  72145. */
  72146. export class PointerEventTypes {
  72147. /**
  72148. * 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.
  72149. */
  72150. static readonly POINTERDOWN: number;
  72151. /**
  72152. * The pointerup event is fired when a pointer is no longer active.
  72153. */
  72154. static readonly POINTERUP: number;
  72155. /**
  72156. * The pointermove event is fired when a pointer changes coordinates.
  72157. */
  72158. static readonly POINTERMOVE: number;
  72159. /**
  72160. * The pointerwheel event is fired when a mouse wheel has been rotated.
  72161. */
  72162. static readonly POINTERWHEEL: number;
  72163. /**
  72164. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  72165. */
  72166. static readonly POINTERPICK: number;
  72167. /**
  72168. * The pointertap event is fired when a the object has been touched and released without drag.
  72169. */
  72170. static readonly POINTERTAP: number;
  72171. /**
  72172. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  72173. */
  72174. static readonly POINTERDOUBLETAP: number;
  72175. }
  72176. /**
  72177. * Base class of pointer info types.
  72178. */
  72179. export class PointerInfoBase {
  72180. /**
  72181. * Defines the type of event (PointerEventTypes)
  72182. */
  72183. type: number;
  72184. /**
  72185. * Defines the related dom event
  72186. */
  72187. event: PointerEvent | MouseWheelEvent;
  72188. /**
  72189. * Instantiates the base class of pointers info.
  72190. * @param type Defines the type of event (PointerEventTypes)
  72191. * @param event Defines the related dom event
  72192. */
  72193. constructor(
  72194. /**
  72195. * Defines the type of event (PointerEventTypes)
  72196. */
  72197. type: number,
  72198. /**
  72199. * Defines the related dom event
  72200. */
  72201. event: PointerEvent | MouseWheelEvent);
  72202. }
  72203. /**
  72204. * This class is used to store pointer related info for the onPrePointerObservable event.
  72205. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  72206. */
  72207. export class PointerInfoPre extends PointerInfoBase {
  72208. /**
  72209. * Ray from a pointer if availible (eg. 6dof controller)
  72210. */
  72211. ray: Nullable<Ray>;
  72212. /**
  72213. * Defines the local position of the pointer on the canvas.
  72214. */
  72215. localPosition: Vector2;
  72216. /**
  72217. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  72218. */
  72219. skipOnPointerObservable: boolean;
  72220. /**
  72221. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  72222. * @param type Defines the type of event (PointerEventTypes)
  72223. * @param event Defines the related dom event
  72224. * @param localX Defines the local x coordinates of the pointer when the event occured
  72225. * @param localY Defines the local y coordinates of the pointer when the event occured
  72226. */
  72227. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  72228. }
  72229. /**
  72230. * This type contains all the data related to a pointer event in Babylon.js.
  72231. * 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.
  72232. */
  72233. export class PointerInfo extends PointerInfoBase {
  72234. /**
  72235. * Defines the picking info associated to the info (if any)\
  72236. */
  72237. pickInfo: Nullable<PickingInfo>;
  72238. /**
  72239. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  72240. * @param type Defines the type of event (PointerEventTypes)
  72241. * @param event Defines the related dom event
  72242. * @param pickInfo Defines the picking info associated to the info (if any)\
  72243. */
  72244. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  72245. /**
  72246. * Defines the picking info associated to the info (if any)\
  72247. */
  72248. pickInfo: Nullable<PickingInfo>);
  72249. }
  72250. /**
  72251. * Data relating to a touch event on the screen.
  72252. */
  72253. export interface PointerTouch {
  72254. /**
  72255. * X coordinate of touch.
  72256. */
  72257. x: number;
  72258. /**
  72259. * Y coordinate of touch.
  72260. */
  72261. y: number;
  72262. /**
  72263. * Id of touch. Unique for each finger.
  72264. */
  72265. pointerId: number;
  72266. /**
  72267. * Event type passed from DOM.
  72268. */
  72269. type: any;
  72270. }
  72271. }
  72272. declare module BABYLON {
  72273. /**
  72274. * Manage the mouse inputs to control the movement of a free camera.
  72275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72276. */
  72277. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  72278. /**
  72279. * Define if touch is enabled in the mouse input
  72280. */
  72281. touchEnabled: boolean;
  72282. /**
  72283. * Defines the camera the input is attached to.
  72284. */
  72285. camera: FreeCamera;
  72286. /**
  72287. * Defines the buttons associated with the input to handle camera move.
  72288. */
  72289. buttons: number[];
  72290. /**
  72291. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  72292. */
  72293. angularSensibility: number;
  72294. private _pointerInput;
  72295. private _onMouseMove;
  72296. private _observer;
  72297. private previousPosition;
  72298. /**
  72299. * Observable for when a pointer move event occurs containing the move offset
  72300. */
  72301. onPointerMovedObservable: Observable<{
  72302. offsetX: number;
  72303. offsetY: number;
  72304. }>;
  72305. /**
  72306. * @hidden
  72307. * If the camera should be rotated automatically based on pointer movement
  72308. */
  72309. _allowCameraRotation: boolean;
  72310. /**
  72311. * Manage the mouse inputs to control the movement of a free camera.
  72312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72313. * @param touchEnabled Defines if touch is enabled or not
  72314. */
  72315. constructor(
  72316. /**
  72317. * Define if touch is enabled in the mouse input
  72318. */
  72319. touchEnabled?: boolean);
  72320. /**
  72321. * Attach the input controls to a specific dom element to get the input from.
  72322. * @param element Defines the element the controls should be listened from
  72323. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72324. */
  72325. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72326. /**
  72327. * Called on JS contextmenu event.
  72328. * Override this method to provide functionality.
  72329. */
  72330. protected onContextMenu(evt: PointerEvent): void;
  72331. /**
  72332. * Detach the current controls from the specified dom element.
  72333. * @param element Defines the element to stop listening the inputs from
  72334. */
  72335. detachControl(element: Nullable<HTMLElement>): void;
  72336. /**
  72337. * Gets the class name of the current intput.
  72338. * @returns the class name
  72339. */
  72340. getClassName(): string;
  72341. /**
  72342. * Get the friendly name associated with the input class.
  72343. * @returns the input friendly name
  72344. */
  72345. getSimpleName(): string;
  72346. }
  72347. }
  72348. declare module BABYLON {
  72349. /**
  72350. * Manage the touch inputs to control the movement of a free camera.
  72351. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72352. */
  72353. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  72354. /**
  72355. * Defines the camera the input is attached to.
  72356. */
  72357. camera: FreeCamera;
  72358. /**
  72359. * Defines the touch sensibility for rotation.
  72360. * The higher the faster.
  72361. */
  72362. touchAngularSensibility: number;
  72363. /**
  72364. * Defines the touch sensibility for move.
  72365. * The higher the faster.
  72366. */
  72367. touchMoveSensibility: number;
  72368. private _offsetX;
  72369. private _offsetY;
  72370. private _pointerPressed;
  72371. private _pointerInput;
  72372. private _observer;
  72373. private _onLostFocus;
  72374. /**
  72375. * Attach the input controls to a specific dom element to get the input from.
  72376. * @param element Defines the element the controls should be listened from
  72377. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72378. */
  72379. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72380. /**
  72381. * Detach the current controls from the specified dom element.
  72382. * @param element Defines the element to stop listening the inputs from
  72383. */
  72384. detachControl(element: Nullable<HTMLElement>): void;
  72385. /**
  72386. * Update the current camera state depending on the inputs that have been used this frame.
  72387. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72388. */
  72389. checkInputs(): void;
  72390. /**
  72391. * Gets the class name of the current intput.
  72392. * @returns the class name
  72393. */
  72394. getClassName(): string;
  72395. /**
  72396. * Get the friendly name associated with the input class.
  72397. * @returns the input friendly name
  72398. */
  72399. getSimpleName(): string;
  72400. }
  72401. }
  72402. declare module BABYLON {
  72403. /**
  72404. * Default Inputs manager for the FreeCamera.
  72405. * It groups all the default supported inputs for ease of use.
  72406. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72407. */
  72408. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  72409. /**
  72410. * @hidden
  72411. */
  72412. _mouseInput: Nullable<FreeCameraMouseInput>;
  72413. /**
  72414. * Instantiates a new FreeCameraInputsManager.
  72415. * @param camera Defines the camera the inputs belong to
  72416. */
  72417. constructor(camera: FreeCamera);
  72418. /**
  72419. * Add keyboard input support to the input manager.
  72420. * @returns the current input manager
  72421. */
  72422. addKeyboard(): FreeCameraInputsManager;
  72423. /**
  72424. * Add mouse input support to the input manager.
  72425. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  72426. * @returns the current input manager
  72427. */
  72428. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  72429. /**
  72430. * Removes the mouse input support from the manager
  72431. * @returns the current input manager
  72432. */
  72433. removeMouse(): FreeCameraInputsManager;
  72434. /**
  72435. * Add touch input support to the input manager.
  72436. * @returns the current input manager
  72437. */
  72438. addTouch(): FreeCameraInputsManager;
  72439. /**
  72440. * Remove all attached input methods from a camera
  72441. */
  72442. clear(): void;
  72443. }
  72444. }
  72445. declare module BABYLON {
  72446. /**
  72447. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72448. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  72449. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72450. */
  72451. export class FreeCamera extends TargetCamera {
  72452. /**
  72453. * Define the collision ellipsoid of the camera.
  72454. * This is helpful to simulate a camera body like the player body around the camera
  72455. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  72456. */
  72457. ellipsoid: Vector3;
  72458. /**
  72459. * Define an offset for the position of the ellipsoid around the camera.
  72460. * This can be helpful to determine the center of the body near the gravity center of the body
  72461. * instead of its head.
  72462. */
  72463. ellipsoidOffset: Vector3;
  72464. /**
  72465. * Enable or disable collisions of the camera with the rest of the scene objects.
  72466. */
  72467. checkCollisions: boolean;
  72468. /**
  72469. * Enable or disable gravity on the camera.
  72470. */
  72471. applyGravity: boolean;
  72472. /**
  72473. * Define the input manager associated to the camera.
  72474. */
  72475. inputs: FreeCameraInputsManager;
  72476. /**
  72477. * Gets the input sensibility for a mouse input. (default is 2000.0)
  72478. * Higher values reduce sensitivity.
  72479. */
  72480. /**
  72481. * Sets the input sensibility for a mouse input. (default is 2000.0)
  72482. * Higher values reduce sensitivity.
  72483. */
  72484. angularSensibility: number;
  72485. /**
  72486. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72487. */
  72488. keysUp: number[];
  72489. /**
  72490. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72491. */
  72492. keysDown: number[];
  72493. /**
  72494. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72495. */
  72496. keysLeft: number[];
  72497. /**
  72498. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72499. */
  72500. keysRight: number[];
  72501. /**
  72502. * Event raised when the camera collide with a mesh in the scene.
  72503. */
  72504. onCollide: (collidedMesh: AbstractMesh) => void;
  72505. private _collider;
  72506. private _needMoveForGravity;
  72507. private _oldPosition;
  72508. private _diffPosition;
  72509. private _newPosition;
  72510. /** @hidden */
  72511. _localDirection: Vector3;
  72512. /** @hidden */
  72513. _transformedDirection: Vector3;
  72514. /**
  72515. * Instantiates a Free Camera.
  72516. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72517. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  72518. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72519. * @param name Define the name of the camera in the scene
  72520. * @param position Define the start position of the camera in the scene
  72521. * @param scene Define the scene the camera belongs to
  72522. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72523. */
  72524. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72525. /**
  72526. * Attached controls to the current camera.
  72527. * @param element Defines the element the controls should be listened from
  72528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72529. */
  72530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72531. /**
  72532. * Detach the current controls from the camera.
  72533. * The camera will stop reacting to inputs.
  72534. * @param element Defines the element to stop listening the inputs from
  72535. */
  72536. detachControl(element: HTMLElement): void;
  72537. private _collisionMask;
  72538. /**
  72539. * Define a collision mask to limit the list of object the camera can collide with
  72540. */
  72541. collisionMask: number;
  72542. /** @hidden */
  72543. _collideWithWorld(displacement: Vector3): void;
  72544. private _onCollisionPositionChange;
  72545. /** @hidden */
  72546. _checkInputs(): void;
  72547. /** @hidden */
  72548. _decideIfNeedsToMove(): boolean;
  72549. /** @hidden */
  72550. _updatePosition(): void;
  72551. /**
  72552. * Destroy the camera and release the current resources hold by it.
  72553. */
  72554. dispose(): void;
  72555. /**
  72556. * Gets the current object class name.
  72557. * @return the class name
  72558. */
  72559. getClassName(): string;
  72560. }
  72561. }
  72562. declare module BABYLON {
  72563. /**
  72564. * Represents a gamepad control stick position
  72565. */
  72566. export class StickValues {
  72567. /**
  72568. * The x component of the control stick
  72569. */
  72570. x: number;
  72571. /**
  72572. * The y component of the control stick
  72573. */
  72574. y: number;
  72575. /**
  72576. * Initializes the gamepad x and y control stick values
  72577. * @param x The x component of the gamepad control stick value
  72578. * @param y The y component of the gamepad control stick value
  72579. */
  72580. constructor(
  72581. /**
  72582. * The x component of the control stick
  72583. */
  72584. x: number,
  72585. /**
  72586. * The y component of the control stick
  72587. */
  72588. y: number);
  72589. }
  72590. /**
  72591. * An interface which manages callbacks for gamepad button changes
  72592. */
  72593. export interface GamepadButtonChanges {
  72594. /**
  72595. * Called when a gamepad has been changed
  72596. */
  72597. changed: boolean;
  72598. /**
  72599. * Called when a gamepad press event has been triggered
  72600. */
  72601. pressChanged: boolean;
  72602. /**
  72603. * Called when a touch event has been triggered
  72604. */
  72605. touchChanged: boolean;
  72606. /**
  72607. * Called when a value has changed
  72608. */
  72609. valueChanged: boolean;
  72610. }
  72611. /**
  72612. * Represents a gamepad
  72613. */
  72614. export class Gamepad {
  72615. /**
  72616. * The id of the gamepad
  72617. */
  72618. id: string;
  72619. /**
  72620. * The index of the gamepad
  72621. */
  72622. index: number;
  72623. /**
  72624. * The browser gamepad
  72625. */
  72626. browserGamepad: any;
  72627. /**
  72628. * Specifies what type of gamepad this represents
  72629. */
  72630. type: number;
  72631. private _leftStick;
  72632. private _rightStick;
  72633. /** @hidden */
  72634. _isConnected: boolean;
  72635. private _leftStickAxisX;
  72636. private _leftStickAxisY;
  72637. private _rightStickAxisX;
  72638. private _rightStickAxisY;
  72639. /**
  72640. * Triggered when the left control stick has been changed
  72641. */
  72642. private _onleftstickchanged;
  72643. /**
  72644. * Triggered when the right control stick has been changed
  72645. */
  72646. private _onrightstickchanged;
  72647. /**
  72648. * Represents a gamepad controller
  72649. */
  72650. static GAMEPAD: number;
  72651. /**
  72652. * Represents a generic controller
  72653. */
  72654. static GENERIC: number;
  72655. /**
  72656. * Represents an XBox controller
  72657. */
  72658. static XBOX: number;
  72659. /**
  72660. * Represents a pose-enabled controller
  72661. */
  72662. static POSE_ENABLED: number;
  72663. /**
  72664. * Specifies whether the left control stick should be Y-inverted
  72665. */
  72666. protected _invertLeftStickY: boolean;
  72667. /**
  72668. * Specifies if the gamepad has been connected
  72669. */
  72670. readonly isConnected: boolean;
  72671. /**
  72672. * Initializes the gamepad
  72673. * @param id The id of the gamepad
  72674. * @param index The index of the gamepad
  72675. * @param browserGamepad The browser gamepad
  72676. * @param leftStickX The x component of the left joystick
  72677. * @param leftStickY The y component of the left joystick
  72678. * @param rightStickX The x component of the right joystick
  72679. * @param rightStickY The y component of the right joystick
  72680. */
  72681. constructor(
  72682. /**
  72683. * The id of the gamepad
  72684. */
  72685. id: string,
  72686. /**
  72687. * The index of the gamepad
  72688. */
  72689. index: number,
  72690. /**
  72691. * The browser gamepad
  72692. */
  72693. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  72694. /**
  72695. * Callback triggered when the left joystick has changed
  72696. * @param callback
  72697. */
  72698. onleftstickchanged(callback: (values: StickValues) => void): void;
  72699. /**
  72700. * Callback triggered when the right joystick has changed
  72701. * @param callback
  72702. */
  72703. onrightstickchanged(callback: (values: StickValues) => void): void;
  72704. /**
  72705. * Gets the left joystick
  72706. */
  72707. /**
  72708. * Sets the left joystick values
  72709. */
  72710. leftStick: StickValues;
  72711. /**
  72712. * Gets the right joystick
  72713. */
  72714. /**
  72715. * Sets the right joystick value
  72716. */
  72717. rightStick: StickValues;
  72718. /**
  72719. * Updates the gamepad joystick positions
  72720. */
  72721. update(): void;
  72722. /**
  72723. * Disposes the gamepad
  72724. */
  72725. dispose(): void;
  72726. }
  72727. /**
  72728. * Represents a generic gamepad
  72729. */
  72730. export class GenericPad extends Gamepad {
  72731. private _buttons;
  72732. private _onbuttondown;
  72733. private _onbuttonup;
  72734. /**
  72735. * Observable triggered when a button has been pressed
  72736. */
  72737. onButtonDownObservable: Observable<number>;
  72738. /**
  72739. * Observable triggered when a button has been released
  72740. */
  72741. onButtonUpObservable: Observable<number>;
  72742. /**
  72743. * Callback triggered when a button has been pressed
  72744. * @param callback Called when a button has been pressed
  72745. */
  72746. onbuttondown(callback: (buttonPressed: number) => void): void;
  72747. /**
  72748. * Callback triggered when a button has been released
  72749. * @param callback Called when a button has been released
  72750. */
  72751. onbuttonup(callback: (buttonReleased: number) => void): void;
  72752. /**
  72753. * Initializes the generic gamepad
  72754. * @param id The id of the generic gamepad
  72755. * @param index The index of the generic gamepad
  72756. * @param browserGamepad The browser gamepad
  72757. */
  72758. constructor(id: string, index: number, browserGamepad: any);
  72759. private _setButtonValue;
  72760. /**
  72761. * Updates the generic gamepad
  72762. */
  72763. update(): void;
  72764. /**
  72765. * Disposes the generic gamepad
  72766. */
  72767. dispose(): void;
  72768. }
  72769. }
  72770. declare module BABYLON {
  72771. /**
  72772. * Defines the types of pose enabled controllers that are supported
  72773. */
  72774. export enum PoseEnabledControllerType {
  72775. /**
  72776. * HTC Vive
  72777. */
  72778. VIVE = 0,
  72779. /**
  72780. * Oculus Rift
  72781. */
  72782. OCULUS = 1,
  72783. /**
  72784. * Windows mixed reality
  72785. */
  72786. WINDOWS = 2,
  72787. /**
  72788. * Samsung gear VR
  72789. */
  72790. GEAR_VR = 3,
  72791. /**
  72792. * Google Daydream
  72793. */
  72794. DAYDREAM = 4,
  72795. /**
  72796. * Generic
  72797. */
  72798. GENERIC = 5
  72799. }
  72800. /**
  72801. * Defines the MutableGamepadButton interface for the state of a gamepad button
  72802. */
  72803. export interface MutableGamepadButton {
  72804. /**
  72805. * Value of the button/trigger
  72806. */
  72807. value: number;
  72808. /**
  72809. * If the button/trigger is currently touched
  72810. */
  72811. touched: boolean;
  72812. /**
  72813. * If the button/trigger is currently pressed
  72814. */
  72815. pressed: boolean;
  72816. }
  72817. /**
  72818. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  72819. * @hidden
  72820. */
  72821. export interface ExtendedGamepadButton extends GamepadButton {
  72822. /**
  72823. * If the button/trigger is currently pressed
  72824. */
  72825. readonly pressed: boolean;
  72826. /**
  72827. * If the button/trigger is currently touched
  72828. */
  72829. readonly touched: boolean;
  72830. /**
  72831. * Value of the button/trigger
  72832. */
  72833. readonly value: number;
  72834. }
  72835. /** @hidden */
  72836. export interface _GamePadFactory {
  72837. /**
  72838. * Returns wether or not the current gamepad can be created for this type of controller.
  72839. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72840. * @returns true if it can be created, otherwise false
  72841. */
  72842. canCreate(gamepadInfo: any): boolean;
  72843. /**
  72844. * Creates a new instance of the Gamepad.
  72845. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72846. * @returns the new gamepad instance
  72847. */
  72848. create(gamepadInfo: any): Gamepad;
  72849. }
  72850. /**
  72851. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72852. */
  72853. export class PoseEnabledControllerHelper {
  72854. /** @hidden */
  72855. static _ControllerFactories: _GamePadFactory[];
  72856. /** @hidden */
  72857. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72858. /**
  72859. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72860. * @param vrGamepad the gamepad to initialized
  72861. * @returns a vr controller of the type the gamepad identified as
  72862. */
  72863. static InitiateController(vrGamepad: any): Gamepad;
  72864. }
  72865. /**
  72866. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72867. */
  72868. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72869. private _deviceRoomPosition;
  72870. private _deviceRoomRotationQuaternion;
  72871. /**
  72872. * The device position in babylon space
  72873. */
  72874. devicePosition: Vector3;
  72875. /**
  72876. * The device rotation in babylon space
  72877. */
  72878. deviceRotationQuaternion: Quaternion;
  72879. /**
  72880. * The scale factor of the device in babylon space
  72881. */
  72882. deviceScaleFactor: number;
  72883. /**
  72884. * (Likely devicePosition should be used instead) The device position in its room space
  72885. */
  72886. position: Vector3;
  72887. /**
  72888. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72889. */
  72890. rotationQuaternion: Quaternion;
  72891. /**
  72892. * The type of controller (Eg. Windows mixed reality)
  72893. */
  72894. controllerType: PoseEnabledControllerType;
  72895. protected _calculatedPosition: Vector3;
  72896. private _calculatedRotation;
  72897. /**
  72898. * The raw pose from the device
  72899. */
  72900. rawPose: DevicePose;
  72901. private _trackPosition;
  72902. private _maxRotationDistFromHeadset;
  72903. private _draggedRoomRotation;
  72904. /**
  72905. * @hidden
  72906. */
  72907. _disableTrackPosition(fixedPosition: Vector3): void;
  72908. /**
  72909. * Internal, the mesh attached to the controller
  72910. * @hidden
  72911. */
  72912. _mesh: Nullable<AbstractMesh>;
  72913. private _poseControlledCamera;
  72914. private _leftHandSystemQuaternion;
  72915. /**
  72916. * Internal, matrix used to convert room space to babylon space
  72917. * @hidden
  72918. */
  72919. _deviceToWorld: Matrix;
  72920. /**
  72921. * Node to be used when casting a ray from the controller
  72922. * @hidden
  72923. */
  72924. _pointingPoseNode: Nullable<TransformNode>;
  72925. /**
  72926. * Name of the child mesh that can be used to cast a ray from the controller
  72927. */
  72928. static readonly POINTING_POSE: string;
  72929. /**
  72930. * Creates a new PoseEnabledController from a gamepad
  72931. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72932. */
  72933. constructor(browserGamepad: any);
  72934. private _workingMatrix;
  72935. /**
  72936. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72937. */
  72938. update(): void;
  72939. /**
  72940. * Updates only the pose device and mesh without doing any button event checking
  72941. */
  72942. protected _updatePoseAndMesh(): void;
  72943. /**
  72944. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72945. * @param poseData raw pose fromthe device
  72946. */
  72947. updateFromDevice(poseData: DevicePose): void;
  72948. /**
  72949. * @hidden
  72950. */
  72951. _meshAttachedObservable: Observable<AbstractMesh>;
  72952. /**
  72953. * Attaches a mesh to the controller
  72954. * @param mesh the mesh to be attached
  72955. */
  72956. attachToMesh(mesh: AbstractMesh): void;
  72957. /**
  72958. * Attaches the controllers mesh to a camera
  72959. * @param camera the camera the mesh should be attached to
  72960. */
  72961. attachToPoseControlledCamera(camera: TargetCamera): void;
  72962. /**
  72963. * Disposes of the controller
  72964. */
  72965. dispose(): void;
  72966. /**
  72967. * The mesh that is attached to the controller
  72968. */
  72969. readonly mesh: Nullable<AbstractMesh>;
  72970. /**
  72971. * Gets the ray of the controller in the direction the controller is pointing
  72972. * @param length the length the resulting ray should be
  72973. * @returns a ray in the direction the controller is pointing
  72974. */
  72975. getForwardRay(length?: number): Ray;
  72976. }
  72977. }
  72978. declare module BABYLON {
  72979. /**
  72980. * Defines the WebVRController object that represents controllers tracked in 3D space
  72981. */
  72982. export abstract class WebVRController extends PoseEnabledController {
  72983. /**
  72984. * Internal, the default controller model for the controller
  72985. */
  72986. protected _defaultModel: AbstractMesh;
  72987. /**
  72988. * Fired when the trigger state has changed
  72989. */
  72990. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72991. /**
  72992. * Fired when the main button state has changed
  72993. */
  72994. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72995. /**
  72996. * Fired when the secondary button state has changed
  72997. */
  72998. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72999. /**
  73000. * Fired when the pad state has changed
  73001. */
  73002. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  73003. /**
  73004. * Fired when controllers stick values have changed
  73005. */
  73006. onPadValuesChangedObservable: Observable<StickValues>;
  73007. /**
  73008. * Array of button availible on the controller
  73009. */
  73010. protected _buttons: Array<MutableGamepadButton>;
  73011. private _onButtonStateChange;
  73012. /**
  73013. * Fired when a controller button's state has changed
  73014. * @param callback the callback containing the button that was modified
  73015. */
  73016. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  73017. /**
  73018. * X and Y axis corrisponding to the controllers joystick
  73019. */
  73020. pad: StickValues;
  73021. /**
  73022. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  73023. */
  73024. hand: string;
  73025. /**
  73026. * The default controller model for the controller
  73027. */
  73028. readonly defaultModel: AbstractMesh;
  73029. /**
  73030. * Creates a new WebVRController from a gamepad
  73031. * @param vrGamepad the gamepad that the WebVRController should be created from
  73032. */
  73033. constructor(vrGamepad: any);
  73034. /**
  73035. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  73036. */
  73037. update(): void;
  73038. /**
  73039. * Function to be called when a button is modified
  73040. */
  73041. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  73042. /**
  73043. * Loads a mesh and attaches it to the controller
  73044. * @param scene the scene the mesh should be added to
  73045. * @param meshLoaded callback for when the mesh has been loaded
  73046. */
  73047. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  73048. private _setButtonValue;
  73049. private _changes;
  73050. private _checkChanges;
  73051. /**
  73052. * Disposes of th webVRCOntroller
  73053. */
  73054. dispose(): void;
  73055. }
  73056. }
  73057. declare module BABYLON {
  73058. /**
  73059. * The HemisphericLight simulates the ambient environment light,
  73060. * so the passed direction is the light reflection direction, not the incoming direction.
  73061. */
  73062. export class HemisphericLight extends Light {
  73063. /**
  73064. * The groundColor is the light in the opposite direction to the one specified during creation.
  73065. * 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.
  73066. */
  73067. groundColor: Color3;
  73068. /**
  73069. * The light reflection direction, not the incoming direction.
  73070. */
  73071. direction: Vector3;
  73072. /**
  73073. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  73074. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  73075. * The HemisphericLight can't cast shadows.
  73076. * Documentation : https://doc.babylonjs.com/babylon101/lights
  73077. * @param name The friendly name of the light
  73078. * @param direction The direction of the light reflection
  73079. * @param scene The scene the light belongs to
  73080. */
  73081. constructor(name: string, direction: Vector3, scene: Scene);
  73082. protected _buildUniformLayout(): void;
  73083. /**
  73084. * Returns the string "HemisphericLight".
  73085. * @return The class name
  73086. */
  73087. getClassName(): string;
  73088. /**
  73089. * Sets the HemisphericLight direction towards the passed target (Vector3).
  73090. * Returns the updated direction.
  73091. * @param target The target the direction should point to
  73092. * @return The computed direction
  73093. */
  73094. setDirectionToTarget(target: Vector3): Vector3;
  73095. /**
  73096. * Returns the shadow generator associated to the light.
  73097. * @returns Always null for hemispheric lights because it does not support shadows.
  73098. */
  73099. getShadowGenerator(): Nullable<IShadowGenerator>;
  73100. /**
  73101. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  73102. * @param effect The effect to update
  73103. * @param lightIndex The index of the light in the effect to update
  73104. * @returns The hemispheric light
  73105. */
  73106. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  73107. /**
  73108. * Computes the world matrix of the node
  73109. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73110. * @param useWasUpdatedFlag defines a reserved property
  73111. * @returns the world matrix
  73112. */
  73113. computeWorldMatrix(): Matrix;
  73114. /**
  73115. * Returns the integer 3.
  73116. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  73117. */
  73118. getTypeID(): number;
  73119. /**
  73120. * Prepares the list of defines specific to the light type.
  73121. * @param defines the list of defines
  73122. * @param lightIndex defines the index of the light for the effect
  73123. */
  73124. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73125. }
  73126. }
  73127. declare module BABYLON {
  73128. /** @hidden */
  73129. export var vrMultiviewToSingleviewPixelShader: {
  73130. name: string;
  73131. shader: string;
  73132. };
  73133. }
  73134. declare module BABYLON {
  73135. /**
  73136. * Renders to multiple views with a single draw call
  73137. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  73138. */
  73139. export class MultiviewRenderTarget extends RenderTargetTexture {
  73140. /**
  73141. * Creates a multiview render target
  73142. * @param scene scene used with the render target
  73143. * @param size the size of the render target (used for each view)
  73144. */
  73145. constructor(scene: Scene, size?: number | {
  73146. width: number;
  73147. height: number;
  73148. } | {
  73149. ratio: number;
  73150. });
  73151. /**
  73152. * @hidden
  73153. * @param faceIndex the face index, if its a cube texture
  73154. */
  73155. _bindFrameBuffer(faceIndex?: number): void;
  73156. /**
  73157. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  73158. * @returns the view count
  73159. */
  73160. getViewCount(): number;
  73161. }
  73162. }
  73163. declare module BABYLON {
  73164. interface Engine {
  73165. /**
  73166. * Creates a new multiview render target
  73167. * @param width defines the width of the texture
  73168. * @param height defines the height of the texture
  73169. * @returns the created multiview texture
  73170. */
  73171. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  73172. /**
  73173. * Binds a multiview framebuffer to be drawn to
  73174. * @param multiviewTexture texture to bind
  73175. */
  73176. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  73177. }
  73178. interface Camera {
  73179. /**
  73180. * @hidden
  73181. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  73182. */
  73183. _useMultiviewToSingleView: boolean;
  73184. /**
  73185. * @hidden
  73186. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  73187. */
  73188. _multiviewTexture: Nullable<RenderTargetTexture>;
  73189. /**
  73190. * @hidden
  73191. * ensures the multiview texture of the camera exists and has the specified width/height
  73192. * @param width height to set on the multiview texture
  73193. * @param height width to set on the multiview texture
  73194. */
  73195. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  73196. }
  73197. interface Scene {
  73198. /** @hidden */
  73199. _transformMatrixR: Matrix;
  73200. /** @hidden */
  73201. _multiviewSceneUbo: Nullable<UniformBuffer>;
  73202. /** @hidden */
  73203. _createMultiviewUbo(): void;
  73204. /** @hidden */
  73205. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  73206. /** @hidden */
  73207. _renderMultiviewToSingleView(camera: Camera): void;
  73208. }
  73209. }
  73210. declare module BABYLON {
  73211. /**
  73212. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  73213. * This will not be used for webXR as it supports displaying texture arrays directly
  73214. */
  73215. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  73216. /**
  73217. * Initializes a VRMultiviewToSingleview
  73218. * @param name name of the post process
  73219. * @param camera camera to be applied to
  73220. * @param scaleFactor scaling factor to the size of the output texture
  73221. */
  73222. constructor(name: string, camera: Camera, scaleFactor: number);
  73223. }
  73224. }
  73225. declare module BABYLON {
  73226. /**
  73227. * Defines the interface used by display changed events
  73228. */
  73229. interface IDisplayChangedEventArgs {
  73230. /** Gets the vrDisplay object (if any) */
  73231. vrDisplay: Nullable<any>;
  73232. /** Gets a boolean indicating if webVR is supported */
  73233. vrSupported: boolean;
  73234. }
  73235. interface Engine {
  73236. /** @hidden */
  73237. _vrDisplay: any;
  73238. /** @hidden */
  73239. _vrSupported: boolean;
  73240. /** @hidden */
  73241. _oldSize: Size;
  73242. /** @hidden */
  73243. _oldHardwareScaleFactor: number;
  73244. /** @hidden */
  73245. _vrExclusivePointerMode: boolean;
  73246. /** @hidden */
  73247. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  73248. /** @hidden */
  73249. _onVRDisplayPointerRestricted: () => void;
  73250. /** @hidden */
  73251. _onVRDisplayPointerUnrestricted: () => void;
  73252. /** @hidden */
  73253. _onVrDisplayConnect: Nullable<(display: any) => void>;
  73254. /** @hidden */
  73255. _onVrDisplayDisconnect: Nullable<() => void>;
  73256. /** @hidden */
  73257. _onVrDisplayPresentChange: Nullable<() => void>;
  73258. /**
  73259. * Observable signaled when VR display mode changes
  73260. */
  73261. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  73262. /**
  73263. * Observable signaled when VR request present is complete
  73264. */
  73265. onVRRequestPresentComplete: Observable<boolean>;
  73266. /**
  73267. * Observable signaled when VR request present starts
  73268. */
  73269. onVRRequestPresentStart: Observable<Engine>;
  73270. /**
  73271. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  73272. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  73273. */
  73274. isInVRExclusivePointerMode: boolean;
  73275. /**
  73276. * Gets a boolean indicating if a webVR device was detected
  73277. * @returns true if a webVR device was detected
  73278. */
  73279. isVRDevicePresent(): boolean;
  73280. /**
  73281. * Gets the current webVR device
  73282. * @returns the current webVR device (or null)
  73283. */
  73284. getVRDevice(): any;
  73285. /**
  73286. * Initializes a webVR display and starts listening to display change events
  73287. * The onVRDisplayChangedObservable will be notified upon these changes
  73288. * @returns A promise containing a VRDisplay and if vr is supported
  73289. */
  73290. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  73291. /** @hidden */
  73292. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  73293. /**
  73294. * Call this function to switch to webVR mode
  73295. * Will do nothing if webVR is not supported or if there is no webVR device
  73296. * @see http://doc.babylonjs.com/how_to/webvr_camera
  73297. */
  73298. enableVR(): void;
  73299. /** @hidden */
  73300. _onVRFullScreenTriggered(): void;
  73301. }
  73302. }
  73303. declare module BABYLON {
  73304. /**
  73305. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  73306. * IMPORTANT!! The data is right-hand data.
  73307. * @export
  73308. * @interface DevicePose
  73309. */
  73310. export interface DevicePose {
  73311. /**
  73312. * The position of the device, values in array are [x,y,z].
  73313. */
  73314. readonly position: Nullable<Float32Array>;
  73315. /**
  73316. * The linearVelocity of the device, values in array are [x,y,z].
  73317. */
  73318. readonly linearVelocity: Nullable<Float32Array>;
  73319. /**
  73320. * The linearAcceleration of the device, values in array are [x,y,z].
  73321. */
  73322. readonly linearAcceleration: Nullable<Float32Array>;
  73323. /**
  73324. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  73325. */
  73326. readonly orientation: Nullable<Float32Array>;
  73327. /**
  73328. * The angularVelocity of the device, values in array are [x,y,z].
  73329. */
  73330. readonly angularVelocity: Nullable<Float32Array>;
  73331. /**
  73332. * The angularAcceleration of the device, values in array are [x,y,z].
  73333. */
  73334. readonly angularAcceleration: Nullable<Float32Array>;
  73335. }
  73336. /**
  73337. * Interface representing a pose controlled object in Babylon.
  73338. * A pose controlled object has both regular pose values as well as pose values
  73339. * from an external device such as a VR head mounted display
  73340. */
  73341. export interface PoseControlled {
  73342. /**
  73343. * The position of the object in babylon space.
  73344. */
  73345. position: Vector3;
  73346. /**
  73347. * The rotation quaternion of the object in babylon space.
  73348. */
  73349. rotationQuaternion: Quaternion;
  73350. /**
  73351. * The position of the device in babylon space.
  73352. */
  73353. devicePosition?: Vector3;
  73354. /**
  73355. * The rotation quaternion of the device in babylon space.
  73356. */
  73357. deviceRotationQuaternion: Quaternion;
  73358. /**
  73359. * The raw pose coming from the device.
  73360. */
  73361. rawPose: Nullable<DevicePose>;
  73362. /**
  73363. * The scale of the device to be used when translating from device space to babylon space.
  73364. */
  73365. deviceScaleFactor: number;
  73366. /**
  73367. * Updates the poseControlled values based on the input device pose.
  73368. * @param poseData the pose data to update the object with
  73369. */
  73370. updateFromDevice(poseData: DevicePose): void;
  73371. }
  73372. /**
  73373. * Set of options to customize the webVRCamera
  73374. */
  73375. export interface WebVROptions {
  73376. /**
  73377. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  73378. */
  73379. trackPosition?: boolean;
  73380. /**
  73381. * Sets the scale of the vrDevice in babylon space. (default: 1)
  73382. */
  73383. positionScale?: number;
  73384. /**
  73385. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  73386. */
  73387. displayName?: string;
  73388. /**
  73389. * Should the native controller meshes be initialized. (default: true)
  73390. */
  73391. controllerMeshes?: boolean;
  73392. /**
  73393. * Creating a default HemiLight only on controllers. (default: true)
  73394. */
  73395. defaultLightingOnControllers?: boolean;
  73396. /**
  73397. * If you don't want to use the default VR button of the helper. (default: false)
  73398. */
  73399. useCustomVRButton?: boolean;
  73400. /**
  73401. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  73402. */
  73403. customVRButton?: HTMLButtonElement;
  73404. /**
  73405. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  73406. */
  73407. rayLength?: number;
  73408. /**
  73409. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  73410. */
  73411. defaultHeight?: number;
  73412. /**
  73413. * If multiview should be used if availible (default: false)
  73414. */
  73415. useMultiview?: boolean;
  73416. }
  73417. /**
  73418. * This represents a WebVR camera.
  73419. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  73420. * @example http://doc.babylonjs.com/how_to/webvr_camera
  73421. */
  73422. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  73423. private webVROptions;
  73424. /**
  73425. * @hidden
  73426. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  73427. */
  73428. _vrDevice: any;
  73429. /**
  73430. * The rawPose of the vrDevice.
  73431. */
  73432. rawPose: Nullable<DevicePose>;
  73433. private _onVREnabled;
  73434. private _specsVersion;
  73435. private _attached;
  73436. private _frameData;
  73437. protected _descendants: Array<Node>;
  73438. private _deviceRoomPosition;
  73439. /** @hidden */
  73440. _deviceRoomRotationQuaternion: Quaternion;
  73441. private _standingMatrix;
  73442. /**
  73443. * Represents device position in babylon space.
  73444. */
  73445. devicePosition: Vector3;
  73446. /**
  73447. * Represents device rotation in babylon space.
  73448. */
  73449. deviceRotationQuaternion: Quaternion;
  73450. /**
  73451. * The scale of the device to be used when translating from device space to babylon space.
  73452. */
  73453. deviceScaleFactor: number;
  73454. private _deviceToWorld;
  73455. private _worldToDevice;
  73456. /**
  73457. * References to the webVR controllers for the vrDevice.
  73458. */
  73459. controllers: Array<WebVRController>;
  73460. /**
  73461. * Emits an event when a controller is attached.
  73462. */
  73463. onControllersAttachedObservable: Observable<WebVRController[]>;
  73464. /**
  73465. * Emits an event when a controller's mesh has been loaded;
  73466. */
  73467. onControllerMeshLoadedObservable: Observable<WebVRController>;
  73468. /**
  73469. * Emits an event when the HMD's pose has been updated.
  73470. */
  73471. onPoseUpdatedFromDeviceObservable: Observable<any>;
  73472. private _poseSet;
  73473. /**
  73474. * If the rig cameras be used as parent instead of this camera.
  73475. */
  73476. rigParenting: boolean;
  73477. private _lightOnControllers;
  73478. private _defaultHeight?;
  73479. /**
  73480. * Instantiates a WebVRFreeCamera.
  73481. * @param name The name of the WebVRFreeCamera
  73482. * @param position The starting anchor position for the camera
  73483. * @param scene The scene the camera belongs to
  73484. * @param webVROptions a set of customizable options for the webVRCamera
  73485. */
  73486. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  73487. /**
  73488. * Gets the device distance from the ground in meters.
  73489. * @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.
  73490. */
  73491. deviceDistanceToRoomGround(): number;
  73492. /**
  73493. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73494. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  73495. */
  73496. useStandingMatrix(callback?: (bool: boolean) => void): void;
  73497. /**
  73498. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73499. * @returns A promise with a boolean set to if the standing matrix is supported.
  73500. */
  73501. useStandingMatrixAsync(): Promise<boolean>;
  73502. /**
  73503. * Disposes the camera
  73504. */
  73505. dispose(): void;
  73506. /**
  73507. * Gets a vrController by name.
  73508. * @param name The name of the controller to retreive
  73509. * @returns the controller matching the name specified or null if not found
  73510. */
  73511. getControllerByName(name: string): Nullable<WebVRController>;
  73512. private _leftController;
  73513. /**
  73514. * The controller corrisponding to the users left hand.
  73515. */
  73516. readonly leftController: Nullable<WebVRController>;
  73517. private _rightController;
  73518. /**
  73519. * The controller corrisponding to the users right hand.
  73520. */
  73521. readonly rightController: Nullable<WebVRController>;
  73522. /**
  73523. * Casts a ray forward from the vrCamera's gaze.
  73524. * @param length Length of the ray (default: 100)
  73525. * @returns the ray corrisponding to the gaze
  73526. */
  73527. getForwardRay(length?: number): Ray;
  73528. /**
  73529. * @hidden
  73530. * Updates the camera based on device's frame data
  73531. */
  73532. _checkInputs(): void;
  73533. /**
  73534. * Updates the poseControlled values based on the input device pose.
  73535. * @param poseData Pose coming from the device
  73536. */
  73537. updateFromDevice(poseData: DevicePose): void;
  73538. private _htmlElementAttached;
  73539. private _detachIfAttached;
  73540. /**
  73541. * WebVR's attach control will start broadcasting frames to the device.
  73542. * Note that in certain browsers (chrome for example) this function must be called
  73543. * within a user-interaction callback. Example:
  73544. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  73545. *
  73546. * @param element html element to attach the vrDevice to
  73547. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  73548. */
  73549. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73550. /**
  73551. * Detaches the camera from the html element and disables VR
  73552. *
  73553. * @param element html element to detach from
  73554. */
  73555. detachControl(element: HTMLElement): void;
  73556. /**
  73557. * @returns the name of this class
  73558. */
  73559. getClassName(): string;
  73560. /**
  73561. * Calls resetPose on the vrDisplay
  73562. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  73563. */
  73564. resetToCurrentRotation(): void;
  73565. /**
  73566. * @hidden
  73567. * Updates the rig cameras (left and right eye)
  73568. */
  73569. _updateRigCameras(): void;
  73570. private _workingVector;
  73571. private _oneVector;
  73572. private _workingMatrix;
  73573. private updateCacheCalled;
  73574. private _correctPositionIfNotTrackPosition;
  73575. /**
  73576. * @hidden
  73577. * Updates the cached values of the camera
  73578. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  73579. */
  73580. _updateCache(ignoreParentClass?: boolean): void;
  73581. /**
  73582. * @hidden
  73583. * Get current device position in babylon world
  73584. */
  73585. _computeDevicePosition(): void;
  73586. /**
  73587. * Updates the current device position and rotation in the babylon world
  73588. */
  73589. update(): void;
  73590. /**
  73591. * @hidden
  73592. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  73593. * @returns an identity matrix
  73594. */
  73595. _getViewMatrix(): Matrix;
  73596. private _tmpMatrix;
  73597. /**
  73598. * This function is called by the two RIG cameras.
  73599. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  73600. * @hidden
  73601. */
  73602. _getWebVRViewMatrix(): Matrix;
  73603. /** @hidden */
  73604. _getWebVRProjectionMatrix(): Matrix;
  73605. private _onGamepadConnectedObserver;
  73606. private _onGamepadDisconnectedObserver;
  73607. private _updateCacheWhenTrackingDisabledObserver;
  73608. /**
  73609. * Initializes the controllers and their meshes
  73610. */
  73611. initControllers(): void;
  73612. }
  73613. }
  73614. declare module BABYLON {
  73615. /**
  73616. * Size options for a post process
  73617. */
  73618. export type PostProcessOptions = {
  73619. width: number;
  73620. height: number;
  73621. };
  73622. /**
  73623. * PostProcess can be used to apply a shader to a texture after it has been rendered
  73624. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73625. */
  73626. export class PostProcess {
  73627. /** Name of the PostProcess. */
  73628. name: string;
  73629. /**
  73630. * Gets or sets the unique id of the post process
  73631. */
  73632. uniqueId: number;
  73633. /**
  73634. * Width of the texture to apply the post process on
  73635. */
  73636. width: number;
  73637. /**
  73638. * Height of the texture to apply the post process on
  73639. */
  73640. height: number;
  73641. /**
  73642. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  73643. * @hidden
  73644. */
  73645. _outputTexture: Nullable<InternalTexture>;
  73646. /**
  73647. * Sampling mode used by the shader
  73648. * See https://doc.babylonjs.com/classes/3.1/texture
  73649. */
  73650. renderTargetSamplingMode: number;
  73651. /**
  73652. * Clear color to use when screen clearing
  73653. */
  73654. clearColor: Color4;
  73655. /**
  73656. * If the buffer needs to be cleared before applying the post process. (default: true)
  73657. * Should be set to false if shader will overwrite all previous pixels.
  73658. */
  73659. autoClear: boolean;
  73660. /**
  73661. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  73662. */
  73663. alphaMode: number;
  73664. /**
  73665. * Sets the setAlphaBlendConstants of the babylon engine
  73666. */
  73667. alphaConstants: Color4;
  73668. /**
  73669. * Animations to be used for the post processing
  73670. */
  73671. animations: Animation[];
  73672. /**
  73673. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  73674. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  73675. */
  73676. enablePixelPerfectMode: boolean;
  73677. /**
  73678. * Force the postprocess to be applied without taking in account viewport
  73679. */
  73680. forceFullscreenViewport: boolean;
  73681. /**
  73682. * List of inspectable custom properties (used by the Inspector)
  73683. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73684. */
  73685. inspectableCustomProperties: IInspectable[];
  73686. /**
  73687. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  73688. *
  73689. * | Value | Type | Description |
  73690. * | ----- | ----------------------------------- | ----------- |
  73691. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  73692. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  73693. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  73694. *
  73695. */
  73696. scaleMode: number;
  73697. /**
  73698. * Force textures to be a power of two (default: false)
  73699. */
  73700. alwaysForcePOT: boolean;
  73701. private _samples;
  73702. /**
  73703. * Number of sample textures (default: 1)
  73704. */
  73705. samples: number;
  73706. /**
  73707. * Modify the scale of the post process to be the same as the viewport (default: false)
  73708. */
  73709. adaptScaleToCurrentViewport: boolean;
  73710. private _camera;
  73711. private _scene;
  73712. private _engine;
  73713. private _options;
  73714. private _reusable;
  73715. private _textureType;
  73716. /**
  73717. * Smart array of input and output textures for the post process.
  73718. * @hidden
  73719. */
  73720. _textures: SmartArray<InternalTexture>;
  73721. /**
  73722. * The index in _textures that corresponds to the output texture.
  73723. * @hidden
  73724. */
  73725. _currentRenderTextureInd: number;
  73726. private _effect;
  73727. private _samplers;
  73728. private _fragmentUrl;
  73729. private _vertexUrl;
  73730. private _parameters;
  73731. private _scaleRatio;
  73732. protected _indexParameters: any;
  73733. private _shareOutputWithPostProcess;
  73734. private _texelSize;
  73735. private _forcedOutputTexture;
  73736. /**
  73737. * Returns the fragment url or shader name used in the post process.
  73738. * @returns the fragment url or name in the shader store.
  73739. */
  73740. getEffectName(): string;
  73741. /**
  73742. * An event triggered when the postprocess is activated.
  73743. */
  73744. onActivateObservable: Observable<Camera>;
  73745. private _onActivateObserver;
  73746. /**
  73747. * A function that is added to the onActivateObservable
  73748. */
  73749. onActivate: Nullable<(camera: Camera) => void>;
  73750. /**
  73751. * An event triggered when the postprocess changes its size.
  73752. */
  73753. onSizeChangedObservable: Observable<PostProcess>;
  73754. private _onSizeChangedObserver;
  73755. /**
  73756. * A function that is added to the onSizeChangedObservable
  73757. */
  73758. onSizeChanged: (postProcess: PostProcess) => void;
  73759. /**
  73760. * An event triggered when the postprocess applies its effect.
  73761. */
  73762. onApplyObservable: Observable<Effect>;
  73763. private _onApplyObserver;
  73764. /**
  73765. * A function that is added to the onApplyObservable
  73766. */
  73767. onApply: (effect: Effect) => void;
  73768. /**
  73769. * An event triggered before rendering the postprocess
  73770. */
  73771. onBeforeRenderObservable: Observable<Effect>;
  73772. private _onBeforeRenderObserver;
  73773. /**
  73774. * A function that is added to the onBeforeRenderObservable
  73775. */
  73776. onBeforeRender: (effect: Effect) => void;
  73777. /**
  73778. * An event triggered after rendering the postprocess
  73779. */
  73780. onAfterRenderObservable: Observable<Effect>;
  73781. private _onAfterRenderObserver;
  73782. /**
  73783. * A function that is added to the onAfterRenderObservable
  73784. */
  73785. onAfterRender: (efect: Effect) => void;
  73786. /**
  73787. * 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
  73788. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  73789. */
  73790. inputTexture: InternalTexture;
  73791. /**
  73792. * Gets the camera which post process is applied to.
  73793. * @returns The camera the post process is applied to.
  73794. */
  73795. getCamera(): Camera;
  73796. /**
  73797. * Gets the texel size of the postprocess.
  73798. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  73799. */
  73800. readonly texelSize: Vector2;
  73801. /**
  73802. * Creates a new instance PostProcess
  73803. * @param name The name of the PostProcess.
  73804. * @param fragmentUrl The url of the fragment shader to be used.
  73805. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  73806. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  73807. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  73808. * @param camera The camera to apply the render pass to.
  73809. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73810. * @param engine The engine which the post process will be applied. (default: current engine)
  73811. * @param reusable If the post process can be reused on the same frame. (default: false)
  73812. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  73813. * @param textureType Type of textures used when performing the post process. (default: 0)
  73814. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  73815. * @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
  73816. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  73817. */
  73818. constructor(
  73819. /** Name of the PostProcess. */
  73820. 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);
  73821. /**
  73822. * Gets a string idenfifying the name of the class
  73823. * @returns "PostProcess" string
  73824. */
  73825. getClassName(): string;
  73826. /**
  73827. * Gets the engine which this post process belongs to.
  73828. * @returns The engine the post process was enabled with.
  73829. */
  73830. getEngine(): Engine;
  73831. /**
  73832. * The effect that is created when initializing the post process.
  73833. * @returns The created effect corrisponding the the postprocess.
  73834. */
  73835. getEffect(): Effect;
  73836. /**
  73837. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  73838. * @param postProcess The post process to share the output with.
  73839. * @returns This post process.
  73840. */
  73841. shareOutputWith(postProcess: PostProcess): PostProcess;
  73842. /**
  73843. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  73844. * This should be called if the post process that shares output with this post process is disabled/disposed.
  73845. */
  73846. useOwnOutput(): void;
  73847. /**
  73848. * Updates the effect with the current post process compile time values and recompiles the shader.
  73849. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73850. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73851. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73852. * @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
  73853. * @param onCompiled Called when the shader has been compiled.
  73854. * @param onError Called if there is an error when compiling a shader.
  73855. */
  73856. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73857. /**
  73858. * The post process is reusable if it can be used multiple times within one frame.
  73859. * @returns If the post process is reusable
  73860. */
  73861. isReusable(): boolean;
  73862. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  73863. markTextureDirty(): void;
  73864. /**
  73865. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  73866. * 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.
  73867. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  73868. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  73869. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  73870. * @returns The target texture that was bound to be written to.
  73871. */
  73872. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  73873. /**
  73874. * If the post process is supported.
  73875. */
  73876. readonly isSupported: boolean;
  73877. /**
  73878. * The aspect ratio of the output texture.
  73879. */
  73880. readonly aspectRatio: number;
  73881. /**
  73882. * Get a value indicating if the post-process is ready to be used
  73883. * @returns true if the post-process is ready (shader is compiled)
  73884. */
  73885. isReady(): boolean;
  73886. /**
  73887. * Binds all textures and uniforms to the shader, this will be run on every pass.
  73888. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  73889. */
  73890. apply(): Nullable<Effect>;
  73891. private _disposeTextures;
  73892. /**
  73893. * Disposes the post process.
  73894. * @param camera The camera to dispose the post process on.
  73895. */
  73896. dispose(camera?: Camera): void;
  73897. }
  73898. }
  73899. declare module BABYLON {
  73900. /**
  73901. * PostProcessManager is used to manage one or more post processes or post process pipelines
  73902. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73903. */
  73904. export class PostProcessManager {
  73905. private _scene;
  73906. private _indexBuffer;
  73907. private _vertexBuffers;
  73908. /**
  73909. * Creates a new instance PostProcess
  73910. * @param scene The scene that the post process is associated with.
  73911. */
  73912. constructor(scene: Scene);
  73913. private _prepareBuffers;
  73914. private _buildIndexBuffer;
  73915. /**
  73916. * Rebuilds the vertex buffers of the manager.
  73917. * @hidden
  73918. */
  73919. _rebuild(): void;
  73920. /**
  73921. * Prepares a frame to be run through a post process.
  73922. * @param sourceTexture The input texture to the post procesess. (default: null)
  73923. * @param postProcesses An array of post processes to be run. (default: null)
  73924. * @returns True if the post processes were able to be run.
  73925. * @hidden
  73926. */
  73927. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73928. /**
  73929. * Manually render a set of post processes to a texture.
  73930. * @param postProcesses An array of post processes to be run.
  73931. * @param targetTexture The target texture to render to.
  73932. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73933. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73934. * @param lodLevel defines which lod of the texture to render to
  73935. */
  73936. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73937. /**
  73938. * Finalize the result of the output of the postprocesses.
  73939. * @param doNotPresent If true the result will not be displayed to the screen.
  73940. * @param targetTexture The target texture to render to.
  73941. * @param faceIndex The index of the face to bind the target texture to.
  73942. * @param postProcesses The array of post processes to render.
  73943. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73944. * @hidden
  73945. */
  73946. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73947. /**
  73948. * Disposes of the post process manager.
  73949. */
  73950. dispose(): void;
  73951. }
  73952. }
  73953. declare module BABYLON {
  73954. interface AbstractScene {
  73955. /**
  73956. * The list of layers (background and foreground) of the scene
  73957. */
  73958. layers: Array<Layer>;
  73959. }
  73960. /**
  73961. * Defines the layer scene component responsible to manage any layers
  73962. * in a given scene.
  73963. */
  73964. export class LayerSceneComponent implements ISceneComponent {
  73965. /**
  73966. * The component name helpfull to identify the component in the list of scene components.
  73967. */
  73968. readonly name: string;
  73969. /**
  73970. * The scene the component belongs to.
  73971. */
  73972. scene: Scene;
  73973. private _engine;
  73974. /**
  73975. * Creates a new instance of the component for the given scene
  73976. * @param scene Defines the scene to register the component in
  73977. */
  73978. constructor(scene: Scene);
  73979. /**
  73980. * Registers the component in a given scene
  73981. */
  73982. register(): void;
  73983. /**
  73984. * Rebuilds the elements related to this component in case of
  73985. * context lost for instance.
  73986. */
  73987. rebuild(): void;
  73988. /**
  73989. * Disposes the component and the associated ressources.
  73990. */
  73991. dispose(): void;
  73992. private _draw;
  73993. private _drawCameraPredicate;
  73994. private _drawCameraBackground;
  73995. private _drawCameraForeground;
  73996. private _drawRenderTargetPredicate;
  73997. private _drawRenderTargetBackground;
  73998. private _drawRenderTargetForeground;
  73999. }
  74000. }
  74001. declare module BABYLON {
  74002. /** @hidden */
  74003. export var layerPixelShader: {
  74004. name: string;
  74005. shader: string;
  74006. };
  74007. }
  74008. declare module BABYLON {
  74009. /** @hidden */
  74010. export var layerVertexShader: {
  74011. name: string;
  74012. shader: string;
  74013. };
  74014. }
  74015. declare module BABYLON {
  74016. /**
  74017. * This represents a full screen 2d layer.
  74018. * This can be useful to display a picture in the background of your scene for instance.
  74019. * @see https://www.babylonjs-playground.com/#08A2BS#1
  74020. */
  74021. export class Layer {
  74022. /**
  74023. * Define the name of the layer.
  74024. */
  74025. name: string;
  74026. /**
  74027. * Define the texture the layer should display.
  74028. */
  74029. texture: Nullable<Texture>;
  74030. /**
  74031. * Is the layer in background or foreground.
  74032. */
  74033. isBackground: boolean;
  74034. /**
  74035. * Define the color of the layer (instead of texture).
  74036. */
  74037. color: Color4;
  74038. /**
  74039. * Define the scale of the layer in order to zoom in out of the texture.
  74040. */
  74041. scale: Vector2;
  74042. /**
  74043. * Define an offset for the layer in order to shift the texture.
  74044. */
  74045. offset: Vector2;
  74046. /**
  74047. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  74048. */
  74049. alphaBlendingMode: number;
  74050. /**
  74051. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  74052. * Alpha test will not mix with the background color in case of transparency.
  74053. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  74054. */
  74055. alphaTest: boolean;
  74056. /**
  74057. * Define a mask to restrict the layer to only some of the scene cameras.
  74058. */
  74059. layerMask: number;
  74060. /**
  74061. * Define the list of render target the layer is visible into.
  74062. */
  74063. renderTargetTextures: RenderTargetTexture[];
  74064. /**
  74065. * Define if the layer is only used in renderTarget or if it also
  74066. * renders in the main frame buffer of the canvas.
  74067. */
  74068. renderOnlyInRenderTargetTextures: boolean;
  74069. private _scene;
  74070. private _vertexBuffers;
  74071. private _indexBuffer;
  74072. private _effect;
  74073. private _alphaTestEffect;
  74074. /**
  74075. * An event triggered when the layer is disposed.
  74076. */
  74077. onDisposeObservable: Observable<Layer>;
  74078. private _onDisposeObserver;
  74079. /**
  74080. * Back compatibility with callback before the onDisposeObservable existed.
  74081. * The set callback will be triggered when the layer has been disposed.
  74082. */
  74083. onDispose: () => void;
  74084. /**
  74085. * An event triggered before rendering the scene
  74086. */
  74087. onBeforeRenderObservable: Observable<Layer>;
  74088. private _onBeforeRenderObserver;
  74089. /**
  74090. * Back compatibility with callback before the onBeforeRenderObservable existed.
  74091. * The set callback will be triggered just before rendering the layer.
  74092. */
  74093. onBeforeRender: () => void;
  74094. /**
  74095. * An event triggered after rendering the scene
  74096. */
  74097. onAfterRenderObservable: Observable<Layer>;
  74098. private _onAfterRenderObserver;
  74099. /**
  74100. * Back compatibility with callback before the onAfterRenderObservable existed.
  74101. * The set callback will be triggered just after rendering the layer.
  74102. */
  74103. onAfterRender: () => void;
  74104. /**
  74105. * Instantiates a new layer.
  74106. * This represents a full screen 2d layer.
  74107. * This can be useful to display a picture in the background of your scene for instance.
  74108. * @see https://www.babylonjs-playground.com/#08A2BS#1
  74109. * @param name Define the name of the layer in the scene
  74110. * @param imgUrl Define the url of the texture to display in the layer
  74111. * @param scene Define the scene the layer belongs to
  74112. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  74113. * @param color Defines a color for the layer
  74114. */
  74115. constructor(
  74116. /**
  74117. * Define the name of the layer.
  74118. */
  74119. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  74120. private _createIndexBuffer;
  74121. /** @hidden */
  74122. _rebuild(): void;
  74123. /**
  74124. * Renders the layer in the scene.
  74125. */
  74126. render(): void;
  74127. /**
  74128. * Disposes and releases the associated ressources.
  74129. */
  74130. dispose(): void;
  74131. }
  74132. }
  74133. declare module BABYLON {
  74134. interface AbstractScene {
  74135. /**
  74136. * The list of procedural textures added to the scene
  74137. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74138. */
  74139. proceduralTextures: Array<ProceduralTexture>;
  74140. }
  74141. /**
  74142. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  74143. * in a given scene.
  74144. */
  74145. export class ProceduralTextureSceneComponent implements ISceneComponent {
  74146. /**
  74147. * The component name helpfull to identify the component in the list of scene components.
  74148. */
  74149. readonly name: string;
  74150. /**
  74151. * The scene the component belongs to.
  74152. */
  74153. scene: Scene;
  74154. /**
  74155. * Creates a new instance of the component for the given scene
  74156. * @param scene Defines the scene to register the component in
  74157. */
  74158. constructor(scene: Scene);
  74159. /**
  74160. * Registers the component in a given scene
  74161. */
  74162. register(): void;
  74163. /**
  74164. * Rebuilds the elements related to this component in case of
  74165. * context lost for instance.
  74166. */
  74167. rebuild(): void;
  74168. /**
  74169. * Disposes the component and the associated ressources.
  74170. */
  74171. dispose(): void;
  74172. private _beforeClear;
  74173. }
  74174. }
  74175. declare module BABYLON {
  74176. interface Engine {
  74177. /**
  74178. * Creates a new render target cube texture
  74179. * @param size defines the size of the texture
  74180. * @param options defines the options used to create the texture
  74181. * @returns a new render target cube texture stored in an InternalTexture
  74182. */
  74183. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  74184. }
  74185. }
  74186. declare module BABYLON {
  74187. /** @hidden */
  74188. export var proceduralVertexShader: {
  74189. name: string;
  74190. shader: string;
  74191. };
  74192. }
  74193. declare module BABYLON {
  74194. /**
  74195. * 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.
  74196. * This is the base class of any Procedural texture and contains most of the shareable code.
  74197. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74198. */
  74199. export class ProceduralTexture extends Texture {
  74200. isCube: boolean;
  74201. /**
  74202. * Define if the texture is enabled or not (disabled texture will not render)
  74203. */
  74204. isEnabled: boolean;
  74205. /**
  74206. * Define if the texture must be cleared before rendering (default is true)
  74207. */
  74208. autoClear: boolean;
  74209. /**
  74210. * Callback called when the texture is generated
  74211. */
  74212. onGenerated: () => void;
  74213. /**
  74214. * Event raised when the texture is generated
  74215. */
  74216. onGeneratedObservable: Observable<ProceduralTexture>;
  74217. /** @hidden */
  74218. _generateMipMaps: boolean;
  74219. /** @hidden **/
  74220. _effect: Effect;
  74221. /** @hidden */
  74222. _textures: {
  74223. [key: string]: Texture;
  74224. };
  74225. private _size;
  74226. private _currentRefreshId;
  74227. private _refreshRate;
  74228. private _vertexBuffers;
  74229. private _indexBuffer;
  74230. private _uniforms;
  74231. private _samplers;
  74232. private _fragment;
  74233. private _floats;
  74234. private _ints;
  74235. private _floatsArrays;
  74236. private _colors3;
  74237. private _colors4;
  74238. private _vectors2;
  74239. private _vectors3;
  74240. private _matrices;
  74241. private _fallbackTexture;
  74242. private _fallbackTextureUsed;
  74243. private _engine;
  74244. private _cachedDefines;
  74245. private _contentUpdateId;
  74246. private _contentData;
  74247. /**
  74248. * Instantiates a new procedural texture.
  74249. * 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.
  74250. * This is the base class of any Procedural texture and contains most of the shareable code.
  74251. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74252. * @param name Define the name of the texture
  74253. * @param size Define the size of the texture to create
  74254. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  74255. * @param scene Define the scene the texture belongs to
  74256. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  74257. * @param generateMipMaps Define if the texture should creates mip maps or not
  74258. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  74259. */
  74260. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  74261. /**
  74262. * The effect that is created when initializing the post process.
  74263. * @returns The created effect corrisponding the the postprocess.
  74264. */
  74265. getEffect(): Effect;
  74266. /**
  74267. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  74268. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  74269. */
  74270. getContent(): Nullable<ArrayBufferView>;
  74271. private _createIndexBuffer;
  74272. /** @hidden */
  74273. _rebuild(): void;
  74274. /**
  74275. * Resets the texture in order to recreate its associated resources.
  74276. * This can be called in case of context loss
  74277. */
  74278. reset(): void;
  74279. protected _getDefines(): string;
  74280. /**
  74281. * Is the texture ready to be used ? (rendered at least once)
  74282. * @returns true if ready, otherwise, false.
  74283. */
  74284. isReady(): boolean;
  74285. /**
  74286. * Resets the refresh counter of the texture and start bak from scratch.
  74287. * Could be useful to regenerate the texture if it is setup to render only once.
  74288. */
  74289. resetRefreshCounter(): void;
  74290. /**
  74291. * Set the fragment shader to use in order to render the texture.
  74292. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  74293. */
  74294. setFragment(fragment: any): void;
  74295. /**
  74296. * Define the refresh rate of the texture or the rendering frequency.
  74297. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74298. */
  74299. refreshRate: number;
  74300. /** @hidden */
  74301. _shouldRender(): boolean;
  74302. /**
  74303. * Get the size the texture is rendering at.
  74304. * @returns the size (texture is always squared)
  74305. */
  74306. getRenderSize(): number;
  74307. /**
  74308. * Resize the texture to new value.
  74309. * @param size Define the new size the texture should have
  74310. * @param generateMipMaps Define whether the new texture should create mip maps
  74311. */
  74312. resize(size: number, generateMipMaps: boolean): void;
  74313. private _checkUniform;
  74314. /**
  74315. * Set a texture in the shader program used to render.
  74316. * @param name Define the name of the uniform samplers as defined in the shader
  74317. * @param texture Define the texture to bind to this sampler
  74318. * @return the texture itself allowing "fluent" like uniform updates
  74319. */
  74320. setTexture(name: string, texture: Texture): ProceduralTexture;
  74321. /**
  74322. * Set a float in the shader.
  74323. * @param name Define the name of the uniform as defined in the shader
  74324. * @param value Define the value to give to the uniform
  74325. * @return the texture itself allowing "fluent" like uniform updates
  74326. */
  74327. setFloat(name: string, value: number): ProceduralTexture;
  74328. /**
  74329. * Set a int in the shader.
  74330. * @param name Define the name of the uniform as defined in the shader
  74331. * @param value Define the value to give to the uniform
  74332. * @return the texture itself allowing "fluent" like uniform updates
  74333. */
  74334. setInt(name: string, value: number): ProceduralTexture;
  74335. /**
  74336. * Set an array of floats in the shader.
  74337. * @param name Define the name of the uniform as defined in the shader
  74338. * @param value Define the value to give to the uniform
  74339. * @return the texture itself allowing "fluent" like uniform updates
  74340. */
  74341. setFloats(name: string, value: number[]): ProceduralTexture;
  74342. /**
  74343. * Set a vec3 in the shader from a Color3.
  74344. * @param name Define the name of the uniform as defined in the shader
  74345. * @param value Define the value to give to the uniform
  74346. * @return the texture itself allowing "fluent" like uniform updates
  74347. */
  74348. setColor3(name: string, value: Color3): ProceduralTexture;
  74349. /**
  74350. * Set a vec4 in the shader from a Color4.
  74351. * @param name Define the name of the uniform as defined in the shader
  74352. * @param value Define the value to give to the uniform
  74353. * @return the texture itself allowing "fluent" like uniform updates
  74354. */
  74355. setColor4(name: string, value: Color4): ProceduralTexture;
  74356. /**
  74357. * Set a vec2 in the shader from a Vector2.
  74358. * @param name Define the name of the uniform as defined in the shader
  74359. * @param value Define the value to give to the uniform
  74360. * @return the texture itself allowing "fluent" like uniform updates
  74361. */
  74362. setVector2(name: string, value: Vector2): ProceduralTexture;
  74363. /**
  74364. * Set a vec3 in the shader from a Vector3.
  74365. * @param name Define the name of the uniform as defined in the shader
  74366. * @param value Define the value to give to the uniform
  74367. * @return the texture itself allowing "fluent" like uniform updates
  74368. */
  74369. setVector3(name: string, value: Vector3): ProceduralTexture;
  74370. /**
  74371. * Set a mat4 in the shader from a MAtrix.
  74372. * @param name Define the name of the uniform as defined in the shader
  74373. * @param value Define the value to give to the uniform
  74374. * @return the texture itself allowing "fluent" like uniform updates
  74375. */
  74376. setMatrix(name: string, value: Matrix): ProceduralTexture;
  74377. /**
  74378. * Render the texture to its associated render target.
  74379. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  74380. */
  74381. render(useCameraPostProcess?: boolean): void;
  74382. /**
  74383. * Clone the texture.
  74384. * @returns the cloned texture
  74385. */
  74386. clone(): ProceduralTexture;
  74387. /**
  74388. * Dispose the texture and release its asoociated resources.
  74389. */
  74390. dispose(): void;
  74391. }
  74392. }
  74393. declare module BABYLON {
  74394. /**
  74395. * This represents the base class for particle system in Babylon.
  74396. * 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.
  74397. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74398. * @example https://doc.babylonjs.com/babylon101/particles
  74399. */
  74400. export class BaseParticleSystem {
  74401. /**
  74402. * Source color is added to the destination color without alpha affecting the result
  74403. */
  74404. static BLENDMODE_ONEONE: number;
  74405. /**
  74406. * Blend current color and particle color using particle’s alpha
  74407. */
  74408. static BLENDMODE_STANDARD: number;
  74409. /**
  74410. * Add current color and particle color multiplied by particle’s alpha
  74411. */
  74412. static BLENDMODE_ADD: number;
  74413. /**
  74414. * Multiply current color with particle color
  74415. */
  74416. static BLENDMODE_MULTIPLY: number;
  74417. /**
  74418. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  74419. */
  74420. static BLENDMODE_MULTIPLYADD: number;
  74421. /**
  74422. * List of animations used by the particle system.
  74423. */
  74424. animations: Animation[];
  74425. /**
  74426. * The id of the Particle system.
  74427. */
  74428. id: string;
  74429. /**
  74430. * The friendly name of the Particle system.
  74431. */
  74432. name: string;
  74433. /**
  74434. * The rendering group used by the Particle system to chose when to render.
  74435. */
  74436. renderingGroupId: number;
  74437. /**
  74438. * The emitter represents the Mesh or position we are attaching the particle system to.
  74439. */
  74440. emitter: Nullable<AbstractMesh | Vector3>;
  74441. /**
  74442. * The maximum number of particles to emit per frame
  74443. */
  74444. emitRate: number;
  74445. /**
  74446. * If you want to launch only a few particles at once, that can be done, as well.
  74447. */
  74448. manualEmitCount: number;
  74449. /**
  74450. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74451. */
  74452. updateSpeed: number;
  74453. /**
  74454. * The amount of time the particle system is running (depends of the overall update speed).
  74455. */
  74456. targetStopDuration: number;
  74457. /**
  74458. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74459. */
  74460. disposeOnStop: boolean;
  74461. /**
  74462. * Minimum power of emitting particles.
  74463. */
  74464. minEmitPower: number;
  74465. /**
  74466. * Maximum power of emitting particles.
  74467. */
  74468. maxEmitPower: number;
  74469. /**
  74470. * Minimum life time of emitting particles.
  74471. */
  74472. minLifeTime: number;
  74473. /**
  74474. * Maximum life time of emitting particles.
  74475. */
  74476. maxLifeTime: number;
  74477. /**
  74478. * Minimum Size of emitting particles.
  74479. */
  74480. minSize: number;
  74481. /**
  74482. * Maximum Size of emitting particles.
  74483. */
  74484. maxSize: number;
  74485. /**
  74486. * Minimum scale of emitting particles on X axis.
  74487. */
  74488. minScaleX: number;
  74489. /**
  74490. * Maximum scale of emitting particles on X axis.
  74491. */
  74492. maxScaleX: number;
  74493. /**
  74494. * Minimum scale of emitting particles on Y axis.
  74495. */
  74496. minScaleY: number;
  74497. /**
  74498. * Maximum scale of emitting particles on Y axis.
  74499. */
  74500. maxScaleY: number;
  74501. /**
  74502. * Gets or sets the minimal initial rotation in radians.
  74503. */
  74504. minInitialRotation: number;
  74505. /**
  74506. * Gets or sets the maximal initial rotation in radians.
  74507. */
  74508. maxInitialRotation: number;
  74509. /**
  74510. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74511. */
  74512. minAngularSpeed: number;
  74513. /**
  74514. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74515. */
  74516. maxAngularSpeed: number;
  74517. /**
  74518. * The texture used to render each particle. (this can be a spritesheet)
  74519. */
  74520. particleTexture: Nullable<Texture>;
  74521. /**
  74522. * The layer mask we are rendering the particles through.
  74523. */
  74524. layerMask: number;
  74525. /**
  74526. * This can help using your own shader to render the particle system.
  74527. * The according effect will be created
  74528. */
  74529. customShader: any;
  74530. /**
  74531. * By default particle system starts as soon as they are created. This prevents the
  74532. * automatic start to happen and let you decide when to start emitting particles.
  74533. */
  74534. preventAutoStart: boolean;
  74535. private _noiseTexture;
  74536. /**
  74537. * Gets or sets a texture used to add random noise to particle positions
  74538. */
  74539. noiseTexture: Nullable<ProceduralTexture>;
  74540. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74541. noiseStrength: Vector3;
  74542. /**
  74543. * Callback triggered when the particle animation is ending.
  74544. */
  74545. onAnimationEnd: Nullable<() => void>;
  74546. /**
  74547. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  74548. */
  74549. blendMode: number;
  74550. /**
  74551. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  74552. * to override the particles.
  74553. */
  74554. forceDepthWrite: boolean;
  74555. /** 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 */
  74556. preWarmCycles: number;
  74557. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  74558. preWarmStepOffset: number;
  74559. /**
  74560. * 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)
  74561. */
  74562. spriteCellChangeSpeed: number;
  74563. /**
  74564. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74565. */
  74566. startSpriteCellID: number;
  74567. /**
  74568. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74569. */
  74570. endSpriteCellID: number;
  74571. /**
  74572. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74573. */
  74574. spriteCellWidth: number;
  74575. /**
  74576. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74577. */
  74578. spriteCellHeight: number;
  74579. /**
  74580. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74581. */
  74582. spriteRandomStartCell: boolean;
  74583. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74584. translationPivot: Vector2;
  74585. /** @hidden */
  74586. protected _isAnimationSheetEnabled: boolean;
  74587. /**
  74588. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74589. */
  74590. beginAnimationOnStart: boolean;
  74591. /**
  74592. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74593. */
  74594. beginAnimationFrom: number;
  74595. /**
  74596. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74597. */
  74598. beginAnimationTo: number;
  74599. /**
  74600. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74601. */
  74602. beginAnimationLoop: boolean;
  74603. /**
  74604. * Gets or sets a world offset applied to all particles
  74605. */
  74606. worldOffset: Vector3;
  74607. /**
  74608. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  74609. */
  74610. isAnimationSheetEnabled: boolean;
  74611. /**
  74612. * Get hosting scene
  74613. * @returns the scene
  74614. */
  74615. getScene(): Scene;
  74616. /**
  74617. * You can use gravity if you want to give an orientation to your particles.
  74618. */
  74619. gravity: Vector3;
  74620. protected _colorGradients: Nullable<Array<ColorGradient>>;
  74621. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  74622. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  74623. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  74624. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  74625. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  74626. protected _dragGradients: Nullable<Array<FactorGradient>>;
  74627. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  74628. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  74629. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  74630. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  74631. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  74632. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  74633. /**
  74634. * Defines the delay in milliseconds before starting the system (0 by default)
  74635. */
  74636. startDelay: number;
  74637. /**
  74638. * Gets the current list of drag gradients.
  74639. * You must use addDragGradient and removeDragGradient to udpate this list
  74640. * @returns the list of drag gradients
  74641. */
  74642. getDragGradients(): Nullable<Array<FactorGradient>>;
  74643. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74644. limitVelocityDamping: number;
  74645. /**
  74646. * Gets the current list of limit velocity gradients.
  74647. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74648. * @returns the list of limit velocity gradients
  74649. */
  74650. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74651. /**
  74652. * Gets the current list of color gradients.
  74653. * You must use addColorGradient and removeColorGradient to udpate this list
  74654. * @returns the list of color gradients
  74655. */
  74656. getColorGradients(): Nullable<Array<ColorGradient>>;
  74657. /**
  74658. * Gets the current list of size gradients.
  74659. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74660. * @returns the list of size gradients
  74661. */
  74662. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74663. /**
  74664. * Gets the current list of color remap gradients.
  74665. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74666. * @returns the list of color remap gradients
  74667. */
  74668. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74669. /**
  74670. * Gets the current list of alpha remap gradients.
  74671. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74672. * @returns the list of alpha remap gradients
  74673. */
  74674. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74675. /**
  74676. * Gets the current list of life time gradients.
  74677. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74678. * @returns the list of life time gradients
  74679. */
  74680. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74681. /**
  74682. * Gets the current list of angular speed gradients.
  74683. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74684. * @returns the list of angular speed gradients
  74685. */
  74686. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74687. /**
  74688. * Gets the current list of velocity gradients.
  74689. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74690. * @returns the list of velocity gradients
  74691. */
  74692. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74693. /**
  74694. * Gets the current list of start size gradients.
  74695. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74696. * @returns the list of start size gradients
  74697. */
  74698. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74699. /**
  74700. * Gets the current list of emit rate gradients.
  74701. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74702. * @returns the list of emit rate gradients
  74703. */
  74704. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74705. /**
  74706. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74707. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74708. */
  74709. direction1: Vector3;
  74710. /**
  74711. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74712. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74713. */
  74714. direction2: Vector3;
  74715. /**
  74716. * 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.
  74717. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74718. */
  74719. minEmitBox: Vector3;
  74720. /**
  74721. * 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.
  74722. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74723. */
  74724. maxEmitBox: Vector3;
  74725. /**
  74726. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74727. */
  74728. color1: Color4;
  74729. /**
  74730. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74731. */
  74732. color2: Color4;
  74733. /**
  74734. * Color the particle will have at the end of its lifetime
  74735. */
  74736. colorDead: Color4;
  74737. /**
  74738. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  74739. */
  74740. textureMask: Color4;
  74741. /**
  74742. * The particle emitter type defines the emitter used by the particle system.
  74743. * It can be for example box, sphere, or cone...
  74744. */
  74745. particleEmitterType: IParticleEmitterType;
  74746. /** @hidden */
  74747. _isSubEmitter: boolean;
  74748. /**
  74749. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74750. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74751. */
  74752. billboardMode: number;
  74753. protected _isBillboardBased: boolean;
  74754. /**
  74755. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74756. */
  74757. isBillboardBased: boolean;
  74758. /**
  74759. * The scene the particle system belongs to.
  74760. */
  74761. protected _scene: Scene;
  74762. /**
  74763. * Local cache of defines for image processing.
  74764. */
  74765. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  74766. /**
  74767. * Default configuration related to image processing available in the standard Material.
  74768. */
  74769. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  74770. /**
  74771. * Gets the image processing configuration used either in this material.
  74772. */
  74773. /**
  74774. * Sets the Default image processing configuration used either in the this material.
  74775. *
  74776. * If sets to null, the scene one is in use.
  74777. */
  74778. imageProcessingConfiguration: ImageProcessingConfiguration;
  74779. /**
  74780. * Attaches a new image processing configuration to the Standard Material.
  74781. * @param configuration
  74782. */
  74783. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  74784. /** @hidden */
  74785. protected _reset(): void;
  74786. /** @hidden */
  74787. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  74788. /**
  74789. * Instantiates a particle system.
  74790. * 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.
  74791. * @param name The name of the particle system
  74792. */
  74793. constructor(name: string);
  74794. /**
  74795. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74796. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74797. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74798. * @returns the emitter
  74799. */
  74800. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74801. /**
  74802. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74803. * @param radius The radius of the hemisphere to emit from
  74804. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74805. * @returns the emitter
  74806. */
  74807. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  74808. /**
  74809. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74810. * @param radius The radius of the sphere to emit from
  74811. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74812. * @returns the emitter
  74813. */
  74814. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  74815. /**
  74816. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74817. * @param radius The radius of the sphere to emit from
  74818. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74819. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74820. * @returns the emitter
  74821. */
  74822. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  74823. /**
  74824. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74825. * @param radius The radius of the emission cylinder
  74826. * @param height The height of the emission cylinder
  74827. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74828. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74829. * @returns the emitter
  74830. */
  74831. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  74832. /**
  74833. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74834. * @param radius The radius of the cylinder to emit from
  74835. * @param height The height of the emission cylinder
  74836. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74837. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74838. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74839. * @returns the emitter
  74840. */
  74841. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  74842. /**
  74843. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74844. * @param radius The radius of the cone to emit from
  74845. * @param angle The base angle of the cone
  74846. * @returns the emitter
  74847. */
  74848. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  74849. /**
  74850. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74851. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74852. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74853. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74854. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74855. * @returns the emitter
  74856. */
  74857. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74858. }
  74859. }
  74860. declare module BABYLON {
  74861. /**
  74862. * Type of sub emitter
  74863. */
  74864. export enum SubEmitterType {
  74865. /**
  74866. * Attached to the particle over it's lifetime
  74867. */
  74868. ATTACHED = 0,
  74869. /**
  74870. * Created when the particle dies
  74871. */
  74872. END = 1
  74873. }
  74874. /**
  74875. * Sub emitter class used to emit particles from an existing particle
  74876. */
  74877. export class SubEmitter {
  74878. /**
  74879. * the particle system to be used by the sub emitter
  74880. */
  74881. particleSystem: ParticleSystem;
  74882. /**
  74883. * Type of the submitter (Default: END)
  74884. */
  74885. type: SubEmitterType;
  74886. /**
  74887. * 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)
  74888. * Note: This only is supported when using an emitter of type Mesh
  74889. */
  74890. inheritDirection: boolean;
  74891. /**
  74892. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  74893. */
  74894. inheritedVelocityAmount: number;
  74895. /**
  74896. * Creates a sub emitter
  74897. * @param particleSystem the particle system to be used by the sub emitter
  74898. */
  74899. constructor(
  74900. /**
  74901. * the particle system to be used by the sub emitter
  74902. */
  74903. particleSystem: ParticleSystem);
  74904. /**
  74905. * Clones the sub emitter
  74906. * @returns the cloned sub emitter
  74907. */
  74908. clone(): SubEmitter;
  74909. /**
  74910. * Serialize current object to a JSON object
  74911. * @returns the serialized object
  74912. */
  74913. serialize(): any;
  74914. /** @hidden */
  74915. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  74916. /**
  74917. * Creates a new SubEmitter from a serialized JSON version
  74918. * @param serializationObject defines the JSON object to read from
  74919. * @param scene defines the hosting scene
  74920. * @param rootUrl defines the rootUrl for data loading
  74921. * @returns a new SubEmitter
  74922. */
  74923. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74924. /** Release associated resources */
  74925. dispose(): void;
  74926. }
  74927. }
  74928. declare module BABYLON {
  74929. /** @hidden */
  74930. export var clipPlaneFragmentDeclaration: {
  74931. name: string;
  74932. shader: string;
  74933. };
  74934. }
  74935. declare module BABYLON {
  74936. /** @hidden */
  74937. export var imageProcessingDeclaration: {
  74938. name: string;
  74939. shader: string;
  74940. };
  74941. }
  74942. declare module BABYLON {
  74943. /** @hidden */
  74944. export var imageProcessingFunctions: {
  74945. name: string;
  74946. shader: string;
  74947. };
  74948. }
  74949. declare module BABYLON {
  74950. /** @hidden */
  74951. export var clipPlaneFragment: {
  74952. name: string;
  74953. shader: string;
  74954. };
  74955. }
  74956. declare module BABYLON {
  74957. /** @hidden */
  74958. export var particlesPixelShader: {
  74959. name: string;
  74960. shader: string;
  74961. };
  74962. }
  74963. declare module BABYLON {
  74964. /** @hidden */
  74965. export var clipPlaneVertexDeclaration: {
  74966. name: string;
  74967. shader: string;
  74968. };
  74969. }
  74970. declare module BABYLON {
  74971. /** @hidden */
  74972. export var clipPlaneVertex: {
  74973. name: string;
  74974. shader: string;
  74975. };
  74976. }
  74977. declare module BABYLON {
  74978. /** @hidden */
  74979. export var particlesVertexShader: {
  74980. name: string;
  74981. shader: string;
  74982. };
  74983. }
  74984. declare module BABYLON {
  74985. /**
  74986. * This represents a particle system in Babylon.
  74987. * 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.
  74988. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74989. * @example https://doc.babylonjs.com/babylon101/particles
  74990. */
  74991. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74992. /**
  74993. * Billboard mode will only apply to Y axis
  74994. */
  74995. static readonly BILLBOARDMODE_Y: number;
  74996. /**
  74997. * Billboard mode will apply to all axes
  74998. */
  74999. static readonly BILLBOARDMODE_ALL: number;
  75000. /**
  75001. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  75002. */
  75003. static readonly BILLBOARDMODE_STRETCHED: number;
  75004. /**
  75005. * This function can be defined to provide custom update for active particles.
  75006. * This function will be called instead of regular update (age, position, color, etc.).
  75007. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  75008. */
  75009. updateFunction: (particles: Particle[]) => void;
  75010. private _emitterWorldMatrix;
  75011. /**
  75012. * This function can be defined to specify initial direction for every new particle.
  75013. * It by default use the emitterType defined function
  75014. */
  75015. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  75016. /**
  75017. * This function can be defined to specify initial position for every new particle.
  75018. * It by default use the emitterType defined function
  75019. */
  75020. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  75021. /**
  75022. * @hidden
  75023. */
  75024. _inheritedVelocityOffset: Vector3;
  75025. /**
  75026. * An event triggered when the system is disposed
  75027. */
  75028. onDisposeObservable: Observable<ParticleSystem>;
  75029. private _onDisposeObserver;
  75030. /**
  75031. * Sets a callback that will be triggered when the system is disposed
  75032. */
  75033. onDispose: () => void;
  75034. private _particles;
  75035. private _epsilon;
  75036. private _capacity;
  75037. private _stockParticles;
  75038. private _newPartsExcess;
  75039. private _vertexData;
  75040. private _vertexBuffer;
  75041. private _vertexBuffers;
  75042. private _spriteBuffer;
  75043. private _indexBuffer;
  75044. private _effect;
  75045. private _customEffect;
  75046. private _cachedDefines;
  75047. private _scaledColorStep;
  75048. private _colorDiff;
  75049. private _scaledDirection;
  75050. private _scaledGravity;
  75051. private _currentRenderId;
  75052. private _alive;
  75053. private _useInstancing;
  75054. private _started;
  75055. private _stopped;
  75056. private _actualFrame;
  75057. private _scaledUpdateSpeed;
  75058. private _vertexBufferSize;
  75059. /** @hidden */
  75060. _currentEmitRateGradient: Nullable<FactorGradient>;
  75061. /** @hidden */
  75062. _currentEmitRate1: number;
  75063. /** @hidden */
  75064. _currentEmitRate2: number;
  75065. /** @hidden */
  75066. _currentStartSizeGradient: Nullable<FactorGradient>;
  75067. /** @hidden */
  75068. _currentStartSize1: number;
  75069. /** @hidden */
  75070. _currentStartSize2: number;
  75071. private readonly _rawTextureWidth;
  75072. private _rampGradientsTexture;
  75073. private _useRampGradients;
  75074. /** Gets or sets a boolean indicating that ramp gradients must be used
  75075. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  75076. */
  75077. useRampGradients: boolean;
  75078. /**
  75079. * 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.
  75080. * 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: [])
  75081. */
  75082. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  75083. private _subEmitters;
  75084. /**
  75085. * @hidden
  75086. * If the particle systems emitter should be disposed when the particle system is disposed
  75087. */
  75088. _disposeEmitterOnDispose: boolean;
  75089. /**
  75090. * The current active Sub-systems, this property is used by the root particle system only.
  75091. */
  75092. activeSubSystems: Array<ParticleSystem>;
  75093. private _rootParticleSystem;
  75094. /**
  75095. * Gets the current list of active particles
  75096. */
  75097. readonly particles: Particle[];
  75098. /**
  75099. * Returns the string "ParticleSystem"
  75100. * @returns a string containing the class name
  75101. */
  75102. getClassName(): string;
  75103. /**
  75104. * Instantiates a particle system.
  75105. * 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.
  75106. * @param name The name of the particle system
  75107. * @param capacity The max number of particles alive at the same time
  75108. * @param scene The scene the particle system belongs to
  75109. * @param customEffect a custom effect used to change the way particles are rendered by default
  75110. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  75111. * @param epsilon Offset used to render the particles
  75112. */
  75113. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  75114. private _addFactorGradient;
  75115. private _removeFactorGradient;
  75116. /**
  75117. * Adds a new life time gradient
  75118. * @param gradient defines the gradient to use (between 0 and 1)
  75119. * @param factor defines the life time factor to affect to the specified gradient
  75120. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75121. * @returns the current particle system
  75122. */
  75123. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75124. /**
  75125. * Remove a specific life time gradient
  75126. * @param gradient defines the gradient to remove
  75127. * @returns the current particle system
  75128. */
  75129. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75130. /**
  75131. * Adds a new size gradient
  75132. * @param gradient defines the gradient to use (between 0 and 1)
  75133. * @param factor defines the size factor to affect to the specified gradient
  75134. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75135. * @returns the current particle system
  75136. */
  75137. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75138. /**
  75139. * Remove a specific size gradient
  75140. * @param gradient defines the gradient to remove
  75141. * @returns the current particle system
  75142. */
  75143. removeSizeGradient(gradient: number): IParticleSystem;
  75144. /**
  75145. * Adds a new color remap gradient
  75146. * @param gradient defines the gradient to use (between 0 and 1)
  75147. * @param min defines the color remap minimal range
  75148. * @param max defines the color remap maximal range
  75149. * @returns the current particle system
  75150. */
  75151. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75152. /**
  75153. * Remove a specific color remap gradient
  75154. * @param gradient defines the gradient to remove
  75155. * @returns the current particle system
  75156. */
  75157. removeColorRemapGradient(gradient: number): IParticleSystem;
  75158. /**
  75159. * Adds a new alpha remap gradient
  75160. * @param gradient defines the gradient to use (between 0 and 1)
  75161. * @param min defines the alpha remap minimal range
  75162. * @param max defines the alpha remap maximal range
  75163. * @returns the current particle system
  75164. */
  75165. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75166. /**
  75167. * Remove a specific alpha remap gradient
  75168. * @param gradient defines the gradient to remove
  75169. * @returns the current particle system
  75170. */
  75171. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  75172. /**
  75173. * Adds a new angular speed gradient
  75174. * @param gradient defines the gradient to use (between 0 and 1)
  75175. * @param factor defines the angular speed to affect to the specified gradient
  75176. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75177. * @returns the current particle system
  75178. */
  75179. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75180. /**
  75181. * Remove a specific angular speed gradient
  75182. * @param gradient defines the gradient to remove
  75183. * @returns the current particle system
  75184. */
  75185. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75186. /**
  75187. * Adds a new velocity gradient
  75188. * @param gradient defines the gradient to use (between 0 and 1)
  75189. * @param factor defines the velocity to affect to the specified gradient
  75190. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75191. * @returns the current particle system
  75192. */
  75193. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75194. /**
  75195. * Remove a specific velocity gradient
  75196. * @param gradient defines the gradient to remove
  75197. * @returns the current particle system
  75198. */
  75199. removeVelocityGradient(gradient: number): IParticleSystem;
  75200. /**
  75201. * Adds a new limit velocity gradient
  75202. * @param gradient defines the gradient to use (between 0 and 1)
  75203. * @param factor defines the limit velocity value to affect to the specified gradient
  75204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75205. * @returns the current particle system
  75206. */
  75207. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75208. /**
  75209. * Remove a specific limit velocity gradient
  75210. * @param gradient defines the gradient to remove
  75211. * @returns the current particle system
  75212. */
  75213. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75214. /**
  75215. * Adds a new drag gradient
  75216. * @param gradient defines the gradient to use (between 0 and 1)
  75217. * @param factor defines the drag value to affect to the specified gradient
  75218. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75219. * @returns the current particle system
  75220. */
  75221. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75222. /**
  75223. * Remove a specific drag gradient
  75224. * @param gradient defines the gradient to remove
  75225. * @returns the current particle system
  75226. */
  75227. removeDragGradient(gradient: number): IParticleSystem;
  75228. /**
  75229. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75230. * @param gradient defines the gradient to use (between 0 and 1)
  75231. * @param factor defines the emit rate value to affect to the specified gradient
  75232. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75233. * @returns the current particle system
  75234. */
  75235. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75236. /**
  75237. * Remove a specific emit rate gradient
  75238. * @param gradient defines the gradient to remove
  75239. * @returns the current particle system
  75240. */
  75241. removeEmitRateGradient(gradient: number): IParticleSystem;
  75242. /**
  75243. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75244. * @param gradient defines the gradient to use (between 0 and 1)
  75245. * @param factor defines the start size value to affect to the specified gradient
  75246. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75247. * @returns the current particle system
  75248. */
  75249. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75250. /**
  75251. * Remove a specific start size gradient
  75252. * @param gradient defines the gradient to remove
  75253. * @returns the current particle system
  75254. */
  75255. removeStartSizeGradient(gradient: number): IParticleSystem;
  75256. private _createRampGradientTexture;
  75257. /**
  75258. * Gets the current list of ramp gradients.
  75259. * You must use addRampGradient and removeRampGradient to udpate this list
  75260. * @returns the list of ramp gradients
  75261. */
  75262. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75263. /**
  75264. * Adds a new ramp gradient used to remap particle colors
  75265. * @param gradient defines the gradient to use (between 0 and 1)
  75266. * @param color defines the color to affect to the specified gradient
  75267. * @returns the current particle system
  75268. */
  75269. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  75270. /**
  75271. * Remove a specific ramp gradient
  75272. * @param gradient defines the gradient to remove
  75273. * @returns the current particle system
  75274. */
  75275. removeRampGradient(gradient: number): ParticleSystem;
  75276. /**
  75277. * Adds a new color gradient
  75278. * @param gradient defines the gradient to use (between 0 and 1)
  75279. * @param color1 defines the color to affect to the specified gradient
  75280. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75281. * @returns this particle system
  75282. */
  75283. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75284. /**
  75285. * Remove a specific color gradient
  75286. * @param gradient defines the gradient to remove
  75287. * @returns this particle system
  75288. */
  75289. removeColorGradient(gradient: number): IParticleSystem;
  75290. private _fetchR;
  75291. protected _reset(): void;
  75292. private _resetEffect;
  75293. private _createVertexBuffers;
  75294. private _createIndexBuffer;
  75295. /**
  75296. * Gets the maximum number of particles active at the same time.
  75297. * @returns The max number of active particles.
  75298. */
  75299. getCapacity(): number;
  75300. /**
  75301. * Gets whether there are still active particles in the system.
  75302. * @returns True if it is alive, otherwise false.
  75303. */
  75304. isAlive(): boolean;
  75305. /**
  75306. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75307. * @returns True if it has been started, otherwise false.
  75308. */
  75309. isStarted(): boolean;
  75310. private _prepareSubEmitterInternalArray;
  75311. /**
  75312. * Starts the particle system and begins to emit
  75313. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  75314. */
  75315. start(delay?: number): void;
  75316. /**
  75317. * Stops the particle system.
  75318. * @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.
  75319. */
  75320. stop(stopSubEmitters?: boolean): void;
  75321. /**
  75322. * Remove all active particles
  75323. */
  75324. reset(): void;
  75325. /**
  75326. * @hidden (for internal use only)
  75327. */
  75328. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  75329. /**
  75330. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  75331. * Its lifetime will start back at 0.
  75332. */
  75333. recycleParticle: (particle: Particle) => void;
  75334. private _stopSubEmitters;
  75335. private _createParticle;
  75336. private _removeFromRoot;
  75337. private _emitFromParticle;
  75338. private _update;
  75339. /** @hidden */
  75340. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  75341. /** @hidden */
  75342. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  75343. /** @hidden */
  75344. private _getEffect;
  75345. /**
  75346. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  75347. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  75348. */
  75349. animate(preWarmOnly?: boolean): void;
  75350. private _appendParticleVertices;
  75351. /**
  75352. * Rebuilds the particle system.
  75353. */
  75354. rebuild(): void;
  75355. /**
  75356. * Is this system ready to be used/rendered
  75357. * @return true if the system is ready
  75358. */
  75359. isReady(): boolean;
  75360. private _render;
  75361. /**
  75362. * Renders the particle system in its current state.
  75363. * @returns the current number of particles
  75364. */
  75365. render(): number;
  75366. /**
  75367. * Disposes the particle system and free the associated resources
  75368. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75369. */
  75370. dispose(disposeTexture?: boolean): void;
  75371. /**
  75372. * Clones the particle system.
  75373. * @param name The name of the cloned object
  75374. * @param newEmitter The new emitter to use
  75375. * @returns the cloned particle system
  75376. */
  75377. clone(name: string, newEmitter: any): ParticleSystem;
  75378. /**
  75379. * Serializes the particle system to a JSON object.
  75380. * @returns the JSON object
  75381. */
  75382. serialize(): any;
  75383. /** @hidden */
  75384. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  75385. /** @hidden */
  75386. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  75387. /**
  75388. * Parses a JSON object to create a particle system.
  75389. * @param parsedParticleSystem The JSON object to parse
  75390. * @param scene The scene to create the particle system in
  75391. * @param rootUrl The root url to use to load external dependencies like texture
  75392. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  75393. * @returns the Parsed particle system
  75394. */
  75395. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  75396. }
  75397. }
  75398. declare module BABYLON {
  75399. /**
  75400. * A particle represents one of the element emitted by a particle system.
  75401. * This is mainly define by its coordinates, direction, velocity and age.
  75402. */
  75403. export class Particle {
  75404. /**
  75405. * The particle system the particle belongs to.
  75406. */
  75407. particleSystem: ParticleSystem;
  75408. private static _Count;
  75409. /**
  75410. * Unique ID of the particle
  75411. */
  75412. id: number;
  75413. /**
  75414. * The world position of the particle in the scene.
  75415. */
  75416. position: Vector3;
  75417. /**
  75418. * The world direction of the particle in the scene.
  75419. */
  75420. direction: Vector3;
  75421. /**
  75422. * The color of the particle.
  75423. */
  75424. color: Color4;
  75425. /**
  75426. * The color change of the particle per step.
  75427. */
  75428. colorStep: Color4;
  75429. /**
  75430. * Defines how long will the life of the particle be.
  75431. */
  75432. lifeTime: number;
  75433. /**
  75434. * The current age of the particle.
  75435. */
  75436. age: number;
  75437. /**
  75438. * The current size of the particle.
  75439. */
  75440. size: number;
  75441. /**
  75442. * The current scale of the particle.
  75443. */
  75444. scale: Vector2;
  75445. /**
  75446. * The current angle of the particle.
  75447. */
  75448. angle: number;
  75449. /**
  75450. * Defines how fast is the angle changing.
  75451. */
  75452. angularSpeed: number;
  75453. /**
  75454. * Defines the cell index used by the particle to be rendered from a sprite.
  75455. */
  75456. cellIndex: number;
  75457. /**
  75458. * The information required to support color remapping
  75459. */
  75460. remapData: Vector4;
  75461. /** @hidden */
  75462. _randomCellOffset?: number;
  75463. /** @hidden */
  75464. _initialDirection: Nullable<Vector3>;
  75465. /** @hidden */
  75466. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  75467. /** @hidden */
  75468. _initialStartSpriteCellID: number;
  75469. /** @hidden */
  75470. _initialEndSpriteCellID: number;
  75471. /** @hidden */
  75472. _currentColorGradient: Nullable<ColorGradient>;
  75473. /** @hidden */
  75474. _currentColor1: Color4;
  75475. /** @hidden */
  75476. _currentColor2: Color4;
  75477. /** @hidden */
  75478. _currentSizeGradient: Nullable<FactorGradient>;
  75479. /** @hidden */
  75480. _currentSize1: number;
  75481. /** @hidden */
  75482. _currentSize2: number;
  75483. /** @hidden */
  75484. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  75485. /** @hidden */
  75486. _currentAngularSpeed1: number;
  75487. /** @hidden */
  75488. _currentAngularSpeed2: number;
  75489. /** @hidden */
  75490. _currentVelocityGradient: Nullable<FactorGradient>;
  75491. /** @hidden */
  75492. _currentVelocity1: number;
  75493. /** @hidden */
  75494. _currentVelocity2: number;
  75495. /** @hidden */
  75496. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  75497. /** @hidden */
  75498. _currentLimitVelocity1: number;
  75499. /** @hidden */
  75500. _currentLimitVelocity2: number;
  75501. /** @hidden */
  75502. _currentDragGradient: Nullable<FactorGradient>;
  75503. /** @hidden */
  75504. _currentDrag1: number;
  75505. /** @hidden */
  75506. _currentDrag2: number;
  75507. /** @hidden */
  75508. _randomNoiseCoordinates1: Vector3;
  75509. /** @hidden */
  75510. _randomNoiseCoordinates2: Vector3;
  75511. /**
  75512. * Creates a new instance Particle
  75513. * @param particleSystem the particle system the particle belongs to
  75514. */
  75515. constructor(
  75516. /**
  75517. * The particle system the particle belongs to.
  75518. */
  75519. particleSystem: ParticleSystem);
  75520. private updateCellInfoFromSystem;
  75521. /**
  75522. * Defines how the sprite cell index is updated for the particle
  75523. */
  75524. updateCellIndex(): void;
  75525. /** @hidden */
  75526. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  75527. /** @hidden */
  75528. _inheritParticleInfoToSubEmitters(): void;
  75529. /** @hidden */
  75530. _reset(): void;
  75531. /**
  75532. * Copy the properties of particle to another one.
  75533. * @param other the particle to copy the information to.
  75534. */
  75535. copyTo(other: Particle): void;
  75536. }
  75537. }
  75538. declare module BABYLON {
  75539. /**
  75540. * Particle emitter represents a volume emitting particles.
  75541. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  75542. */
  75543. export interface IParticleEmitterType {
  75544. /**
  75545. * Called by the particle System when the direction is computed for the created particle.
  75546. * @param worldMatrix is the world matrix of the particle system
  75547. * @param directionToUpdate is the direction vector to update with the result
  75548. * @param particle is the particle we are computed the direction for
  75549. */
  75550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75551. /**
  75552. * Called by the particle System when the position is computed for the created particle.
  75553. * @param worldMatrix is the world matrix of the particle system
  75554. * @param positionToUpdate is the position vector to update with the result
  75555. * @param particle is the particle we are computed the position for
  75556. */
  75557. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75558. /**
  75559. * Clones the current emitter and returns a copy of it
  75560. * @returns the new emitter
  75561. */
  75562. clone(): IParticleEmitterType;
  75563. /**
  75564. * Called by the GPUParticleSystem to setup the update shader
  75565. * @param effect defines the update shader
  75566. */
  75567. applyToShader(effect: Effect): void;
  75568. /**
  75569. * Returns a string to use to update the GPU particles update shader
  75570. * @returns the effect defines string
  75571. */
  75572. getEffectDefines(): string;
  75573. /**
  75574. * Returns a string representing the class name
  75575. * @returns a string containing the class name
  75576. */
  75577. getClassName(): string;
  75578. /**
  75579. * Serializes the particle system to a JSON object.
  75580. * @returns the JSON object
  75581. */
  75582. serialize(): any;
  75583. /**
  75584. * Parse properties from a JSON object
  75585. * @param serializationObject defines the JSON object
  75586. */
  75587. parse(serializationObject: any): void;
  75588. }
  75589. }
  75590. declare module BABYLON {
  75591. /**
  75592. * Particle emitter emitting particles from the inside of a box.
  75593. * It emits the particles randomly between 2 given directions.
  75594. */
  75595. export class BoxParticleEmitter implements IParticleEmitterType {
  75596. /**
  75597. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75598. */
  75599. direction1: Vector3;
  75600. /**
  75601. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75602. */
  75603. direction2: Vector3;
  75604. /**
  75605. * 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.
  75606. */
  75607. minEmitBox: Vector3;
  75608. /**
  75609. * 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.
  75610. */
  75611. maxEmitBox: Vector3;
  75612. /**
  75613. * Creates a new instance BoxParticleEmitter
  75614. */
  75615. constructor();
  75616. /**
  75617. * Called by the particle System when the direction is computed for the created particle.
  75618. * @param worldMatrix is the world matrix of the particle system
  75619. * @param directionToUpdate is the direction vector to update with the result
  75620. * @param particle is the particle we are computed the direction for
  75621. */
  75622. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75623. /**
  75624. * Called by the particle System when the position is computed for the created particle.
  75625. * @param worldMatrix is the world matrix of the particle system
  75626. * @param positionToUpdate is the position vector to update with the result
  75627. * @param particle is the particle we are computed the position for
  75628. */
  75629. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75630. /**
  75631. * Clones the current emitter and returns a copy of it
  75632. * @returns the new emitter
  75633. */
  75634. clone(): BoxParticleEmitter;
  75635. /**
  75636. * Called by the GPUParticleSystem to setup the update shader
  75637. * @param effect defines the update shader
  75638. */
  75639. applyToShader(effect: Effect): void;
  75640. /**
  75641. * Returns a string to use to update the GPU particles update shader
  75642. * @returns a string containng the defines string
  75643. */
  75644. getEffectDefines(): string;
  75645. /**
  75646. * Returns the string "BoxParticleEmitter"
  75647. * @returns a string containing the class name
  75648. */
  75649. getClassName(): string;
  75650. /**
  75651. * Serializes the particle system to a JSON object.
  75652. * @returns the JSON object
  75653. */
  75654. serialize(): any;
  75655. /**
  75656. * Parse properties from a JSON object
  75657. * @param serializationObject defines the JSON object
  75658. */
  75659. parse(serializationObject: any): void;
  75660. }
  75661. }
  75662. declare module BABYLON {
  75663. /**
  75664. * Particle emitter emitting particles from the inside of a cone.
  75665. * It emits the particles alongside the cone volume from the base to the particle.
  75666. * The emission direction might be randomized.
  75667. */
  75668. export class ConeParticleEmitter implements IParticleEmitterType {
  75669. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75670. directionRandomizer: number;
  75671. private _radius;
  75672. private _angle;
  75673. private _height;
  75674. /**
  75675. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  75676. */
  75677. radiusRange: number;
  75678. /**
  75679. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  75680. */
  75681. heightRange: number;
  75682. /**
  75683. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  75684. */
  75685. emitFromSpawnPointOnly: boolean;
  75686. /**
  75687. * Gets or sets the radius of the emission cone
  75688. */
  75689. radius: number;
  75690. /**
  75691. * Gets or sets the angle of the emission cone
  75692. */
  75693. angle: number;
  75694. private _buildHeight;
  75695. /**
  75696. * Creates a new instance ConeParticleEmitter
  75697. * @param radius the radius of the emission cone (1 by default)
  75698. * @param angle the cone base angle (PI by default)
  75699. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  75700. */
  75701. constructor(radius?: number, angle?: number,
  75702. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75703. directionRandomizer?: number);
  75704. /**
  75705. * Called by the particle System when the direction is computed for the created particle.
  75706. * @param worldMatrix is the world matrix of the particle system
  75707. * @param directionToUpdate is the direction vector to update with the result
  75708. * @param particle is the particle we are computed the direction for
  75709. */
  75710. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75711. /**
  75712. * Called by the particle System when the position is computed for the created particle.
  75713. * @param worldMatrix is the world matrix of the particle system
  75714. * @param positionToUpdate is the position vector to update with the result
  75715. * @param particle is the particle we are computed the position for
  75716. */
  75717. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75718. /**
  75719. * Clones the current emitter and returns a copy of it
  75720. * @returns the new emitter
  75721. */
  75722. clone(): ConeParticleEmitter;
  75723. /**
  75724. * Called by the GPUParticleSystem to setup the update shader
  75725. * @param effect defines the update shader
  75726. */
  75727. applyToShader(effect: Effect): void;
  75728. /**
  75729. * Returns a string to use to update the GPU particles update shader
  75730. * @returns a string containng the defines string
  75731. */
  75732. getEffectDefines(): string;
  75733. /**
  75734. * Returns the string "ConeParticleEmitter"
  75735. * @returns a string containing the class name
  75736. */
  75737. getClassName(): string;
  75738. /**
  75739. * Serializes the particle system to a JSON object.
  75740. * @returns the JSON object
  75741. */
  75742. serialize(): any;
  75743. /**
  75744. * Parse properties from a JSON object
  75745. * @param serializationObject defines the JSON object
  75746. */
  75747. parse(serializationObject: any): void;
  75748. }
  75749. }
  75750. declare module BABYLON {
  75751. /**
  75752. * Particle emitter emitting particles from the inside of a cylinder.
  75753. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  75754. */
  75755. export class CylinderParticleEmitter implements IParticleEmitterType {
  75756. /**
  75757. * The radius of the emission cylinder.
  75758. */
  75759. radius: number;
  75760. /**
  75761. * The height of the emission cylinder.
  75762. */
  75763. height: number;
  75764. /**
  75765. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75766. */
  75767. radiusRange: number;
  75768. /**
  75769. * How much to randomize the particle direction [0-1].
  75770. */
  75771. directionRandomizer: number;
  75772. /**
  75773. * Creates a new instance CylinderParticleEmitter
  75774. * @param radius the radius of the emission cylinder (1 by default)
  75775. * @param height the height of the emission cylinder (1 by default)
  75776. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75777. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75778. */
  75779. constructor(
  75780. /**
  75781. * The radius of the emission cylinder.
  75782. */
  75783. radius?: number,
  75784. /**
  75785. * The height of the emission cylinder.
  75786. */
  75787. height?: number,
  75788. /**
  75789. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75790. */
  75791. radiusRange?: number,
  75792. /**
  75793. * How much to randomize the particle direction [0-1].
  75794. */
  75795. directionRandomizer?: number);
  75796. /**
  75797. * Called by the particle System when the direction is computed for the created particle.
  75798. * @param worldMatrix is the world matrix of the particle system
  75799. * @param directionToUpdate is the direction vector to update with the result
  75800. * @param particle is the particle we are computed the direction for
  75801. */
  75802. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75803. /**
  75804. * Called by the particle System when the position is computed for the created particle.
  75805. * @param worldMatrix is the world matrix of the particle system
  75806. * @param positionToUpdate is the position vector to update with the result
  75807. * @param particle is the particle we are computed the position for
  75808. */
  75809. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75810. /**
  75811. * Clones the current emitter and returns a copy of it
  75812. * @returns the new emitter
  75813. */
  75814. clone(): CylinderParticleEmitter;
  75815. /**
  75816. * Called by the GPUParticleSystem to setup the update shader
  75817. * @param effect defines the update shader
  75818. */
  75819. applyToShader(effect: Effect): void;
  75820. /**
  75821. * Returns a string to use to update the GPU particles update shader
  75822. * @returns a string containng the defines string
  75823. */
  75824. getEffectDefines(): string;
  75825. /**
  75826. * Returns the string "CylinderParticleEmitter"
  75827. * @returns a string containing the class name
  75828. */
  75829. getClassName(): string;
  75830. /**
  75831. * Serializes the particle system to a JSON object.
  75832. * @returns the JSON object
  75833. */
  75834. serialize(): any;
  75835. /**
  75836. * Parse properties from a JSON object
  75837. * @param serializationObject defines the JSON object
  75838. */
  75839. parse(serializationObject: any): void;
  75840. }
  75841. /**
  75842. * Particle emitter emitting particles from the inside of a cylinder.
  75843. * It emits the particles randomly between two vectors.
  75844. */
  75845. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  75846. /**
  75847. * The min limit of the emission direction.
  75848. */
  75849. direction1: Vector3;
  75850. /**
  75851. * The max limit of the emission direction.
  75852. */
  75853. direction2: Vector3;
  75854. /**
  75855. * Creates a new instance CylinderDirectedParticleEmitter
  75856. * @param radius the radius of the emission cylinder (1 by default)
  75857. * @param height the height of the emission cylinder (1 by default)
  75858. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75859. * @param direction1 the min limit of the emission direction (up vector by default)
  75860. * @param direction2 the max limit of the emission direction (up vector by default)
  75861. */
  75862. constructor(radius?: number, height?: number, radiusRange?: number,
  75863. /**
  75864. * The min limit of the emission direction.
  75865. */
  75866. direction1?: Vector3,
  75867. /**
  75868. * The max limit of the emission direction.
  75869. */
  75870. direction2?: Vector3);
  75871. /**
  75872. * Called by the particle System when the direction is computed for the created particle.
  75873. * @param worldMatrix is the world matrix of the particle system
  75874. * @param directionToUpdate is the direction vector to update with the result
  75875. * @param particle is the particle we are computed the direction for
  75876. */
  75877. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75878. /**
  75879. * Clones the current emitter and returns a copy of it
  75880. * @returns the new emitter
  75881. */
  75882. clone(): CylinderDirectedParticleEmitter;
  75883. /**
  75884. * Called by the GPUParticleSystem to setup the update shader
  75885. * @param effect defines the update shader
  75886. */
  75887. applyToShader(effect: Effect): void;
  75888. /**
  75889. * Returns a string to use to update the GPU particles update shader
  75890. * @returns a string containng the defines string
  75891. */
  75892. getEffectDefines(): string;
  75893. /**
  75894. * Returns the string "CylinderDirectedParticleEmitter"
  75895. * @returns a string containing the class name
  75896. */
  75897. getClassName(): string;
  75898. /**
  75899. * Serializes the particle system to a JSON object.
  75900. * @returns the JSON object
  75901. */
  75902. serialize(): any;
  75903. /**
  75904. * Parse properties from a JSON object
  75905. * @param serializationObject defines the JSON object
  75906. */
  75907. parse(serializationObject: any): void;
  75908. }
  75909. }
  75910. declare module BABYLON {
  75911. /**
  75912. * Particle emitter emitting particles from the inside of a hemisphere.
  75913. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  75914. */
  75915. export class HemisphericParticleEmitter implements IParticleEmitterType {
  75916. /**
  75917. * The radius of the emission hemisphere.
  75918. */
  75919. radius: number;
  75920. /**
  75921. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75922. */
  75923. radiusRange: number;
  75924. /**
  75925. * How much to randomize the particle direction [0-1].
  75926. */
  75927. directionRandomizer: number;
  75928. /**
  75929. * Creates a new instance HemisphericParticleEmitter
  75930. * @param radius the radius of the emission hemisphere (1 by default)
  75931. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75932. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75933. */
  75934. constructor(
  75935. /**
  75936. * The radius of the emission hemisphere.
  75937. */
  75938. radius?: number,
  75939. /**
  75940. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75941. */
  75942. radiusRange?: number,
  75943. /**
  75944. * How much to randomize the particle direction [0-1].
  75945. */
  75946. directionRandomizer?: number);
  75947. /**
  75948. * Called by the particle System when the direction is computed for the created particle.
  75949. * @param worldMatrix is the world matrix of the particle system
  75950. * @param directionToUpdate is the direction vector to update with the result
  75951. * @param particle is the particle we are computed the direction for
  75952. */
  75953. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75954. /**
  75955. * Called by the particle System when the position is computed for the created particle.
  75956. * @param worldMatrix is the world matrix of the particle system
  75957. * @param positionToUpdate is the position vector to update with the result
  75958. * @param particle is the particle we are computed the position for
  75959. */
  75960. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75961. /**
  75962. * Clones the current emitter and returns a copy of it
  75963. * @returns the new emitter
  75964. */
  75965. clone(): HemisphericParticleEmitter;
  75966. /**
  75967. * Called by the GPUParticleSystem to setup the update shader
  75968. * @param effect defines the update shader
  75969. */
  75970. applyToShader(effect: Effect): void;
  75971. /**
  75972. * Returns a string to use to update the GPU particles update shader
  75973. * @returns a string containng the defines string
  75974. */
  75975. getEffectDefines(): string;
  75976. /**
  75977. * Returns the string "HemisphericParticleEmitter"
  75978. * @returns a string containing the class name
  75979. */
  75980. getClassName(): string;
  75981. /**
  75982. * Serializes the particle system to a JSON object.
  75983. * @returns the JSON object
  75984. */
  75985. serialize(): any;
  75986. /**
  75987. * Parse properties from a JSON object
  75988. * @param serializationObject defines the JSON object
  75989. */
  75990. parse(serializationObject: any): void;
  75991. }
  75992. }
  75993. declare module BABYLON {
  75994. /**
  75995. * Particle emitter emitting particles from a point.
  75996. * It emits the particles randomly between 2 given directions.
  75997. */
  75998. export class PointParticleEmitter implements IParticleEmitterType {
  75999. /**
  76000. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  76001. */
  76002. direction1: Vector3;
  76003. /**
  76004. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  76005. */
  76006. direction2: Vector3;
  76007. /**
  76008. * Creates a new instance PointParticleEmitter
  76009. */
  76010. constructor();
  76011. /**
  76012. * Called by the particle System when the direction is computed for the created particle.
  76013. * @param worldMatrix is the world matrix of the particle system
  76014. * @param directionToUpdate is the direction vector to update with the result
  76015. * @param particle is the particle we are computed the direction for
  76016. */
  76017. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  76018. /**
  76019. * Called by the particle System when the position is computed for the created particle.
  76020. * @param worldMatrix is the world matrix of the particle system
  76021. * @param positionToUpdate is the position vector to update with the result
  76022. * @param particle is the particle we are computed the position for
  76023. */
  76024. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  76025. /**
  76026. * Clones the current emitter and returns a copy of it
  76027. * @returns the new emitter
  76028. */
  76029. clone(): PointParticleEmitter;
  76030. /**
  76031. * Called by the GPUParticleSystem to setup the update shader
  76032. * @param effect defines the update shader
  76033. */
  76034. applyToShader(effect: Effect): void;
  76035. /**
  76036. * Returns a string to use to update the GPU particles update shader
  76037. * @returns a string containng the defines string
  76038. */
  76039. getEffectDefines(): string;
  76040. /**
  76041. * Returns the string "PointParticleEmitter"
  76042. * @returns a string containing the class name
  76043. */
  76044. getClassName(): string;
  76045. /**
  76046. * Serializes the particle system to a JSON object.
  76047. * @returns the JSON object
  76048. */
  76049. serialize(): any;
  76050. /**
  76051. * Parse properties from a JSON object
  76052. * @param serializationObject defines the JSON object
  76053. */
  76054. parse(serializationObject: any): void;
  76055. }
  76056. }
  76057. declare module BABYLON {
  76058. /**
  76059. * Particle emitter emitting particles from the inside of a sphere.
  76060. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  76061. */
  76062. export class SphereParticleEmitter implements IParticleEmitterType {
  76063. /**
  76064. * The radius of the emission sphere.
  76065. */
  76066. radius: number;
  76067. /**
  76068. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  76069. */
  76070. radiusRange: number;
  76071. /**
  76072. * How much to randomize the particle direction [0-1].
  76073. */
  76074. directionRandomizer: number;
  76075. /**
  76076. * Creates a new instance SphereParticleEmitter
  76077. * @param radius the radius of the emission sphere (1 by default)
  76078. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76079. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  76080. */
  76081. constructor(
  76082. /**
  76083. * The radius of the emission sphere.
  76084. */
  76085. radius?: number,
  76086. /**
  76087. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  76088. */
  76089. radiusRange?: number,
  76090. /**
  76091. * How much to randomize the particle direction [0-1].
  76092. */
  76093. directionRandomizer?: number);
  76094. /**
  76095. * Called by the particle System when the direction is computed for the created particle.
  76096. * @param worldMatrix is the world matrix of the particle system
  76097. * @param directionToUpdate is the direction vector to update with the result
  76098. * @param particle is the particle we are computed the direction for
  76099. */
  76100. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  76101. /**
  76102. * Called by the particle System when the position is computed for the created particle.
  76103. * @param worldMatrix is the world matrix of the particle system
  76104. * @param positionToUpdate is the position vector to update with the result
  76105. * @param particle is the particle we are computed the position for
  76106. */
  76107. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  76108. /**
  76109. * Clones the current emitter and returns a copy of it
  76110. * @returns the new emitter
  76111. */
  76112. clone(): SphereParticleEmitter;
  76113. /**
  76114. * Called by the GPUParticleSystem to setup the update shader
  76115. * @param effect defines the update shader
  76116. */
  76117. applyToShader(effect: Effect): void;
  76118. /**
  76119. * Returns a string to use to update the GPU particles update shader
  76120. * @returns a string containng the defines string
  76121. */
  76122. getEffectDefines(): string;
  76123. /**
  76124. * Returns the string "SphereParticleEmitter"
  76125. * @returns a string containing the class name
  76126. */
  76127. getClassName(): string;
  76128. /**
  76129. * Serializes the particle system to a JSON object.
  76130. * @returns the JSON object
  76131. */
  76132. serialize(): any;
  76133. /**
  76134. * Parse properties from a JSON object
  76135. * @param serializationObject defines the JSON object
  76136. */
  76137. parse(serializationObject: any): void;
  76138. }
  76139. /**
  76140. * Particle emitter emitting particles from the inside of a sphere.
  76141. * It emits the particles randomly between two vectors.
  76142. */
  76143. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  76144. /**
  76145. * The min limit of the emission direction.
  76146. */
  76147. direction1: Vector3;
  76148. /**
  76149. * The max limit of the emission direction.
  76150. */
  76151. direction2: Vector3;
  76152. /**
  76153. * Creates a new instance SphereDirectedParticleEmitter
  76154. * @param radius the radius of the emission sphere (1 by default)
  76155. * @param direction1 the min limit of the emission direction (up vector by default)
  76156. * @param direction2 the max limit of the emission direction (up vector by default)
  76157. */
  76158. constructor(radius?: number,
  76159. /**
  76160. * The min limit of the emission direction.
  76161. */
  76162. direction1?: Vector3,
  76163. /**
  76164. * The max limit of the emission direction.
  76165. */
  76166. direction2?: Vector3);
  76167. /**
  76168. * Called by the particle System when the direction is computed for the created particle.
  76169. * @param worldMatrix is the world matrix of the particle system
  76170. * @param directionToUpdate is the direction vector to update with the result
  76171. * @param particle is the particle we are computed the direction for
  76172. */
  76173. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  76174. /**
  76175. * Clones the current emitter and returns a copy of it
  76176. * @returns the new emitter
  76177. */
  76178. clone(): SphereDirectedParticleEmitter;
  76179. /**
  76180. * Called by the GPUParticleSystem to setup the update shader
  76181. * @param effect defines the update shader
  76182. */
  76183. applyToShader(effect: Effect): void;
  76184. /**
  76185. * Returns a string to use to update the GPU particles update shader
  76186. * @returns a string containng the defines string
  76187. */
  76188. getEffectDefines(): string;
  76189. /**
  76190. * Returns the string "SphereDirectedParticleEmitter"
  76191. * @returns a string containing the class name
  76192. */
  76193. getClassName(): string;
  76194. /**
  76195. * Serializes the particle system to a JSON object.
  76196. * @returns the JSON object
  76197. */
  76198. serialize(): any;
  76199. /**
  76200. * Parse properties from a JSON object
  76201. * @param serializationObject defines the JSON object
  76202. */
  76203. parse(serializationObject: any): void;
  76204. }
  76205. }
  76206. declare module BABYLON {
  76207. /**
  76208. * Interface representing a particle system in Babylon.js.
  76209. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  76210. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  76211. */
  76212. export interface IParticleSystem {
  76213. /**
  76214. * List of animations used by the particle system.
  76215. */
  76216. animations: Animation[];
  76217. /**
  76218. * The id of the Particle system.
  76219. */
  76220. id: string;
  76221. /**
  76222. * The name of the Particle system.
  76223. */
  76224. name: string;
  76225. /**
  76226. * The emitter represents the Mesh or position we are attaching the particle system to.
  76227. */
  76228. emitter: Nullable<AbstractMesh | Vector3>;
  76229. /**
  76230. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  76231. */
  76232. isBillboardBased: boolean;
  76233. /**
  76234. * The rendering group used by the Particle system to chose when to render.
  76235. */
  76236. renderingGroupId: number;
  76237. /**
  76238. * The layer mask we are rendering the particles through.
  76239. */
  76240. layerMask: number;
  76241. /**
  76242. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  76243. */
  76244. updateSpeed: number;
  76245. /**
  76246. * The amount of time the particle system is running (depends of the overall update speed).
  76247. */
  76248. targetStopDuration: number;
  76249. /**
  76250. * The texture used to render each particle. (this can be a spritesheet)
  76251. */
  76252. particleTexture: Nullable<Texture>;
  76253. /**
  76254. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  76255. */
  76256. blendMode: number;
  76257. /**
  76258. * Minimum life time of emitting particles.
  76259. */
  76260. minLifeTime: number;
  76261. /**
  76262. * Maximum life time of emitting particles.
  76263. */
  76264. maxLifeTime: number;
  76265. /**
  76266. * Minimum Size of emitting particles.
  76267. */
  76268. minSize: number;
  76269. /**
  76270. * Maximum Size of emitting particles.
  76271. */
  76272. maxSize: number;
  76273. /**
  76274. * Minimum scale of emitting particles on X axis.
  76275. */
  76276. minScaleX: number;
  76277. /**
  76278. * Maximum scale of emitting particles on X axis.
  76279. */
  76280. maxScaleX: number;
  76281. /**
  76282. * Minimum scale of emitting particles on Y axis.
  76283. */
  76284. minScaleY: number;
  76285. /**
  76286. * Maximum scale of emitting particles on Y axis.
  76287. */
  76288. maxScaleY: number;
  76289. /**
  76290. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76291. */
  76292. color1: Color4;
  76293. /**
  76294. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76295. */
  76296. color2: Color4;
  76297. /**
  76298. * Color the particle will have at the end of its lifetime.
  76299. */
  76300. colorDead: Color4;
  76301. /**
  76302. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  76303. */
  76304. emitRate: number;
  76305. /**
  76306. * You can use gravity if you want to give an orientation to your particles.
  76307. */
  76308. gravity: Vector3;
  76309. /**
  76310. * Minimum power of emitting particles.
  76311. */
  76312. minEmitPower: number;
  76313. /**
  76314. * Maximum power of emitting particles.
  76315. */
  76316. maxEmitPower: number;
  76317. /**
  76318. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  76319. */
  76320. minAngularSpeed: number;
  76321. /**
  76322. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  76323. */
  76324. maxAngularSpeed: number;
  76325. /**
  76326. * Gets or sets the minimal initial rotation in radians.
  76327. */
  76328. minInitialRotation: number;
  76329. /**
  76330. * Gets or sets the maximal initial rotation in radians.
  76331. */
  76332. maxInitialRotation: number;
  76333. /**
  76334. * The particle emitter type defines the emitter used by the particle system.
  76335. * It can be for example box, sphere, or cone...
  76336. */
  76337. particleEmitterType: Nullable<IParticleEmitterType>;
  76338. /**
  76339. * Defines the delay in milliseconds before starting the system (0 by default)
  76340. */
  76341. startDelay: number;
  76342. /**
  76343. * 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
  76344. */
  76345. preWarmCycles: number;
  76346. /**
  76347. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  76348. */
  76349. preWarmStepOffset: number;
  76350. /**
  76351. * 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)
  76352. */
  76353. spriteCellChangeSpeed: number;
  76354. /**
  76355. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  76356. */
  76357. startSpriteCellID: number;
  76358. /**
  76359. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  76360. */
  76361. endSpriteCellID: number;
  76362. /**
  76363. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  76364. */
  76365. spriteCellWidth: number;
  76366. /**
  76367. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  76368. */
  76369. spriteCellHeight: number;
  76370. /**
  76371. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  76372. */
  76373. spriteRandomStartCell: boolean;
  76374. /**
  76375. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  76376. */
  76377. isAnimationSheetEnabled: boolean;
  76378. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  76379. translationPivot: Vector2;
  76380. /**
  76381. * Gets or sets a texture used to add random noise to particle positions
  76382. */
  76383. noiseTexture: Nullable<BaseTexture>;
  76384. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  76385. noiseStrength: Vector3;
  76386. /**
  76387. * Gets or sets the billboard mode to use when isBillboardBased = true.
  76388. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  76389. */
  76390. billboardMode: number;
  76391. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  76392. limitVelocityDamping: number;
  76393. /**
  76394. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  76395. */
  76396. beginAnimationOnStart: boolean;
  76397. /**
  76398. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  76399. */
  76400. beginAnimationFrom: number;
  76401. /**
  76402. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  76403. */
  76404. beginAnimationTo: number;
  76405. /**
  76406. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  76407. */
  76408. beginAnimationLoop: boolean;
  76409. /**
  76410. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  76411. */
  76412. disposeOnStop: boolean;
  76413. /**
  76414. * Gets the maximum number of particles active at the same time.
  76415. * @returns The max number of active particles.
  76416. */
  76417. getCapacity(): number;
  76418. /**
  76419. * Gets if the system has been started. (Note: this will still be true after stop is called)
  76420. * @returns True if it has been started, otherwise false.
  76421. */
  76422. isStarted(): boolean;
  76423. /**
  76424. * Animates the particle system for this frame.
  76425. */
  76426. animate(): void;
  76427. /**
  76428. * Renders the particle system in its current state.
  76429. * @returns the current number of particles
  76430. */
  76431. render(): number;
  76432. /**
  76433. * Dispose the particle system and frees its associated resources.
  76434. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  76435. */
  76436. dispose(disposeTexture?: boolean): void;
  76437. /**
  76438. * Clones the particle system.
  76439. * @param name The name of the cloned object
  76440. * @param newEmitter The new emitter to use
  76441. * @returns the cloned particle system
  76442. */
  76443. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  76444. /**
  76445. * Serializes the particle system to a JSON object.
  76446. * @returns the JSON object
  76447. */
  76448. serialize(): any;
  76449. /**
  76450. * Rebuild the particle system
  76451. */
  76452. rebuild(): void;
  76453. /**
  76454. * Starts the particle system and begins to emit
  76455. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  76456. */
  76457. start(delay?: number): void;
  76458. /**
  76459. * Stops the particle system.
  76460. */
  76461. stop(): void;
  76462. /**
  76463. * Remove all active particles
  76464. */
  76465. reset(): void;
  76466. /**
  76467. * Is this system ready to be used/rendered
  76468. * @return true if the system is ready
  76469. */
  76470. isReady(): boolean;
  76471. /**
  76472. * Adds a new color gradient
  76473. * @param gradient defines the gradient to use (between 0 and 1)
  76474. * @param color1 defines the color to affect to the specified gradient
  76475. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  76476. * @returns the current particle system
  76477. */
  76478. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  76479. /**
  76480. * Remove a specific color gradient
  76481. * @param gradient defines the gradient to remove
  76482. * @returns the current particle system
  76483. */
  76484. removeColorGradient(gradient: number): IParticleSystem;
  76485. /**
  76486. * Adds a new size gradient
  76487. * @param gradient defines the gradient to use (between 0 and 1)
  76488. * @param factor defines the size factor to affect to the specified gradient
  76489. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76490. * @returns the current particle system
  76491. */
  76492. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76493. /**
  76494. * Remove a specific size gradient
  76495. * @param gradient defines the gradient to remove
  76496. * @returns the current particle system
  76497. */
  76498. removeSizeGradient(gradient: number): IParticleSystem;
  76499. /**
  76500. * Gets the current list of color gradients.
  76501. * You must use addColorGradient and removeColorGradient to udpate this list
  76502. * @returns the list of color gradients
  76503. */
  76504. getColorGradients(): Nullable<Array<ColorGradient>>;
  76505. /**
  76506. * Gets the current list of size gradients.
  76507. * You must use addSizeGradient and removeSizeGradient to udpate this list
  76508. * @returns the list of size gradients
  76509. */
  76510. getSizeGradients(): Nullable<Array<FactorGradient>>;
  76511. /**
  76512. * Gets the current list of angular speed gradients.
  76513. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  76514. * @returns the list of angular speed gradients
  76515. */
  76516. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  76517. /**
  76518. * Adds a new angular speed gradient
  76519. * @param gradient defines the gradient to use (between 0 and 1)
  76520. * @param factor defines the angular speed to affect to the specified gradient
  76521. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76522. * @returns the current particle system
  76523. */
  76524. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76525. /**
  76526. * Remove a specific angular speed gradient
  76527. * @param gradient defines the gradient to remove
  76528. * @returns the current particle system
  76529. */
  76530. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  76531. /**
  76532. * Gets the current list of velocity gradients.
  76533. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  76534. * @returns the list of velocity gradients
  76535. */
  76536. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  76537. /**
  76538. * Adds a new velocity gradient
  76539. * @param gradient defines the gradient to use (between 0 and 1)
  76540. * @param factor defines the velocity to affect to the specified gradient
  76541. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76542. * @returns the current particle system
  76543. */
  76544. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76545. /**
  76546. * Remove a specific velocity gradient
  76547. * @param gradient defines the gradient to remove
  76548. * @returns the current particle system
  76549. */
  76550. removeVelocityGradient(gradient: number): IParticleSystem;
  76551. /**
  76552. * Gets the current list of limit velocity gradients.
  76553. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  76554. * @returns the list of limit velocity gradients
  76555. */
  76556. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  76557. /**
  76558. * Adds a new limit velocity gradient
  76559. * @param gradient defines the gradient to use (between 0 and 1)
  76560. * @param factor defines the limit velocity to affect to the specified gradient
  76561. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76562. * @returns the current particle system
  76563. */
  76564. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76565. /**
  76566. * Remove a specific limit velocity gradient
  76567. * @param gradient defines the gradient to remove
  76568. * @returns the current particle system
  76569. */
  76570. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  76571. /**
  76572. * Adds a new drag gradient
  76573. * @param gradient defines the gradient to use (between 0 and 1)
  76574. * @param factor defines the drag to affect to the specified gradient
  76575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76576. * @returns the current particle system
  76577. */
  76578. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76579. /**
  76580. * Remove a specific drag gradient
  76581. * @param gradient defines the gradient to remove
  76582. * @returns the current particle system
  76583. */
  76584. removeDragGradient(gradient: number): IParticleSystem;
  76585. /**
  76586. * Gets the current list of drag gradients.
  76587. * You must use addDragGradient and removeDragGradient to udpate this list
  76588. * @returns the list of drag gradients
  76589. */
  76590. getDragGradients(): Nullable<Array<FactorGradient>>;
  76591. /**
  76592. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  76593. * @param gradient defines the gradient to use (between 0 and 1)
  76594. * @param factor defines the emit rate to affect to the specified gradient
  76595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76596. * @returns the current particle system
  76597. */
  76598. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76599. /**
  76600. * Remove a specific emit rate gradient
  76601. * @param gradient defines the gradient to remove
  76602. * @returns the current particle system
  76603. */
  76604. removeEmitRateGradient(gradient: number): IParticleSystem;
  76605. /**
  76606. * Gets the current list of emit rate gradients.
  76607. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  76608. * @returns the list of emit rate gradients
  76609. */
  76610. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  76611. /**
  76612. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  76613. * @param gradient defines the gradient to use (between 0 and 1)
  76614. * @param factor defines the start size to affect to the specified gradient
  76615. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76616. * @returns the current particle system
  76617. */
  76618. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76619. /**
  76620. * Remove a specific start size gradient
  76621. * @param gradient defines the gradient to remove
  76622. * @returns the current particle system
  76623. */
  76624. removeStartSizeGradient(gradient: number): IParticleSystem;
  76625. /**
  76626. * Gets the current list of start size gradients.
  76627. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  76628. * @returns the list of start size gradients
  76629. */
  76630. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  76631. /**
  76632. * Adds a new life time gradient
  76633. * @param gradient defines the gradient to use (between 0 and 1)
  76634. * @param factor defines the life time factor to affect to the specified gradient
  76635. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76636. * @returns the current particle system
  76637. */
  76638. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76639. /**
  76640. * Remove a specific life time gradient
  76641. * @param gradient defines the gradient to remove
  76642. * @returns the current particle system
  76643. */
  76644. removeLifeTimeGradient(gradient: number): IParticleSystem;
  76645. /**
  76646. * Gets the current list of life time gradients.
  76647. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  76648. * @returns the list of life time gradients
  76649. */
  76650. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  76651. /**
  76652. * Gets the current list of color gradients.
  76653. * You must use addColorGradient and removeColorGradient to udpate this list
  76654. * @returns the list of color gradients
  76655. */
  76656. getColorGradients(): Nullable<Array<ColorGradient>>;
  76657. /**
  76658. * Adds a new ramp gradient used to remap particle colors
  76659. * @param gradient defines the gradient to use (between 0 and 1)
  76660. * @param color defines the color to affect to the specified gradient
  76661. * @returns the current particle system
  76662. */
  76663. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  76664. /**
  76665. * Gets the current list of ramp gradients.
  76666. * You must use addRampGradient and removeRampGradient to udpate this list
  76667. * @returns the list of ramp gradients
  76668. */
  76669. getRampGradients(): Nullable<Array<Color3Gradient>>;
  76670. /** Gets or sets a boolean indicating that ramp gradients must be used
  76671. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  76672. */
  76673. useRampGradients: boolean;
  76674. /**
  76675. * Adds a new color remap gradient
  76676. * @param gradient defines the gradient to use (between 0 and 1)
  76677. * @param min defines the color remap minimal range
  76678. * @param max defines the color remap maximal range
  76679. * @returns the current particle system
  76680. */
  76681. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76682. /**
  76683. * Gets the current list of color remap gradients.
  76684. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  76685. * @returns the list of color remap gradients
  76686. */
  76687. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  76688. /**
  76689. * Adds a new alpha remap gradient
  76690. * @param gradient defines the gradient to use (between 0 and 1)
  76691. * @param min defines the alpha remap minimal range
  76692. * @param max defines the alpha remap maximal range
  76693. * @returns the current particle system
  76694. */
  76695. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76696. /**
  76697. * Gets the current list of alpha remap gradients.
  76698. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  76699. * @returns the list of alpha remap gradients
  76700. */
  76701. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  76702. /**
  76703. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  76704. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76705. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76706. * @returns the emitter
  76707. */
  76708. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  76709. /**
  76710. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  76711. * @param radius The radius of the hemisphere to emit from
  76712. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76713. * @returns the emitter
  76714. */
  76715. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  76716. /**
  76717. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  76718. * @param radius The radius of the sphere to emit from
  76719. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76720. * @returns the emitter
  76721. */
  76722. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  76723. /**
  76724. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  76725. * @param radius The radius of the sphere to emit from
  76726. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  76727. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  76728. * @returns the emitter
  76729. */
  76730. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76731. /**
  76732. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  76733. * @param radius The radius of the emission cylinder
  76734. * @param height The height of the emission cylinder
  76735. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  76736. * @param directionRandomizer How much to randomize the particle direction [0-1]
  76737. * @returns the emitter
  76738. */
  76739. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  76740. /**
  76741. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  76742. * @param radius The radius of the cylinder to emit from
  76743. * @param height The height of the emission cylinder
  76744. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76745. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  76746. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  76747. * @returns the emitter
  76748. */
  76749. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76750. /**
  76751. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  76752. * @param radius The radius of the cone to emit from
  76753. * @param angle The base angle of the cone
  76754. * @returns the emitter
  76755. */
  76756. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  76757. /**
  76758. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  76759. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76760. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76761. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76762. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76763. * @returns the emitter
  76764. */
  76765. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  76766. /**
  76767. * Get hosting scene
  76768. * @returns the scene
  76769. */
  76770. getScene(): Scene;
  76771. }
  76772. }
  76773. declare module BABYLON {
  76774. /**
  76775. * Creates an instance based on a source mesh.
  76776. */
  76777. export class InstancedMesh extends AbstractMesh {
  76778. private _sourceMesh;
  76779. private _currentLOD;
  76780. /** @hidden */
  76781. _indexInSourceMeshInstanceArray: number;
  76782. constructor(name: string, source: Mesh);
  76783. /**
  76784. * Returns the string "InstancedMesh".
  76785. */
  76786. getClassName(): string;
  76787. /** Gets the list of lights affecting that mesh */
  76788. readonly lightSources: Light[];
  76789. _resyncLightSources(): void;
  76790. _resyncLighSource(light: Light): void;
  76791. _removeLightSource(light: Light): void;
  76792. /**
  76793. * If the source mesh receives shadows
  76794. */
  76795. readonly receiveShadows: boolean;
  76796. /**
  76797. * The material of the source mesh
  76798. */
  76799. readonly material: Nullable<Material>;
  76800. /**
  76801. * Visibility of the source mesh
  76802. */
  76803. readonly visibility: number;
  76804. /**
  76805. * Skeleton of the source mesh
  76806. */
  76807. readonly skeleton: Nullable<Skeleton>;
  76808. /**
  76809. * Rendering ground id of the source mesh
  76810. */
  76811. renderingGroupId: number;
  76812. /**
  76813. * Returns the total number of vertices (integer).
  76814. */
  76815. getTotalVertices(): number;
  76816. /**
  76817. * Returns a positive integer : the total number of indices in this mesh geometry.
  76818. * @returns the numner of indices or zero if the mesh has no geometry.
  76819. */
  76820. getTotalIndices(): number;
  76821. /**
  76822. * The source mesh of the instance
  76823. */
  76824. readonly sourceMesh: Mesh;
  76825. /**
  76826. * Is this node ready to be used/rendered
  76827. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76828. * @return {boolean} is it ready
  76829. */
  76830. isReady(completeCheck?: boolean): boolean;
  76831. /**
  76832. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76833. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  76834. * @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.
  76835. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  76836. */
  76837. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  76838. /**
  76839. * Sets the vertex data of the mesh geometry for the requested `kind`.
  76840. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  76841. * The `data` are either a numeric array either a Float32Array.
  76842. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  76843. * 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).
  76844. * Note that a new underlying VertexBuffer object is created each call.
  76845. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  76846. *
  76847. * Possible `kind` values :
  76848. * - VertexBuffer.PositionKind
  76849. * - VertexBuffer.UVKind
  76850. * - VertexBuffer.UV2Kind
  76851. * - VertexBuffer.UV3Kind
  76852. * - VertexBuffer.UV4Kind
  76853. * - VertexBuffer.UV5Kind
  76854. * - VertexBuffer.UV6Kind
  76855. * - VertexBuffer.ColorKind
  76856. * - VertexBuffer.MatricesIndicesKind
  76857. * - VertexBuffer.MatricesIndicesExtraKind
  76858. * - VertexBuffer.MatricesWeightsKind
  76859. * - VertexBuffer.MatricesWeightsExtraKind
  76860. *
  76861. * Returns the Mesh.
  76862. */
  76863. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76864. /**
  76865. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  76866. * If the mesh has no geometry, it is simply returned as it is.
  76867. * The `data` are either a numeric array either a Float32Array.
  76868. * No new underlying VertexBuffer object is created.
  76869. * 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.
  76870. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  76871. *
  76872. * Possible `kind` values :
  76873. * - VertexBuffer.PositionKind
  76874. * - VertexBuffer.UVKind
  76875. * - VertexBuffer.UV2Kind
  76876. * - VertexBuffer.UV3Kind
  76877. * - VertexBuffer.UV4Kind
  76878. * - VertexBuffer.UV5Kind
  76879. * - VertexBuffer.UV6Kind
  76880. * - VertexBuffer.ColorKind
  76881. * - VertexBuffer.MatricesIndicesKind
  76882. * - VertexBuffer.MatricesIndicesExtraKind
  76883. * - VertexBuffer.MatricesWeightsKind
  76884. * - VertexBuffer.MatricesWeightsExtraKind
  76885. *
  76886. * Returns the Mesh.
  76887. */
  76888. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76889. /**
  76890. * Sets the mesh indices.
  76891. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  76892. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  76893. * This method creates a new index buffer each call.
  76894. * Returns the Mesh.
  76895. */
  76896. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  76897. /**
  76898. * Boolean : True if the mesh owns the requested kind of data.
  76899. */
  76900. isVerticesDataPresent(kind: string): boolean;
  76901. /**
  76902. * Returns an array of indices (IndicesArray).
  76903. */
  76904. getIndices(): Nullable<IndicesArray>;
  76905. readonly _positions: Nullable<Vector3[]>;
  76906. /**
  76907. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76908. * This means the mesh underlying bounding box and sphere are recomputed.
  76909. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76910. * @returns the current mesh
  76911. */
  76912. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  76913. /** @hidden */
  76914. _preActivate(): InstancedMesh;
  76915. /** @hidden */
  76916. _activate(renderId: number, intermediateRendering: boolean): boolean;
  76917. /** @hidden */
  76918. _postActivate(): void;
  76919. getWorldMatrix(): Matrix;
  76920. readonly isAnInstance: boolean;
  76921. /**
  76922. * Returns the current associated LOD AbstractMesh.
  76923. */
  76924. getLOD(camera: Camera): AbstractMesh;
  76925. /** @hidden */
  76926. _syncSubMeshes(): InstancedMesh;
  76927. /** @hidden */
  76928. _generatePointsArray(): boolean;
  76929. /**
  76930. * Creates a new InstancedMesh from the current mesh.
  76931. * - name (string) : the cloned mesh name
  76932. * - newParent (optional Node) : the optional Node to parent the clone to.
  76933. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76934. *
  76935. * Returns the clone.
  76936. */
  76937. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76938. /**
  76939. * Disposes the InstancedMesh.
  76940. * Returns nothing.
  76941. */
  76942. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76943. }
  76944. }
  76945. declare module BABYLON {
  76946. /**
  76947. * Defines the options associated with the creation of a shader material.
  76948. */
  76949. export interface IShaderMaterialOptions {
  76950. /**
  76951. * Does the material work in alpha blend mode
  76952. */
  76953. needAlphaBlending: boolean;
  76954. /**
  76955. * Does the material work in alpha test mode
  76956. */
  76957. needAlphaTesting: boolean;
  76958. /**
  76959. * The list of attribute names used in the shader
  76960. */
  76961. attributes: string[];
  76962. /**
  76963. * The list of unifrom names used in the shader
  76964. */
  76965. uniforms: string[];
  76966. /**
  76967. * The list of UBO names used in the shader
  76968. */
  76969. uniformBuffers: string[];
  76970. /**
  76971. * The list of sampler names used in the shader
  76972. */
  76973. samplers: string[];
  76974. /**
  76975. * The list of defines used in the shader
  76976. */
  76977. defines: string[];
  76978. }
  76979. /**
  76980. * 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.
  76981. *
  76982. * This returned material effects how the mesh will look based on the code in the shaders.
  76983. *
  76984. * @see http://doc.babylonjs.com/how_to/shader_material
  76985. */
  76986. export class ShaderMaterial extends Material {
  76987. private _shaderPath;
  76988. private _options;
  76989. private _textures;
  76990. private _textureArrays;
  76991. private _floats;
  76992. private _ints;
  76993. private _floatsArrays;
  76994. private _colors3;
  76995. private _colors3Arrays;
  76996. private _colors4;
  76997. private _vectors2;
  76998. private _vectors3;
  76999. private _vectors4;
  77000. private _matrices;
  77001. private _matrices3x3;
  77002. private _matrices2x2;
  77003. private _vectors2Arrays;
  77004. private _vectors3Arrays;
  77005. private _cachedWorldViewMatrix;
  77006. private _renderId;
  77007. /**
  77008. * Instantiate a new shader material.
  77009. * 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.
  77010. * This returned material effects how the mesh will look based on the code in the shaders.
  77011. * @see http://doc.babylonjs.com/how_to/shader_material
  77012. * @param name Define the name of the material in the scene
  77013. * @param scene Define the scene the material belongs to
  77014. * @param shaderPath Defines the route to the shader code in one of three ways:
  77015. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  77016. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  77017. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  77018. * @param options Define the options used to create the shader
  77019. */
  77020. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  77021. /**
  77022. * Gets the options used to compile the shader.
  77023. * They can be modified to trigger a new compilation
  77024. */
  77025. readonly options: IShaderMaterialOptions;
  77026. /**
  77027. * Gets the current class name of the material e.g. "ShaderMaterial"
  77028. * Mainly use in serialization.
  77029. * @returns the class name
  77030. */
  77031. getClassName(): string;
  77032. /**
  77033. * Specifies if the material will require alpha blending
  77034. * @returns a boolean specifying if alpha blending is needed
  77035. */
  77036. needAlphaBlending(): boolean;
  77037. /**
  77038. * Specifies if this material should be rendered in alpha test mode
  77039. * @returns a boolean specifying if an alpha test is needed.
  77040. */
  77041. needAlphaTesting(): boolean;
  77042. private _checkUniform;
  77043. /**
  77044. * Set a texture in the shader.
  77045. * @param name Define the name of the uniform samplers as defined in the shader
  77046. * @param texture Define the texture to bind to this sampler
  77047. * @return the material itself allowing "fluent" like uniform updates
  77048. */
  77049. setTexture(name: string, texture: Texture): ShaderMaterial;
  77050. /**
  77051. * Set a texture array in the shader.
  77052. * @param name Define the name of the uniform sampler array as defined in the shader
  77053. * @param textures Define the list of textures to bind to this sampler
  77054. * @return the material itself allowing "fluent" like uniform updates
  77055. */
  77056. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  77057. /**
  77058. * Set a float in the shader.
  77059. * @param name Define the name of the uniform as defined in the shader
  77060. * @param value Define the value to give to the uniform
  77061. * @return the material itself allowing "fluent" like uniform updates
  77062. */
  77063. setFloat(name: string, value: number): ShaderMaterial;
  77064. /**
  77065. * Set a int in the shader.
  77066. * @param name Define the name of the uniform as defined in the shader
  77067. * @param value Define the value to give to the uniform
  77068. * @return the material itself allowing "fluent" like uniform updates
  77069. */
  77070. setInt(name: string, value: number): ShaderMaterial;
  77071. /**
  77072. * Set an array of floats in the shader.
  77073. * @param name Define the name of the uniform as defined in the shader
  77074. * @param value Define the value to give to the uniform
  77075. * @return the material itself allowing "fluent" like uniform updates
  77076. */
  77077. setFloats(name: string, value: number[]): ShaderMaterial;
  77078. /**
  77079. * Set a vec3 in the shader from a Color3.
  77080. * @param name Define the name of the uniform as defined in the shader
  77081. * @param value Define the value to give to the uniform
  77082. * @return the material itself allowing "fluent" like uniform updates
  77083. */
  77084. setColor3(name: string, value: Color3): ShaderMaterial;
  77085. /**
  77086. * Set a vec3 array in the shader from a Color3 array.
  77087. * @param name Define the name of the uniform as defined in the shader
  77088. * @param value Define the value to give to the uniform
  77089. * @return the material itself allowing "fluent" like uniform updates
  77090. */
  77091. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  77092. /**
  77093. * Set a vec4 in the shader from a Color4.
  77094. * @param name Define the name of the uniform as defined in the shader
  77095. * @param value Define the value to give to the uniform
  77096. * @return the material itself allowing "fluent" like uniform updates
  77097. */
  77098. setColor4(name: string, value: Color4): ShaderMaterial;
  77099. /**
  77100. * Set a vec2 in the shader from a Vector2.
  77101. * @param name Define the name of the uniform as defined in the shader
  77102. * @param value Define the value to give to the uniform
  77103. * @return the material itself allowing "fluent" like uniform updates
  77104. */
  77105. setVector2(name: string, value: Vector2): ShaderMaterial;
  77106. /**
  77107. * Set a vec3 in the shader from a Vector3.
  77108. * @param name Define the name of the uniform as defined in the shader
  77109. * @param value Define the value to give to the uniform
  77110. * @return the material itself allowing "fluent" like uniform updates
  77111. */
  77112. setVector3(name: string, value: Vector3): ShaderMaterial;
  77113. /**
  77114. * Set a vec4 in the shader from a Vector4.
  77115. * @param name Define the name of the uniform as defined in the shader
  77116. * @param value Define the value to give to the uniform
  77117. * @return the material itself allowing "fluent" like uniform updates
  77118. */
  77119. setVector4(name: string, value: Vector4): ShaderMaterial;
  77120. /**
  77121. * Set a mat4 in the shader from a Matrix.
  77122. * @param name Define the name of the uniform as defined in the shader
  77123. * @param value Define the value to give to the uniform
  77124. * @return the material itself allowing "fluent" like uniform updates
  77125. */
  77126. setMatrix(name: string, value: Matrix): ShaderMaterial;
  77127. /**
  77128. * Set a mat3 in the shader from a Float32Array.
  77129. * @param name Define the name of the uniform as defined in the shader
  77130. * @param value Define the value to give to the uniform
  77131. * @return the material itself allowing "fluent" like uniform updates
  77132. */
  77133. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  77134. /**
  77135. * Set a mat2 in the shader from a Float32Array.
  77136. * @param name Define the name of the uniform as defined in the shader
  77137. * @param value Define the value to give to the uniform
  77138. * @return the material itself allowing "fluent" like uniform updates
  77139. */
  77140. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  77141. /**
  77142. * Set a vec2 array in the shader from a number array.
  77143. * @param name Define the name of the uniform as defined in the shader
  77144. * @param value Define the value to give to the uniform
  77145. * @return the material itself allowing "fluent" like uniform updates
  77146. */
  77147. setArray2(name: string, value: number[]): ShaderMaterial;
  77148. /**
  77149. * Set a vec3 array in the shader from a number array.
  77150. * @param name Define the name of the uniform as defined in the shader
  77151. * @param value Define the value to give to the uniform
  77152. * @return the material itself allowing "fluent" like uniform updates
  77153. */
  77154. setArray3(name: string, value: number[]): ShaderMaterial;
  77155. private _checkCache;
  77156. /**
  77157. * Specifies that the submesh is ready to be used
  77158. * @param mesh defines the mesh to check
  77159. * @param subMesh defines which submesh to check
  77160. * @param useInstances specifies that instances should be used
  77161. * @returns a boolean indicating that the submesh is ready or not
  77162. */
  77163. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  77164. /**
  77165. * Checks if the material is ready to render the requested mesh
  77166. * @param mesh Define the mesh to render
  77167. * @param useInstances Define whether or not the material is used with instances
  77168. * @returns true if ready, otherwise false
  77169. */
  77170. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  77171. /**
  77172. * Binds the world matrix to the material
  77173. * @param world defines the world transformation matrix
  77174. */
  77175. bindOnlyWorldMatrix(world: Matrix): void;
  77176. /**
  77177. * Binds the material to the mesh
  77178. * @param world defines the world transformation matrix
  77179. * @param mesh defines the mesh to bind the material to
  77180. */
  77181. bind(world: Matrix, mesh?: Mesh): void;
  77182. /**
  77183. * Gets the active textures from the material
  77184. * @returns an array of textures
  77185. */
  77186. getActiveTextures(): BaseTexture[];
  77187. /**
  77188. * Specifies if the material uses a texture
  77189. * @param texture defines the texture to check against the material
  77190. * @returns a boolean specifying if the material uses the texture
  77191. */
  77192. hasTexture(texture: BaseTexture): boolean;
  77193. /**
  77194. * Makes a duplicate of the material, and gives it a new name
  77195. * @param name defines the new name for the duplicated material
  77196. * @returns the cloned material
  77197. */
  77198. clone(name: string): ShaderMaterial;
  77199. /**
  77200. * Disposes the material
  77201. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  77202. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  77203. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  77204. */
  77205. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  77206. /**
  77207. * Serializes this material in a JSON representation
  77208. * @returns the serialized material object
  77209. */
  77210. serialize(): any;
  77211. /**
  77212. * Creates a shader material from parsed shader material data
  77213. * @param source defines the JSON represnetation of the material
  77214. * @param scene defines the hosting scene
  77215. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  77216. * @returns a new material
  77217. */
  77218. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  77219. }
  77220. }
  77221. declare module BABYLON {
  77222. /** @hidden */
  77223. export var colorPixelShader: {
  77224. name: string;
  77225. shader: string;
  77226. };
  77227. }
  77228. declare module BABYLON {
  77229. /** @hidden */
  77230. export var colorVertexShader: {
  77231. name: string;
  77232. shader: string;
  77233. };
  77234. }
  77235. declare module BABYLON {
  77236. /**
  77237. * Line mesh
  77238. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  77239. */
  77240. export class LinesMesh extends Mesh {
  77241. /**
  77242. * If vertex color should be applied to the mesh
  77243. */
  77244. useVertexColor?: boolean | undefined;
  77245. /**
  77246. * If vertex alpha should be applied to the mesh
  77247. */
  77248. useVertexAlpha?: boolean | undefined;
  77249. /**
  77250. * Color of the line (Default: White)
  77251. */
  77252. color: Color3;
  77253. /**
  77254. * Alpha of the line (Default: 1)
  77255. */
  77256. alpha: number;
  77257. /**
  77258. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77259. * This margin is expressed in world space coordinates, so its value may vary.
  77260. * Default value is 0.1
  77261. */
  77262. intersectionThreshold: number;
  77263. private _colorShader;
  77264. /**
  77265. * Creates a new LinesMesh
  77266. * @param name defines the name
  77267. * @param scene defines the hosting scene
  77268. * @param parent defines the parent mesh if any
  77269. * @param source defines the optional source LinesMesh used to clone data from
  77270. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77271. * When false, achieved by calling a clone(), also passing False.
  77272. * This will make creation of children, recursive.
  77273. * @param useVertexColor defines if this LinesMesh supports vertex color
  77274. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  77275. */
  77276. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  77277. /**
  77278. * If vertex color should be applied to the mesh
  77279. */
  77280. useVertexColor?: boolean | undefined,
  77281. /**
  77282. * If vertex alpha should be applied to the mesh
  77283. */
  77284. useVertexAlpha?: boolean | undefined);
  77285. private _addClipPlaneDefine;
  77286. private _removeClipPlaneDefine;
  77287. isReady(): boolean;
  77288. /**
  77289. * Returns the string "LineMesh"
  77290. */
  77291. getClassName(): string;
  77292. /**
  77293. * @hidden
  77294. */
  77295. /**
  77296. * @hidden
  77297. */
  77298. material: Material;
  77299. /**
  77300. * @hidden
  77301. */
  77302. readonly checkCollisions: boolean;
  77303. /** @hidden */
  77304. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  77305. /** @hidden */
  77306. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  77307. /**
  77308. * Disposes of the line mesh
  77309. * @param doNotRecurse If children should be disposed
  77310. */
  77311. dispose(doNotRecurse?: boolean): void;
  77312. /**
  77313. * Returns a new LineMesh object cloned from the current one.
  77314. */
  77315. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  77316. /**
  77317. * Creates a new InstancedLinesMesh object from the mesh model.
  77318. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77319. * @param name defines the name of the new instance
  77320. * @returns a new InstancedLinesMesh
  77321. */
  77322. createInstance(name: string): InstancedLinesMesh;
  77323. }
  77324. /**
  77325. * Creates an instance based on a source LinesMesh
  77326. */
  77327. export class InstancedLinesMesh extends InstancedMesh {
  77328. /**
  77329. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77330. * This margin is expressed in world space coordinates, so its value may vary.
  77331. * Initilized with the intersectionThreshold value of the source LinesMesh
  77332. */
  77333. intersectionThreshold: number;
  77334. constructor(name: string, source: LinesMesh);
  77335. /**
  77336. * Returns the string "InstancedLinesMesh".
  77337. */
  77338. getClassName(): string;
  77339. }
  77340. }
  77341. declare module BABYLON {
  77342. /** @hidden */
  77343. export var linePixelShader: {
  77344. name: string;
  77345. shader: string;
  77346. };
  77347. }
  77348. declare module BABYLON {
  77349. /** @hidden */
  77350. export var lineVertexShader: {
  77351. name: string;
  77352. shader: string;
  77353. };
  77354. }
  77355. declare module BABYLON {
  77356. interface AbstractMesh {
  77357. /**
  77358. * Gets the edgesRenderer associated with the mesh
  77359. */
  77360. edgesRenderer: Nullable<EdgesRenderer>;
  77361. }
  77362. interface LinesMesh {
  77363. /**
  77364. * Enables the edge rendering mode on the mesh.
  77365. * This mode makes the mesh edges visible
  77366. * @param epsilon defines the maximal distance between two angles to detect a face
  77367. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77368. * @returns the currentAbstractMesh
  77369. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77370. */
  77371. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77372. }
  77373. interface InstancedLinesMesh {
  77374. /**
  77375. * Enables the edge rendering mode on the mesh.
  77376. * This mode makes the mesh edges visible
  77377. * @param epsilon defines the maximal distance between two angles to detect a face
  77378. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77379. * @returns the current InstancedLinesMesh
  77380. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77381. */
  77382. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  77383. }
  77384. /**
  77385. * Defines the minimum contract an Edges renderer should follow.
  77386. */
  77387. export interface IEdgesRenderer extends IDisposable {
  77388. /**
  77389. * Gets or sets a boolean indicating if the edgesRenderer is active
  77390. */
  77391. isEnabled: boolean;
  77392. /**
  77393. * Renders the edges of the attached mesh,
  77394. */
  77395. render(): void;
  77396. /**
  77397. * Checks wether or not the edges renderer is ready to render.
  77398. * @return true if ready, otherwise false.
  77399. */
  77400. isReady(): boolean;
  77401. }
  77402. /**
  77403. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  77404. */
  77405. export class EdgesRenderer implements IEdgesRenderer {
  77406. /**
  77407. * Define the size of the edges with an orthographic camera
  77408. */
  77409. edgesWidthScalerForOrthographic: number;
  77410. /**
  77411. * Define the size of the edges with a perspective camera
  77412. */
  77413. edgesWidthScalerForPerspective: number;
  77414. protected _source: AbstractMesh;
  77415. protected _linesPositions: number[];
  77416. protected _linesNormals: number[];
  77417. protected _linesIndices: number[];
  77418. protected _epsilon: number;
  77419. protected _indicesCount: number;
  77420. protected _lineShader: ShaderMaterial;
  77421. protected _ib: DataBuffer;
  77422. protected _buffers: {
  77423. [key: string]: Nullable<VertexBuffer>;
  77424. };
  77425. protected _checkVerticesInsteadOfIndices: boolean;
  77426. private _meshRebuildObserver;
  77427. private _meshDisposeObserver;
  77428. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  77429. isEnabled: boolean;
  77430. /**
  77431. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  77432. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  77433. * @param source Mesh used to create edges
  77434. * @param epsilon sum of angles in adjacency to check for edge
  77435. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  77436. * @param generateEdgesLines - should generate Lines or only prepare resources.
  77437. */
  77438. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  77439. protected _prepareRessources(): void;
  77440. /** @hidden */
  77441. _rebuild(): void;
  77442. /**
  77443. * Releases the required resources for the edges renderer
  77444. */
  77445. dispose(): void;
  77446. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  77447. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  77448. /**
  77449. * Checks if the pair of p0 and p1 is en edge
  77450. * @param faceIndex
  77451. * @param edge
  77452. * @param faceNormals
  77453. * @param p0
  77454. * @param p1
  77455. * @private
  77456. */
  77457. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  77458. /**
  77459. * push line into the position, normal and index buffer
  77460. * @protected
  77461. */
  77462. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  77463. /**
  77464. * Generates lines edges from adjacencjes
  77465. * @private
  77466. */
  77467. _generateEdgesLines(): void;
  77468. /**
  77469. * Checks wether or not the edges renderer is ready to render.
  77470. * @return true if ready, otherwise false.
  77471. */
  77472. isReady(): boolean;
  77473. /**
  77474. * Renders the edges of the attached mesh,
  77475. */
  77476. render(): void;
  77477. }
  77478. /**
  77479. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  77480. */
  77481. export class LineEdgesRenderer extends EdgesRenderer {
  77482. /**
  77483. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  77484. * @param source LineMesh used to generate edges
  77485. * @param epsilon not important (specified angle for edge detection)
  77486. * @param checkVerticesInsteadOfIndices not important for LineMesh
  77487. */
  77488. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  77489. /**
  77490. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  77491. */
  77492. _generateEdgesLines(): void;
  77493. }
  77494. }
  77495. declare module BABYLON {
  77496. /**
  77497. * This represents the object necessary to create a rendering group.
  77498. * This is exclusively used and created by the rendering manager.
  77499. * To modify the behavior, you use the available helpers in your scene or meshes.
  77500. * @hidden
  77501. */
  77502. export class RenderingGroup {
  77503. index: number;
  77504. private _scene;
  77505. private _opaqueSubMeshes;
  77506. private _transparentSubMeshes;
  77507. private _alphaTestSubMeshes;
  77508. private _depthOnlySubMeshes;
  77509. private _particleSystems;
  77510. private _spriteManagers;
  77511. private _opaqueSortCompareFn;
  77512. private _alphaTestSortCompareFn;
  77513. private _transparentSortCompareFn;
  77514. private _renderOpaque;
  77515. private _renderAlphaTest;
  77516. private _renderTransparent;
  77517. /** @hidden */
  77518. _edgesRenderers: SmartArray<IEdgesRenderer>;
  77519. onBeforeTransparentRendering: () => void;
  77520. /**
  77521. * Set the opaque sort comparison function.
  77522. * If null the sub meshes will be render in the order they were created
  77523. */
  77524. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77525. /**
  77526. * Set the alpha test sort comparison function.
  77527. * If null the sub meshes will be render in the order they were created
  77528. */
  77529. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77530. /**
  77531. * Set the transparent sort comparison function.
  77532. * If null the sub meshes will be render in the order they were created
  77533. */
  77534. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77535. /**
  77536. * Creates a new rendering group.
  77537. * @param index The rendering group index
  77538. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  77539. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  77540. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  77541. */
  77542. 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>);
  77543. /**
  77544. * Render all the sub meshes contained in the group.
  77545. * @param customRenderFunction Used to override the default render behaviour of the group.
  77546. * @returns true if rendered some submeshes.
  77547. */
  77548. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  77549. /**
  77550. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  77551. * @param subMeshes The submeshes to render
  77552. */
  77553. private renderOpaqueSorted;
  77554. /**
  77555. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  77556. * @param subMeshes The submeshes to render
  77557. */
  77558. private renderAlphaTestSorted;
  77559. /**
  77560. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  77561. * @param subMeshes The submeshes to render
  77562. */
  77563. private renderTransparentSorted;
  77564. /**
  77565. * Renders the submeshes in a specified order.
  77566. * @param subMeshes The submeshes to sort before render
  77567. * @param sortCompareFn The comparison function use to sort
  77568. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  77569. * @param transparent Specifies to activate blending if true
  77570. */
  77571. private static renderSorted;
  77572. /**
  77573. * Renders the submeshes in the order they were dispatched (no sort applied).
  77574. * @param subMeshes The submeshes to render
  77575. */
  77576. private static renderUnsorted;
  77577. /**
  77578. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77579. * are rendered back to front if in the same alpha index.
  77580. *
  77581. * @param a The first submesh
  77582. * @param b The second submesh
  77583. * @returns The result of the comparison
  77584. */
  77585. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  77586. /**
  77587. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77588. * are rendered back to front.
  77589. *
  77590. * @param a The first submesh
  77591. * @param b The second submesh
  77592. * @returns The result of the comparison
  77593. */
  77594. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  77595. /**
  77596. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77597. * are rendered front to back (prevent overdraw).
  77598. *
  77599. * @param a The first submesh
  77600. * @param b The second submesh
  77601. * @returns The result of the comparison
  77602. */
  77603. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  77604. /**
  77605. * Resets the different lists of submeshes to prepare a new frame.
  77606. */
  77607. prepare(): void;
  77608. dispose(): void;
  77609. /**
  77610. * Inserts the submesh in its correct queue depending on its material.
  77611. * @param subMesh The submesh to dispatch
  77612. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77613. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77614. */
  77615. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77616. dispatchSprites(spriteManager: ISpriteManager): void;
  77617. dispatchParticles(particleSystem: IParticleSystem): void;
  77618. private _renderParticles;
  77619. private _renderSprites;
  77620. }
  77621. }
  77622. declare module BABYLON {
  77623. /**
  77624. * Interface describing the different options available in the rendering manager
  77625. * regarding Auto Clear between groups.
  77626. */
  77627. export interface IRenderingManagerAutoClearSetup {
  77628. /**
  77629. * Defines whether or not autoclear is enable.
  77630. */
  77631. autoClear: boolean;
  77632. /**
  77633. * Defines whether or not to autoclear the depth buffer.
  77634. */
  77635. depth: boolean;
  77636. /**
  77637. * Defines whether or not to autoclear the stencil buffer.
  77638. */
  77639. stencil: boolean;
  77640. }
  77641. /**
  77642. * This class is used by the onRenderingGroupObservable
  77643. */
  77644. export class RenderingGroupInfo {
  77645. /**
  77646. * The Scene that being rendered
  77647. */
  77648. scene: Scene;
  77649. /**
  77650. * The camera currently used for the rendering pass
  77651. */
  77652. camera: Nullable<Camera>;
  77653. /**
  77654. * The ID of the renderingGroup being processed
  77655. */
  77656. renderingGroupId: number;
  77657. }
  77658. /**
  77659. * This is the manager responsible of all the rendering for meshes sprites and particles.
  77660. * It is enable to manage the different groups as well as the different necessary sort functions.
  77661. * This should not be used directly aside of the few static configurations
  77662. */
  77663. export class RenderingManager {
  77664. /**
  77665. * The max id used for rendering groups (not included)
  77666. */
  77667. static MAX_RENDERINGGROUPS: number;
  77668. /**
  77669. * The min id used for rendering groups (included)
  77670. */
  77671. static MIN_RENDERINGGROUPS: number;
  77672. /**
  77673. * Used to globally prevent autoclearing scenes.
  77674. */
  77675. static AUTOCLEAR: boolean;
  77676. /**
  77677. * @hidden
  77678. */
  77679. _useSceneAutoClearSetup: boolean;
  77680. private _scene;
  77681. private _renderingGroups;
  77682. private _depthStencilBufferAlreadyCleaned;
  77683. private _autoClearDepthStencil;
  77684. private _customOpaqueSortCompareFn;
  77685. private _customAlphaTestSortCompareFn;
  77686. private _customTransparentSortCompareFn;
  77687. private _renderingGroupInfo;
  77688. /**
  77689. * Instantiates a new rendering group for a particular scene
  77690. * @param scene Defines the scene the groups belongs to
  77691. */
  77692. constructor(scene: Scene);
  77693. private _clearDepthStencilBuffer;
  77694. /**
  77695. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  77696. * @hidden
  77697. */
  77698. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  77699. /**
  77700. * Resets the different information of the group to prepare a new frame
  77701. * @hidden
  77702. */
  77703. reset(): void;
  77704. /**
  77705. * Dispose and release the group and its associated resources.
  77706. * @hidden
  77707. */
  77708. dispose(): void;
  77709. /**
  77710. * Clear the info related to rendering groups preventing retention points during dispose.
  77711. */
  77712. freeRenderingGroups(): void;
  77713. private _prepareRenderingGroup;
  77714. /**
  77715. * Add a sprite manager to the rendering manager in order to render it this frame.
  77716. * @param spriteManager Define the sprite manager to render
  77717. */
  77718. dispatchSprites(spriteManager: ISpriteManager): void;
  77719. /**
  77720. * Add a particle system to the rendering manager in order to render it this frame.
  77721. * @param particleSystem Define the particle system to render
  77722. */
  77723. dispatchParticles(particleSystem: IParticleSystem): void;
  77724. /**
  77725. * Add a submesh to the manager in order to render it this frame
  77726. * @param subMesh The submesh to dispatch
  77727. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77728. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77729. */
  77730. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77731. /**
  77732. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77733. * This allowed control for front to back rendering or reversly depending of the special needs.
  77734. *
  77735. * @param renderingGroupId The rendering group id corresponding to its index
  77736. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77737. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77738. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77739. */
  77740. 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;
  77741. /**
  77742. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77743. *
  77744. * @param renderingGroupId The rendering group id corresponding to its index
  77745. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77746. * @param depth Automatically clears depth between groups if true and autoClear is true.
  77747. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  77748. */
  77749. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  77750. /**
  77751. * Gets the current auto clear configuration for one rendering group of the rendering
  77752. * manager.
  77753. * @param index the rendering group index to get the information for
  77754. * @returns The auto clear setup for the requested rendering group
  77755. */
  77756. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  77757. }
  77758. }
  77759. declare module BABYLON {
  77760. /**
  77761. * This Helps creating a texture that will be created from a camera in your scene.
  77762. * It is basically a dynamic texture that could be used to create special effects for instance.
  77763. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  77764. */
  77765. export class RenderTargetTexture extends Texture {
  77766. isCube: boolean;
  77767. /**
  77768. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  77769. */
  77770. static readonly REFRESHRATE_RENDER_ONCE: number;
  77771. /**
  77772. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  77773. */
  77774. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  77775. /**
  77776. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  77777. * the central point of your effect and can save a lot of performances.
  77778. */
  77779. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  77780. /**
  77781. * Use this predicate to dynamically define the list of mesh you want to render.
  77782. * If set, the renderList property will be overwritten.
  77783. */
  77784. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  77785. private _renderList;
  77786. /**
  77787. * Use this list to define the list of mesh you want to render.
  77788. */
  77789. renderList: Nullable<Array<AbstractMesh>>;
  77790. private _hookArray;
  77791. /**
  77792. * Define if particles should be rendered in your texture.
  77793. */
  77794. renderParticles: boolean;
  77795. /**
  77796. * Define if sprites should be rendered in your texture.
  77797. */
  77798. renderSprites: boolean;
  77799. /**
  77800. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  77801. */
  77802. coordinatesMode: number;
  77803. /**
  77804. * Define the camera used to render the texture.
  77805. */
  77806. activeCamera: Nullable<Camera>;
  77807. /**
  77808. * Override the render function of the texture with your own one.
  77809. */
  77810. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  77811. /**
  77812. * Define if camera post processes should be use while rendering the texture.
  77813. */
  77814. useCameraPostProcesses: boolean;
  77815. /**
  77816. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  77817. */
  77818. ignoreCameraViewport: boolean;
  77819. private _postProcessManager;
  77820. private _postProcesses;
  77821. private _resizeObserver;
  77822. /**
  77823. * An event triggered when the texture is unbind.
  77824. */
  77825. onBeforeBindObservable: Observable<RenderTargetTexture>;
  77826. /**
  77827. * An event triggered when the texture is unbind.
  77828. */
  77829. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  77830. private _onAfterUnbindObserver;
  77831. /**
  77832. * Set a after unbind callback in the texture.
  77833. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  77834. */
  77835. onAfterUnbind: () => void;
  77836. /**
  77837. * An event triggered before rendering the texture
  77838. */
  77839. onBeforeRenderObservable: Observable<number>;
  77840. private _onBeforeRenderObserver;
  77841. /**
  77842. * Set a before render callback in the texture.
  77843. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  77844. */
  77845. onBeforeRender: (faceIndex: number) => void;
  77846. /**
  77847. * An event triggered after rendering the texture
  77848. */
  77849. onAfterRenderObservable: Observable<number>;
  77850. private _onAfterRenderObserver;
  77851. /**
  77852. * Set a after render callback in the texture.
  77853. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  77854. */
  77855. onAfterRender: (faceIndex: number) => void;
  77856. /**
  77857. * An event triggered after the texture clear
  77858. */
  77859. onClearObservable: Observable<Engine>;
  77860. private _onClearObserver;
  77861. /**
  77862. * Set a clear callback in the texture.
  77863. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  77864. */
  77865. onClear: (Engine: Engine) => void;
  77866. /**
  77867. * Define the clear color of the Render Target if it should be different from the scene.
  77868. */
  77869. clearColor: Color4;
  77870. protected _size: number | {
  77871. width: number;
  77872. height: number;
  77873. };
  77874. protected _initialSizeParameter: number | {
  77875. width: number;
  77876. height: number;
  77877. } | {
  77878. ratio: number;
  77879. };
  77880. protected _sizeRatio: Nullable<number>;
  77881. /** @hidden */
  77882. _generateMipMaps: boolean;
  77883. protected _renderingManager: RenderingManager;
  77884. /** @hidden */
  77885. _waitingRenderList: string[];
  77886. protected _doNotChangeAspectRatio: boolean;
  77887. protected _currentRefreshId: number;
  77888. protected _refreshRate: number;
  77889. protected _textureMatrix: Matrix;
  77890. protected _samples: number;
  77891. protected _renderTargetOptions: RenderTargetCreationOptions;
  77892. /**
  77893. * Gets render target creation options that were used.
  77894. */
  77895. readonly renderTargetOptions: RenderTargetCreationOptions;
  77896. protected _engine: Engine;
  77897. protected _onRatioRescale(): void;
  77898. /**
  77899. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  77900. * It must define where the camera used to render the texture is set
  77901. */
  77902. boundingBoxPosition: Vector3;
  77903. private _boundingBoxSize;
  77904. /**
  77905. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  77906. * When defined, the cubemap will switch to local mode
  77907. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77908. * @example https://www.babylonjs-playground.com/#RNASML
  77909. */
  77910. boundingBoxSize: Vector3;
  77911. /**
  77912. * In case the RTT has been created with a depth texture, get the associated
  77913. * depth texture.
  77914. * Otherwise, return null.
  77915. */
  77916. depthStencilTexture: Nullable<InternalTexture>;
  77917. /**
  77918. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77919. * or used a shadow, depth texture...
  77920. * @param name The friendly name of the texture
  77921. * @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)
  77922. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77923. * @param generateMipMaps True if mip maps need to be generated after render.
  77924. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77925. * @param type The type of the buffer in the RTT (int, half float, float...)
  77926. * @param isCube True if a cube texture needs to be created
  77927. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77928. * @param generateDepthBuffer True to generate a depth buffer
  77929. * @param generateStencilBuffer True to generate a stencil buffer
  77930. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77931. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77932. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77933. */
  77934. constructor(name: string, size: number | {
  77935. width: number;
  77936. height: number;
  77937. } | {
  77938. ratio: number;
  77939. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77940. /**
  77941. * Creates a depth stencil texture.
  77942. * This is only available in WebGL 2 or with the depth texture extension available.
  77943. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77944. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77945. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77946. */
  77947. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77948. private _processSizeParameter;
  77949. /**
  77950. * Define the number of samples to use in case of MSAA.
  77951. * It defaults to one meaning no MSAA has been enabled.
  77952. */
  77953. samples: number;
  77954. /**
  77955. * Resets the refresh counter of the texture and start bak from scratch.
  77956. * Could be useful to regenerate the texture if it is setup to render only once.
  77957. */
  77958. resetRefreshCounter(): void;
  77959. /**
  77960. * Define the refresh rate of the texture or the rendering frequency.
  77961. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77962. */
  77963. refreshRate: number;
  77964. /**
  77965. * Adds a post process to the render target rendering passes.
  77966. * @param postProcess define the post process to add
  77967. */
  77968. addPostProcess(postProcess: PostProcess): void;
  77969. /**
  77970. * Clear all the post processes attached to the render target
  77971. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77972. */
  77973. clearPostProcesses(dispose?: boolean): void;
  77974. /**
  77975. * Remove one of the post process from the list of attached post processes to the texture
  77976. * @param postProcess define the post process to remove from the list
  77977. */
  77978. removePostProcess(postProcess: PostProcess): void;
  77979. /** @hidden */
  77980. _shouldRender(): boolean;
  77981. /**
  77982. * Gets the actual render size of the texture.
  77983. * @returns the width of the render size
  77984. */
  77985. getRenderSize(): number;
  77986. /**
  77987. * Gets the actual render width of the texture.
  77988. * @returns the width of the render size
  77989. */
  77990. getRenderWidth(): number;
  77991. /**
  77992. * Gets the actual render height of the texture.
  77993. * @returns the height of the render size
  77994. */
  77995. getRenderHeight(): number;
  77996. /**
  77997. * Get if the texture can be rescaled or not.
  77998. */
  77999. readonly canRescale: boolean;
  78000. /**
  78001. * Resize the texture using a ratio.
  78002. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  78003. */
  78004. scale(ratio: number): void;
  78005. /**
  78006. * Get the texture reflection matrix used to rotate/transform the reflection.
  78007. * @returns the reflection matrix
  78008. */
  78009. getReflectionTextureMatrix(): Matrix;
  78010. /**
  78011. * Resize the texture to a new desired size.
  78012. * Be carrefull as it will recreate all the data in the new texture.
  78013. * @param size Define the new size. It can be:
  78014. * - a number for squared texture,
  78015. * - an object containing { width: number, height: number }
  78016. * - or an object containing a ratio { ratio: number }
  78017. */
  78018. resize(size: number | {
  78019. width: number;
  78020. height: number;
  78021. } | {
  78022. ratio: number;
  78023. }): void;
  78024. /**
  78025. * Renders all the objects from the render list into the texture.
  78026. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  78027. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  78028. */
  78029. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  78030. private _bestReflectionRenderTargetDimension;
  78031. /**
  78032. * @hidden
  78033. * @param faceIndex face index to bind to if this is a cubetexture
  78034. */
  78035. _bindFrameBuffer(faceIndex?: number): void;
  78036. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  78037. private renderToTarget;
  78038. /**
  78039. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  78040. * This allowed control for front to back rendering or reversly depending of the special needs.
  78041. *
  78042. * @param renderingGroupId The rendering group id corresponding to its index
  78043. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  78044. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  78045. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  78046. */
  78047. 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;
  78048. /**
  78049. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  78050. *
  78051. * @param renderingGroupId The rendering group id corresponding to its index
  78052. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  78053. */
  78054. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  78055. /**
  78056. * Clones the texture.
  78057. * @returns the cloned texture
  78058. */
  78059. clone(): RenderTargetTexture;
  78060. /**
  78061. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  78062. * @returns The JSON representation of the texture
  78063. */
  78064. serialize(): any;
  78065. /**
  78066. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  78067. */
  78068. disposeFramebufferObjects(): void;
  78069. /**
  78070. * Dispose the texture and release its associated resources.
  78071. */
  78072. dispose(): void;
  78073. /** @hidden */
  78074. _rebuild(): void;
  78075. /**
  78076. * Clear the info related to rendering groups preventing retention point in material dispose.
  78077. */
  78078. freeRenderingGroups(): void;
  78079. /**
  78080. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  78081. * @returns the view count
  78082. */
  78083. getViewCount(): number;
  78084. }
  78085. }
  78086. declare module BABYLON {
  78087. /**
  78088. * Mirror texture can be used to simulate the view from a mirror in a scene.
  78089. * It will dynamically be rendered every frame to adapt to the camera point of view.
  78090. * You can then easily use it as a reflectionTexture on a flat surface.
  78091. * In case the surface is not a plane, please consider relying on reflection probes.
  78092. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78093. */
  78094. export class MirrorTexture extends RenderTargetTexture {
  78095. private scene;
  78096. /**
  78097. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  78098. * 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.
  78099. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78100. */
  78101. mirrorPlane: Plane;
  78102. /**
  78103. * Define the blur ratio used to blur the reflection if needed.
  78104. */
  78105. blurRatio: number;
  78106. /**
  78107. * Define the adaptive blur kernel used to blur the reflection if needed.
  78108. * This will autocompute the closest best match for the `blurKernel`
  78109. */
  78110. adaptiveBlurKernel: number;
  78111. /**
  78112. * Define the blur kernel used to blur the reflection if needed.
  78113. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78114. */
  78115. blurKernel: number;
  78116. /**
  78117. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  78118. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78119. */
  78120. blurKernelX: number;
  78121. /**
  78122. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  78123. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78124. */
  78125. blurKernelY: number;
  78126. private _autoComputeBlurKernel;
  78127. protected _onRatioRescale(): void;
  78128. private _updateGammaSpace;
  78129. private _imageProcessingConfigChangeObserver;
  78130. private _transformMatrix;
  78131. private _mirrorMatrix;
  78132. private _savedViewMatrix;
  78133. private _blurX;
  78134. private _blurY;
  78135. private _adaptiveBlurKernel;
  78136. private _blurKernelX;
  78137. private _blurKernelY;
  78138. private _blurRatio;
  78139. /**
  78140. * Instantiates a Mirror Texture.
  78141. * Mirror texture can be used to simulate the view from a mirror in a scene.
  78142. * It will dynamically be rendered every frame to adapt to the camera point of view.
  78143. * You can then easily use it as a reflectionTexture on a flat surface.
  78144. * In case the surface is not a plane, please consider relying on reflection probes.
  78145. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78146. * @param name
  78147. * @param size
  78148. * @param scene
  78149. * @param generateMipMaps
  78150. * @param type
  78151. * @param samplingMode
  78152. * @param generateDepthBuffer
  78153. */
  78154. constructor(name: string, size: number | {
  78155. width: number;
  78156. height: number;
  78157. } | {
  78158. ratio: number;
  78159. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  78160. private _preparePostProcesses;
  78161. /**
  78162. * Clone the mirror texture.
  78163. * @returns the cloned texture
  78164. */
  78165. clone(): MirrorTexture;
  78166. /**
  78167. * Serialize the texture to a JSON representation you could use in Parse later on
  78168. * @returns the serialized JSON representation
  78169. */
  78170. serialize(): any;
  78171. /**
  78172. * Dispose the texture and release its associated resources.
  78173. */
  78174. dispose(): void;
  78175. }
  78176. }
  78177. declare module BABYLON {
  78178. /**
  78179. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78180. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78181. */
  78182. export class Texture extends BaseTexture {
  78183. /** @hidden */
  78184. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  78185. /** @hidden */
  78186. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  78187. /** @hidden */
  78188. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  78189. /** nearest is mag = nearest and min = nearest and mip = linear */
  78190. static readonly NEAREST_SAMPLINGMODE: number;
  78191. /** nearest is mag = nearest and min = nearest and mip = linear */
  78192. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  78193. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78194. static readonly BILINEAR_SAMPLINGMODE: number;
  78195. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78196. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  78197. /** Trilinear is mag = linear and min = linear and mip = linear */
  78198. static readonly TRILINEAR_SAMPLINGMODE: number;
  78199. /** Trilinear is mag = linear and min = linear and mip = linear */
  78200. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  78201. /** mag = nearest and min = nearest and mip = nearest */
  78202. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  78203. /** mag = nearest and min = linear and mip = nearest */
  78204. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  78205. /** mag = nearest and min = linear and mip = linear */
  78206. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  78207. /** mag = nearest and min = linear and mip = none */
  78208. static readonly NEAREST_LINEAR: number;
  78209. /** mag = nearest and min = nearest and mip = none */
  78210. static readonly NEAREST_NEAREST: number;
  78211. /** mag = linear and min = nearest and mip = nearest */
  78212. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  78213. /** mag = linear and min = nearest and mip = linear */
  78214. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  78215. /** mag = linear and min = linear and mip = none */
  78216. static readonly LINEAR_LINEAR: number;
  78217. /** mag = linear and min = nearest and mip = none */
  78218. static readonly LINEAR_NEAREST: number;
  78219. /** Explicit coordinates mode */
  78220. static readonly EXPLICIT_MODE: number;
  78221. /** Spherical coordinates mode */
  78222. static readonly SPHERICAL_MODE: number;
  78223. /** Planar coordinates mode */
  78224. static readonly PLANAR_MODE: number;
  78225. /** Cubic coordinates mode */
  78226. static readonly CUBIC_MODE: number;
  78227. /** Projection coordinates mode */
  78228. static readonly PROJECTION_MODE: number;
  78229. /** Inverse Cubic coordinates mode */
  78230. static readonly SKYBOX_MODE: number;
  78231. /** Inverse Cubic coordinates mode */
  78232. static readonly INVCUBIC_MODE: number;
  78233. /** Equirectangular coordinates mode */
  78234. static readonly EQUIRECTANGULAR_MODE: number;
  78235. /** Equirectangular Fixed coordinates mode */
  78236. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  78237. /** Equirectangular Fixed Mirrored coordinates mode */
  78238. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78239. /** Texture is not repeating outside of 0..1 UVs */
  78240. static readonly CLAMP_ADDRESSMODE: number;
  78241. /** Texture is repeating outside of 0..1 UVs */
  78242. static readonly WRAP_ADDRESSMODE: number;
  78243. /** Texture is repeating and mirrored */
  78244. static readonly MIRROR_ADDRESSMODE: number;
  78245. /**
  78246. * 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
  78247. */
  78248. static UseSerializedUrlIfAny: boolean;
  78249. /**
  78250. * Define the url of the texture.
  78251. */
  78252. url: Nullable<string>;
  78253. /**
  78254. * Define an offset on the texture to offset the u coordinates of the UVs
  78255. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78256. */
  78257. uOffset: number;
  78258. /**
  78259. * Define an offset on the texture to offset the v coordinates of the UVs
  78260. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78261. */
  78262. vOffset: number;
  78263. /**
  78264. * Define an offset on the texture to scale the u coordinates of the UVs
  78265. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78266. */
  78267. uScale: number;
  78268. /**
  78269. * Define an offset on the texture to scale the v coordinates of the UVs
  78270. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78271. */
  78272. vScale: number;
  78273. /**
  78274. * Define an offset on the texture to rotate around the u coordinates of the UVs
  78275. * @see http://doc.babylonjs.com/how_to/more_materials
  78276. */
  78277. uAng: number;
  78278. /**
  78279. * Define an offset on the texture to rotate around the v coordinates of the UVs
  78280. * @see http://doc.babylonjs.com/how_to/more_materials
  78281. */
  78282. vAng: number;
  78283. /**
  78284. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  78285. * @see http://doc.babylonjs.com/how_to/more_materials
  78286. */
  78287. wAng: number;
  78288. /**
  78289. * Defines the center of rotation (U)
  78290. */
  78291. uRotationCenter: number;
  78292. /**
  78293. * Defines the center of rotation (V)
  78294. */
  78295. vRotationCenter: number;
  78296. /**
  78297. * Defines the center of rotation (W)
  78298. */
  78299. wRotationCenter: number;
  78300. /**
  78301. * Are mip maps generated for this texture or not.
  78302. */
  78303. readonly noMipmap: boolean;
  78304. /**
  78305. * List of inspectable custom properties (used by the Inspector)
  78306. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78307. */
  78308. inspectableCustomProperties: Nullable<IInspectable[]>;
  78309. private _noMipmap;
  78310. /** @hidden */
  78311. _invertY: boolean;
  78312. private _rowGenerationMatrix;
  78313. private _cachedTextureMatrix;
  78314. private _projectionModeMatrix;
  78315. private _t0;
  78316. private _t1;
  78317. private _t2;
  78318. private _cachedUOffset;
  78319. private _cachedVOffset;
  78320. private _cachedUScale;
  78321. private _cachedVScale;
  78322. private _cachedUAng;
  78323. private _cachedVAng;
  78324. private _cachedWAng;
  78325. private _cachedProjectionMatrixId;
  78326. private _cachedCoordinatesMode;
  78327. /** @hidden */
  78328. protected _initialSamplingMode: number;
  78329. /** @hidden */
  78330. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  78331. private _deleteBuffer;
  78332. protected _format: Nullable<number>;
  78333. private _delayedOnLoad;
  78334. private _delayedOnError;
  78335. /**
  78336. * Observable triggered once the texture has been loaded.
  78337. */
  78338. onLoadObservable: Observable<Texture>;
  78339. protected _isBlocking: boolean;
  78340. /**
  78341. * Is the texture preventing material to render while loading.
  78342. * If false, a default texture will be used instead of the loading one during the preparation step.
  78343. */
  78344. isBlocking: boolean;
  78345. /**
  78346. * Get the current sampling mode associated with the texture.
  78347. */
  78348. readonly samplingMode: number;
  78349. /**
  78350. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  78351. */
  78352. readonly invertY: boolean;
  78353. /**
  78354. * Instantiates a new texture.
  78355. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78356. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78357. * @param url define the url of the picture to load as a texture
  78358. * @param scene define the scene the texture will belong to
  78359. * @param noMipmap define if the texture will require mip maps or not
  78360. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78361. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78362. * @param onLoad define a callback triggered when the texture has been loaded
  78363. * @param onError define a callback triggered when an error occurred during the loading session
  78364. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78365. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78366. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78367. */
  78368. 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);
  78369. /**
  78370. * Update the url (and optional buffer) of this texture if url was null during construction.
  78371. * @param url the url of the texture
  78372. * @param buffer the buffer of the texture (defaults to null)
  78373. * @param onLoad callback called when the texture is loaded (defaults to null)
  78374. */
  78375. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  78376. /**
  78377. * Finish the loading sequence of a texture flagged as delayed load.
  78378. * @hidden
  78379. */
  78380. delayLoad(): void;
  78381. private _prepareRowForTextureGeneration;
  78382. /**
  78383. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  78384. * @returns the transform matrix of the texture.
  78385. */
  78386. getTextureMatrix(): Matrix;
  78387. /**
  78388. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  78389. * @returns The reflection texture transform
  78390. */
  78391. getReflectionTextureMatrix(): Matrix;
  78392. /**
  78393. * Clones the texture.
  78394. * @returns the cloned texture
  78395. */
  78396. clone(): Texture;
  78397. /**
  78398. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  78399. * @returns The JSON representation of the texture
  78400. */
  78401. serialize(): any;
  78402. /**
  78403. * Get the current class name of the texture useful for serialization or dynamic coding.
  78404. * @returns "Texture"
  78405. */
  78406. getClassName(): string;
  78407. /**
  78408. * Dispose the texture and release its associated resources.
  78409. */
  78410. dispose(): void;
  78411. /**
  78412. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  78413. * @param parsedTexture Define the JSON representation of the texture
  78414. * @param scene Define the scene the parsed texture should be instantiated in
  78415. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  78416. * @returns The parsed texture if successful
  78417. */
  78418. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  78419. /**
  78420. * Creates a texture from its base 64 representation.
  78421. * @param data Define the base64 payload without the data: prefix
  78422. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78423. * @param scene Define the scene the texture should belong to
  78424. * @param noMipmap Forces the texture to not create mip map information if true
  78425. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78426. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78427. * @param onLoad define a callback triggered when the texture has been loaded
  78428. * @param onError define a callback triggered when an error occurred during the loading session
  78429. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78430. * @returns the created texture
  78431. */
  78432. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  78433. /**
  78434. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  78435. * @param data Define the base64 payload without the data: prefix
  78436. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78437. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78438. * @param scene Define the scene the texture should belong to
  78439. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78440. * @param noMipmap Forces the texture to not create mip map information if true
  78441. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78442. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78443. * @param onLoad define a callback triggered when the texture has been loaded
  78444. * @param onError define a callback triggered when an error occurred during the loading session
  78445. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78446. * @returns the created texture
  78447. */
  78448. 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;
  78449. }
  78450. }
  78451. declare module BABYLON {
  78452. interface Engine {
  78453. /**
  78454. * Creates a raw texture
  78455. * @param data defines the data to store in the texture
  78456. * @param width defines the width of the texture
  78457. * @param height defines the height of the texture
  78458. * @param format defines the format of the data
  78459. * @param generateMipMaps defines if the engine should generate the mip levels
  78460. * @param invertY defines if data must be stored with Y axis inverted
  78461. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78462. * @param compression defines the compression used (null by default)
  78463. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78464. * @returns the raw texture inside an InternalTexture
  78465. */
  78466. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78467. /**
  78468. * Update a raw texture
  78469. * @param texture defines the texture to update
  78470. * @param data defines the data to store in the texture
  78471. * @param format defines the format of the data
  78472. * @param invertY defines if data must be stored with Y axis inverted
  78473. */
  78474. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78475. /**
  78476. * Update a raw texture
  78477. * @param texture defines the texture to update
  78478. * @param data defines the data to store in the texture
  78479. * @param format defines the format of the data
  78480. * @param invertY defines if data must be stored with Y axis inverted
  78481. * @param compression defines the compression used (null by default)
  78482. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78483. */
  78484. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78485. /**
  78486. * Creates a new raw cube texture
  78487. * @param data defines the array of data to use to create each face
  78488. * @param size defines the size of the textures
  78489. * @param format defines the format of the data
  78490. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78491. * @param generateMipMaps defines if the engine should generate the mip levels
  78492. * @param invertY defines if data must be stored with Y axis inverted
  78493. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78494. * @param compression defines the compression used (null by default)
  78495. * @returns the cube texture as an InternalTexture
  78496. */
  78497. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78498. /**
  78499. * Update a raw cube texture
  78500. * @param texture defines the texture to udpdate
  78501. * @param data defines the data to store
  78502. * @param format defines the data format
  78503. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78504. * @param invertY defines if data must be stored with Y axis inverted
  78505. */
  78506. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78507. /**
  78508. * Update a raw cube texture
  78509. * @param texture defines the texture to udpdate
  78510. * @param data defines the data to store
  78511. * @param format defines the data format
  78512. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78513. * @param invertY defines if data must be stored with Y axis inverted
  78514. * @param compression defines the compression used (null by default)
  78515. */
  78516. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78517. /**
  78518. * Update a raw cube texture
  78519. * @param texture defines the texture to udpdate
  78520. * @param data defines the data to store
  78521. * @param format defines the data format
  78522. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78523. * @param invertY defines if data must be stored with Y axis inverted
  78524. * @param compression defines the compression used (null by default)
  78525. * @param level defines which level of the texture to update
  78526. */
  78527. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78528. /**
  78529. * Creates a new raw cube texture from a specified url
  78530. * @param url defines the url where the data is located
  78531. * @param scene defines the current scene
  78532. * @param size defines the size of the textures
  78533. * @param format defines the format of the data
  78534. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78535. * @param noMipmap defines if the engine should avoid generating the mip levels
  78536. * @param callback defines a callback used to extract texture data from loaded data
  78537. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78538. * @param onLoad defines a callback called when texture is loaded
  78539. * @param onError defines a callback called if there is an error
  78540. * @returns the cube texture as an InternalTexture
  78541. */
  78542. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  78543. /**
  78544. * Creates a new raw cube texture from a specified url
  78545. * @param url defines the url where the data is located
  78546. * @param scene defines the current scene
  78547. * @param size defines the size of the textures
  78548. * @param format defines the format of the data
  78549. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78550. * @param noMipmap defines if the engine should avoid generating the mip levels
  78551. * @param callback defines a callback used to extract texture data from loaded data
  78552. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78553. * @param onLoad defines a callback called when texture is loaded
  78554. * @param onError defines a callback called if there is an error
  78555. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78556. * @param invertY defines if data must be stored with Y axis inverted
  78557. * @returns the cube texture as an InternalTexture
  78558. */
  78559. 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;
  78560. /**
  78561. * Creates a new raw 3D texture
  78562. * @param data defines the data used to create the texture
  78563. * @param width defines the width of the texture
  78564. * @param height defines the height of the texture
  78565. * @param depth defines the depth of the texture
  78566. * @param format defines the format of the texture
  78567. * @param generateMipMaps defines if the engine must generate mip levels
  78568. * @param invertY defines if data must be stored with Y axis inverted
  78569. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78570. * @param compression defines the compressed used (can be null)
  78571. * @param textureType defines the compressed used (can be null)
  78572. * @returns a new raw 3D texture (stored in an InternalTexture)
  78573. */
  78574. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78575. /**
  78576. * Update a raw 3D texture
  78577. * @param texture defines the texture to update
  78578. * @param data defines the data to store
  78579. * @param format defines the data format
  78580. * @param invertY defines if data must be stored with Y axis inverted
  78581. */
  78582. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78583. /**
  78584. * Update a raw 3D texture
  78585. * @param texture defines the texture to update
  78586. * @param data defines the data to store
  78587. * @param format defines the data format
  78588. * @param invertY defines if data must be stored with Y axis inverted
  78589. * @param compression defines the used compression (can be null)
  78590. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78591. */
  78592. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78593. }
  78594. }
  78595. declare module BABYLON {
  78596. /**
  78597. * Raw texture can help creating a texture directly from an array of data.
  78598. * This can be super useful if you either get the data from an uncompressed source or
  78599. * if you wish to create your texture pixel by pixel.
  78600. */
  78601. export class RawTexture extends Texture {
  78602. /**
  78603. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78604. */
  78605. format: number;
  78606. private _engine;
  78607. /**
  78608. * Instantiates a new RawTexture.
  78609. * Raw texture can help creating a texture directly from an array of data.
  78610. * This can be super useful if you either get the data from an uncompressed source or
  78611. * if you wish to create your texture pixel by pixel.
  78612. * @param data define the array of data to use to create the texture
  78613. * @param width define the width of the texture
  78614. * @param height define the height of the texture
  78615. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78616. * @param scene define the scene the texture belongs to
  78617. * @param generateMipMaps define whether mip maps should be generated or not
  78618. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78619. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78620. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78621. */
  78622. constructor(data: ArrayBufferView, width: number, height: number,
  78623. /**
  78624. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78625. */
  78626. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78627. /**
  78628. * Updates the texture underlying data.
  78629. * @param data Define the new data of the texture
  78630. */
  78631. update(data: ArrayBufferView): void;
  78632. /**
  78633. * Creates a luminance texture from some data.
  78634. * @param data Define the texture data
  78635. * @param width Define the width of the texture
  78636. * @param height Define the height of the texture
  78637. * @param scene Define the scene the texture belongs to
  78638. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78639. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78640. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78641. * @returns the luminance texture
  78642. */
  78643. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78644. /**
  78645. * Creates a luminance alpha texture from some data.
  78646. * @param data Define the texture data
  78647. * @param width Define the width of the texture
  78648. * @param height Define the height of the texture
  78649. * @param scene Define the scene the texture belongs to
  78650. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78651. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78652. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78653. * @returns the luminance alpha texture
  78654. */
  78655. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78656. /**
  78657. * Creates an alpha texture from some data.
  78658. * @param data Define the texture data
  78659. * @param width Define the width of the texture
  78660. * @param height Define the height of the texture
  78661. * @param scene Define the scene the texture belongs to
  78662. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78663. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78664. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78665. * @returns the alpha texture
  78666. */
  78667. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78668. /**
  78669. * Creates a RGB texture from some data.
  78670. * @param data Define the texture data
  78671. * @param width Define the width of the texture
  78672. * @param height Define the height of the texture
  78673. * @param scene Define the scene the texture belongs to
  78674. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78675. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78676. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78677. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78678. * @returns the RGB alpha texture
  78679. */
  78680. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78681. /**
  78682. * Creates a RGBA texture from some data.
  78683. * @param data Define the texture data
  78684. * @param width Define the width of the texture
  78685. * @param height Define the height of the texture
  78686. * @param scene Define the scene the texture belongs to
  78687. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78688. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78689. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78690. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78691. * @returns the RGBA texture
  78692. */
  78693. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78694. /**
  78695. * Creates a R texture from some data.
  78696. * @param data Define the texture data
  78697. * @param width Define the width of the texture
  78698. * @param height Define the height of the texture
  78699. * @param scene Define the scene the texture belongs to
  78700. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78701. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78702. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78703. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78704. * @returns the R texture
  78705. */
  78706. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78707. }
  78708. }
  78709. declare module BABYLON {
  78710. /**
  78711. * Defines a runtime animation
  78712. */
  78713. export class RuntimeAnimation {
  78714. private _events;
  78715. /**
  78716. * The current frame of the runtime animation
  78717. */
  78718. private _currentFrame;
  78719. /**
  78720. * The animation used by the runtime animation
  78721. */
  78722. private _animation;
  78723. /**
  78724. * The target of the runtime animation
  78725. */
  78726. private _target;
  78727. /**
  78728. * The initiating animatable
  78729. */
  78730. private _host;
  78731. /**
  78732. * The original value of the runtime animation
  78733. */
  78734. private _originalValue;
  78735. /**
  78736. * The original blend value of the runtime animation
  78737. */
  78738. private _originalBlendValue;
  78739. /**
  78740. * The offsets cache of the runtime animation
  78741. */
  78742. private _offsetsCache;
  78743. /**
  78744. * The high limits cache of the runtime animation
  78745. */
  78746. private _highLimitsCache;
  78747. /**
  78748. * Specifies if the runtime animation has been stopped
  78749. */
  78750. private _stopped;
  78751. /**
  78752. * The blending factor of the runtime animation
  78753. */
  78754. private _blendingFactor;
  78755. /**
  78756. * The BabylonJS scene
  78757. */
  78758. private _scene;
  78759. /**
  78760. * The current value of the runtime animation
  78761. */
  78762. private _currentValue;
  78763. /** @hidden */
  78764. _animationState: _IAnimationState;
  78765. /**
  78766. * The active target of the runtime animation
  78767. */
  78768. private _activeTargets;
  78769. private _currentActiveTarget;
  78770. private _directTarget;
  78771. /**
  78772. * The target path of the runtime animation
  78773. */
  78774. private _targetPath;
  78775. /**
  78776. * The weight of the runtime animation
  78777. */
  78778. private _weight;
  78779. /**
  78780. * The ratio offset of the runtime animation
  78781. */
  78782. private _ratioOffset;
  78783. /**
  78784. * The previous delay of the runtime animation
  78785. */
  78786. private _previousDelay;
  78787. /**
  78788. * The previous ratio of the runtime animation
  78789. */
  78790. private _previousRatio;
  78791. private _enableBlending;
  78792. private _keys;
  78793. private _minFrame;
  78794. private _maxFrame;
  78795. private _minValue;
  78796. private _maxValue;
  78797. private _targetIsArray;
  78798. /**
  78799. * Gets the current frame of the runtime animation
  78800. */
  78801. readonly currentFrame: number;
  78802. /**
  78803. * Gets the weight of the runtime animation
  78804. */
  78805. readonly weight: number;
  78806. /**
  78807. * Gets the current value of the runtime animation
  78808. */
  78809. readonly currentValue: any;
  78810. /**
  78811. * Gets the target path of the runtime animation
  78812. */
  78813. readonly targetPath: string;
  78814. /**
  78815. * Gets the actual target of the runtime animation
  78816. */
  78817. readonly target: any;
  78818. /** @hidden */
  78819. _onLoop: () => void;
  78820. /**
  78821. * Create a new RuntimeAnimation object
  78822. * @param target defines the target of the animation
  78823. * @param animation defines the source animation object
  78824. * @param scene defines the hosting scene
  78825. * @param host defines the initiating Animatable
  78826. */
  78827. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78828. private _preparePath;
  78829. /**
  78830. * Gets the animation from the runtime animation
  78831. */
  78832. readonly animation: Animation;
  78833. /**
  78834. * Resets the runtime animation to the beginning
  78835. * @param restoreOriginal defines whether to restore the target property to the original value
  78836. */
  78837. reset(restoreOriginal?: boolean): void;
  78838. /**
  78839. * Specifies if the runtime animation is stopped
  78840. * @returns Boolean specifying if the runtime animation is stopped
  78841. */
  78842. isStopped(): boolean;
  78843. /**
  78844. * Disposes of the runtime animation
  78845. */
  78846. dispose(): void;
  78847. /**
  78848. * Apply the interpolated value to the target
  78849. * @param currentValue defines the value computed by the animation
  78850. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78851. */
  78852. setValue(currentValue: any, weight: number): void;
  78853. private _getOriginalValues;
  78854. private _setValue;
  78855. /**
  78856. * Gets the loop pmode of the runtime animation
  78857. * @returns Loop Mode
  78858. */
  78859. private _getCorrectLoopMode;
  78860. /**
  78861. * Move the current animation to a given frame
  78862. * @param frame defines the frame to move to
  78863. */
  78864. goToFrame(frame: number): void;
  78865. /**
  78866. * @hidden Internal use only
  78867. */
  78868. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78869. /**
  78870. * Execute the current animation
  78871. * @param delay defines the delay to add to the current frame
  78872. * @param from defines the lower bound of the animation range
  78873. * @param to defines the upper bound of the animation range
  78874. * @param loop defines if the current animation must loop
  78875. * @param speedRatio defines the current speed ratio
  78876. * @param weight defines the weight of the animation (default is -1 so no weight)
  78877. * @param onLoop optional callback called when animation loops
  78878. * @returns a boolean indicating if the animation is running
  78879. */
  78880. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78881. }
  78882. }
  78883. declare module BABYLON {
  78884. /**
  78885. * Class used to store an actual running animation
  78886. */
  78887. export class Animatable {
  78888. /** defines the target object */
  78889. target: any;
  78890. /** defines the starting frame number (default is 0) */
  78891. fromFrame: number;
  78892. /** defines the ending frame number (default is 100) */
  78893. toFrame: number;
  78894. /** defines if the animation must loop (default is false) */
  78895. loopAnimation: boolean;
  78896. /** defines a callback to call when animation ends if it is not looping */
  78897. onAnimationEnd?: (() => void) | null | undefined;
  78898. /** defines a callback to call when animation loops */
  78899. onAnimationLoop?: (() => void) | null | undefined;
  78900. private _localDelayOffset;
  78901. private _pausedDelay;
  78902. private _runtimeAnimations;
  78903. private _paused;
  78904. private _scene;
  78905. private _speedRatio;
  78906. private _weight;
  78907. private _syncRoot;
  78908. /**
  78909. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78910. * This will only apply for non looping animation (default is true)
  78911. */
  78912. disposeOnEnd: boolean;
  78913. /**
  78914. * Gets a boolean indicating if the animation has started
  78915. */
  78916. animationStarted: boolean;
  78917. /**
  78918. * Observer raised when the animation ends
  78919. */
  78920. onAnimationEndObservable: Observable<Animatable>;
  78921. /**
  78922. * Observer raised when the animation loops
  78923. */
  78924. onAnimationLoopObservable: Observable<Animatable>;
  78925. /**
  78926. * Gets the root Animatable used to synchronize and normalize animations
  78927. */
  78928. readonly syncRoot: Nullable<Animatable>;
  78929. /**
  78930. * Gets the current frame of the first RuntimeAnimation
  78931. * Used to synchronize Animatables
  78932. */
  78933. readonly masterFrame: number;
  78934. /**
  78935. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78936. */
  78937. weight: number;
  78938. /**
  78939. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78940. */
  78941. speedRatio: number;
  78942. /**
  78943. * Creates a new Animatable
  78944. * @param scene defines the hosting scene
  78945. * @param target defines the target object
  78946. * @param fromFrame defines the starting frame number (default is 0)
  78947. * @param toFrame defines the ending frame number (default is 100)
  78948. * @param loopAnimation defines if the animation must loop (default is false)
  78949. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78950. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78951. * @param animations defines a group of animation to add to the new Animatable
  78952. * @param onAnimationLoop defines a callback to call when animation loops
  78953. */
  78954. constructor(scene: Scene,
  78955. /** defines the target object */
  78956. target: any,
  78957. /** defines the starting frame number (default is 0) */
  78958. fromFrame?: number,
  78959. /** defines the ending frame number (default is 100) */
  78960. toFrame?: number,
  78961. /** defines if the animation must loop (default is false) */
  78962. loopAnimation?: boolean, speedRatio?: number,
  78963. /** defines a callback to call when animation ends if it is not looping */
  78964. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78965. /** defines a callback to call when animation loops */
  78966. onAnimationLoop?: (() => void) | null | undefined);
  78967. /**
  78968. * Synchronize and normalize current Animatable with a source Animatable
  78969. * This is useful when using animation weights and when animations are not of the same length
  78970. * @param root defines the root Animatable to synchronize with
  78971. * @returns the current Animatable
  78972. */
  78973. syncWith(root: Animatable): Animatable;
  78974. /**
  78975. * Gets the list of runtime animations
  78976. * @returns an array of RuntimeAnimation
  78977. */
  78978. getAnimations(): RuntimeAnimation[];
  78979. /**
  78980. * Adds more animations to the current animatable
  78981. * @param target defines the target of the animations
  78982. * @param animations defines the new animations to add
  78983. */
  78984. appendAnimations(target: any, animations: Animation[]): void;
  78985. /**
  78986. * Gets the source animation for a specific property
  78987. * @param property defines the propertyu to look for
  78988. * @returns null or the source animation for the given property
  78989. */
  78990. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78991. /**
  78992. * Gets the runtime animation for a specific property
  78993. * @param property defines the propertyu to look for
  78994. * @returns null or the runtime animation for the given property
  78995. */
  78996. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78997. /**
  78998. * Resets the animatable to its original state
  78999. */
  79000. reset(): void;
  79001. /**
  79002. * Allows the animatable to blend with current running animations
  79003. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79004. * @param blendingSpeed defines the blending speed to use
  79005. */
  79006. enableBlending(blendingSpeed: number): void;
  79007. /**
  79008. * Disable animation blending
  79009. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79010. */
  79011. disableBlending(): void;
  79012. /**
  79013. * Jump directly to a given frame
  79014. * @param frame defines the frame to jump to
  79015. */
  79016. goToFrame(frame: number): void;
  79017. /**
  79018. * Pause the animation
  79019. */
  79020. pause(): void;
  79021. /**
  79022. * Restart the animation
  79023. */
  79024. restart(): void;
  79025. private _raiseOnAnimationEnd;
  79026. /**
  79027. * Stop and delete the current animation
  79028. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  79029. * @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)
  79030. */
  79031. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  79032. /**
  79033. * Wait asynchronously for the animation to end
  79034. * @returns a promise which will be fullfilled when the animation ends
  79035. */
  79036. waitAsync(): Promise<Animatable>;
  79037. /** @hidden */
  79038. _animate(delay: number): boolean;
  79039. }
  79040. interface Scene {
  79041. /** @hidden */
  79042. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  79043. /** @hidden */
  79044. _processLateAnimationBindingsForMatrices(holder: {
  79045. totalWeight: number;
  79046. animations: RuntimeAnimation[];
  79047. originalValue: Matrix;
  79048. }): any;
  79049. /** @hidden */
  79050. _processLateAnimationBindingsForQuaternions(holder: {
  79051. totalWeight: number;
  79052. animations: RuntimeAnimation[];
  79053. originalValue: Quaternion;
  79054. }, refQuaternion: Quaternion): Quaternion;
  79055. /** @hidden */
  79056. _processLateAnimationBindings(): void;
  79057. /**
  79058. * Will start the animation sequence of a given target
  79059. * @param target defines the target
  79060. * @param from defines from which frame should animation start
  79061. * @param to defines until which frame should animation run.
  79062. * @param weight defines the weight to apply to the animation (1.0 by default)
  79063. * @param loop defines if the animation loops
  79064. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79065. * @param onAnimationEnd defines the function to be executed when the animation ends
  79066. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79067. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79068. * @param onAnimationLoop defines the callback to call when an animation loops
  79069. * @returns the animatable object created for this animation
  79070. */
  79071. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79072. /**
  79073. * Will start the animation sequence of a given target
  79074. * @param target defines the target
  79075. * @param from defines from which frame should animation start
  79076. * @param to defines until which frame should animation run.
  79077. * @param loop defines if the animation loops
  79078. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79079. * @param onAnimationEnd defines the function to be executed when the animation ends
  79080. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79081. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79082. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  79083. * @param onAnimationLoop defines the callback to call when an animation loops
  79084. * @returns the animatable object created for this animation
  79085. */
  79086. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79087. /**
  79088. * Will start the animation sequence of a given target and its hierarchy
  79089. * @param target defines the target
  79090. * @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.
  79091. * @param from defines from which frame should animation start
  79092. * @param to defines until which frame should animation run.
  79093. * @param loop defines if the animation loops
  79094. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79095. * @param onAnimationEnd defines the function to be executed when the animation ends
  79096. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79097. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79098. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79099. * @param onAnimationLoop defines the callback to call when an animation loops
  79100. * @returns the list of created animatables
  79101. */
  79102. 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[];
  79103. /**
  79104. * Begin a new animation on a given node
  79105. * @param target defines the target where the animation will take place
  79106. * @param animations defines the list of animations to start
  79107. * @param from defines the initial value
  79108. * @param to defines the final value
  79109. * @param loop defines if you want animation to loop (off by default)
  79110. * @param speedRatio defines the speed ratio to apply to all animations
  79111. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79112. * @param onAnimationLoop defines the callback to call when an animation loops
  79113. * @returns the list of created animatables
  79114. */
  79115. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79116. /**
  79117. * Begin a new animation on a given node and its hierarchy
  79118. * @param target defines the root node where the animation will take place
  79119. * @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.
  79120. * @param animations defines the list of animations to start
  79121. * @param from defines the initial value
  79122. * @param to defines the final value
  79123. * @param loop defines if you want animation to loop (off by default)
  79124. * @param speedRatio defines the speed ratio to apply to all animations
  79125. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79126. * @param onAnimationLoop defines the callback to call when an animation loops
  79127. * @returns the list of animatables created for all nodes
  79128. */
  79129. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79130. /**
  79131. * Gets the animatable associated with a specific target
  79132. * @param target defines the target of the animatable
  79133. * @returns the required animatable if found
  79134. */
  79135. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79136. /**
  79137. * Gets all animatables associated with a given target
  79138. * @param target defines the target to look animatables for
  79139. * @returns an array of Animatables
  79140. */
  79141. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79142. /**
  79143. * Stops and removes all animations that have been applied to the scene
  79144. */
  79145. stopAllAnimations(): void;
  79146. }
  79147. interface Bone {
  79148. /**
  79149. * Copy an animation range from another bone
  79150. * @param source defines the source bone
  79151. * @param rangeName defines the range name to copy
  79152. * @param frameOffset defines the frame offset
  79153. * @param rescaleAsRequired defines if rescaling must be applied if required
  79154. * @param skelDimensionsRatio defines the scaling ratio
  79155. * @returns true if operation was successful
  79156. */
  79157. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79158. }
  79159. }
  79160. declare module BABYLON {
  79161. /**
  79162. * Class used to handle skinning animations
  79163. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79164. */
  79165. export class Skeleton implements IAnimatable {
  79166. /** defines the skeleton name */
  79167. name: string;
  79168. /** defines the skeleton Id */
  79169. id: string;
  79170. /**
  79171. * Defines the list of child bones
  79172. */
  79173. bones: Bone[];
  79174. /**
  79175. * Defines an estimate of the dimension of the skeleton at rest
  79176. */
  79177. dimensionsAtRest: Vector3;
  79178. /**
  79179. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79180. */
  79181. needInitialSkinMatrix: boolean;
  79182. /**
  79183. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79184. */
  79185. overrideMesh: Nullable<AbstractMesh>;
  79186. /**
  79187. * Gets the list of animations attached to this skeleton
  79188. */
  79189. animations: Array<Animation>;
  79190. private _scene;
  79191. private _isDirty;
  79192. private _transformMatrices;
  79193. private _transformMatrixTexture;
  79194. private _meshesWithPoseMatrix;
  79195. private _animatables;
  79196. private _identity;
  79197. private _synchronizedWithMesh;
  79198. private _ranges;
  79199. private _lastAbsoluteTransformsUpdateId;
  79200. private _canUseTextureForBones;
  79201. private _uniqueId;
  79202. /** @hidden */
  79203. _numBonesWithLinkedTransformNode: number;
  79204. /** @hidden */
  79205. _hasWaitingData: Nullable<boolean>;
  79206. /**
  79207. * Specifies if the skeleton should be serialized
  79208. */
  79209. doNotSerialize: boolean;
  79210. private _useTextureToStoreBoneMatrices;
  79211. /**
  79212. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79213. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  79214. */
  79215. useTextureToStoreBoneMatrices: boolean;
  79216. private _animationPropertiesOverride;
  79217. /**
  79218. * Gets or sets the animation properties override
  79219. */
  79220. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79221. /**
  79222. * List of inspectable custom properties (used by the Inspector)
  79223. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79224. */
  79225. inspectableCustomProperties: IInspectable[];
  79226. /**
  79227. * An observable triggered before computing the skeleton's matrices
  79228. */
  79229. onBeforeComputeObservable: Observable<Skeleton>;
  79230. /**
  79231. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79232. */
  79233. readonly isUsingTextureForMatrices: boolean;
  79234. /**
  79235. * Gets the unique ID of this skeleton
  79236. */
  79237. readonly uniqueId: number;
  79238. /**
  79239. * Creates a new skeleton
  79240. * @param name defines the skeleton name
  79241. * @param id defines the skeleton Id
  79242. * @param scene defines the hosting scene
  79243. */
  79244. constructor(
  79245. /** defines the skeleton name */
  79246. name: string,
  79247. /** defines the skeleton Id */
  79248. id: string, scene: Scene);
  79249. /**
  79250. * Gets the current object class name.
  79251. * @return the class name
  79252. */
  79253. getClassName(): string;
  79254. /**
  79255. * Returns an array containing the root bones
  79256. * @returns an array containing the root bones
  79257. */
  79258. getChildren(): Array<Bone>;
  79259. /**
  79260. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79261. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79262. * @returns a Float32Array containing matrices data
  79263. */
  79264. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79265. /**
  79266. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79267. * @returns a raw texture containing the data
  79268. */
  79269. getTransformMatrixTexture(): Nullable<RawTexture>;
  79270. /**
  79271. * Gets the current hosting scene
  79272. * @returns a scene object
  79273. */
  79274. getScene(): Scene;
  79275. /**
  79276. * Gets a string representing the current skeleton data
  79277. * @param fullDetails defines a boolean indicating if we want a verbose version
  79278. * @returns a string representing the current skeleton data
  79279. */
  79280. toString(fullDetails?: boolean): string;
  79281. /**
  79282. * Get bone's index searching by name
  79283. * @param name defines bone's name to search for
  79284. * @return the indice of the bone. Returns -1 if not found
  79285. */
  79286. getBoneIndexByName(name: string): number;
  79287. /**
  79288. * Creater a new animation range
  79289. * @param name defines the name of the range
  79290. * @param from defines the start key
  79291. * @param to defines the end key
  79292. */
  79293. createAnimationRange(name: string, from: number, to: number): void;
  79294. /**
  79295. * Delete a specific animation range
  79296. * @param name defines the name of the range
  79297. * @param deleteFrames defines if frames must be removed as well
  79298. */
  79299. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79300. /**
  79301. * Gets a specific animation range
  79302. * @param name defines the name of the range to look for
  79303. * @returns the requested animation range or null if not found
  79304. */
  79305. getAnimationRange(name: string): Nullable<AnimationRange>;
  79306. /**
  79307. * Gets the list of all animation ranges defined on this skeleton
  79308. * @returns an array
  79309. */
  79310. getAnimationRanges(): Nullable<AnimationRange>[];
  79311. /**
  79312. * Copy animation range from a source skeleton.
  79313. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79314. * @param source defines the source skeleton
  79315. * @param name defines the name of the range to copy
  79316. * @param rescaleAsRequired defines if rescaling must be applied if required
  79317. * @returns true if operation was successful
  79318. */
  79319. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79320. /**
  79321. * Forces the skeleton to go to rest pose
  79322. */
  79323. returnToRest(): void;
  79324. private _getHighestAnimationFrame;
  79325. /**
  79326. * Begin a specific animation range
  79327. * @param name defines the name of the range to start
  79328. * @param loop defines if looping must be turned on (false by default)
  79329. * @param speedRatio defines the speed ratio to apply (1 by default)
  79330. * @param onAnimationEnd defines a callback which will be called when animation will end
  79331. * @returns a new animatable
  79332. */
  79333. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79334. /** @hidden */
  79335. _markAsDirty(): void;
  79336. /** @hidden */
  79337. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79338. /** @hidden */
  79339. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79340. private _computeTransformMatrices;
  79341. /**
  79342. * Build all resources required to render a skeleton
  79343. */
  79344. prepare(): void;
  79345. /**
  79346. * Gets the list of animatables currently running for this skeleton
  79347. * @returns an array of animatables
  79348. */
  79349. getAnimatables(): IAnimatable[];
  79350. /**
  79351. * Clone the current skeleton
  79352. * @param name defines the name of the new skeleton
  79353. * @param id defines the id of the new skeleton
  79354. * @returns the new skeleton
  79355. */
  79356. clone(name: string, id: string): Skeleton;
  79357. /**
  79358. * Enable animation blending for this skeleton
  79359. * @param blendingSpeed defines the blending speed to apply
  79360. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79361. */
  79362. enableBlending(blendingSpeed?: number): void;
  79363. /**
  79364. * Releases all resources associated with the current skeleton
  79365. */
  79366. dispose(): void;
  79367. /**
  79368. * Serialize the skeleton in a JSON object
  79369. * @returns a JSON object
  79370. */
  79371. serialize(): any;
  79372. /**
  79373. * Creates a new skeleton from serialized data
  79374. * @param parsedSkeleton defines the serialized data
  79375. * @param scene defines the hosting scene
  79376. * @returns a new skeleton
  79377. */
  79378. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79379. /**
  79380. * Compute all node absolute transforms
  79381. * @param forceUpdate defines if computation must be done even if cache is up to date
  79382. */
  79383. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79384. /**
  79385. * Gets the root pose matrix
  79386. * @returns a matrix
  79387. */
  79388. getPoseMatrix(): Nullable<Matrix>;
  79389. /**
  79390. * Sorts bones per internal index
  79391. */
  79392. sortBones(): void;
  79393. private _sortBones;
  79394. }
  79395. }
  79396. declare module BABYLON {
  79397. /**
  79398. * Defines a target to use with MorphTargetManager
  79399. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79400. */
  79401. export class MorphTarget implements IAnimatable {
  79402. /** defines the name of the target */
  79403. name: string;
  79404. /**
  79405. * Gets or sets the list of animations
  79406. */
  79407. animations: Animation[];
  79408. private _scene;
  79409. private _positions;
  79410. private _normals;
  79411. private _tangents;
  79412. private _influence;
  79413. /**
  79414. * Observable raised when the influence changes
  79415. */
  79416. onInfluenceChanged: Observable<boolean>;
  79417. /** @hidden */
  79418. _onDataLayoutChanged: Observable<void>;
  79419. /**
  79420. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  79421. */
  79422. influence: number;
  79423. /**
  79424. * Gets or sets the id of the morph Target
  79425. */
  79426. id: string;
  79427. private _animationPropertiesOverride;
  79428. /**
  79429. * Gets or sets the animation properties override
  79430. */
  79431. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79432. /**
  79433. * Creates a new MorphTarget
  79434. * @param name defines the name of the target
  79435. * @param influence defines the influence to use
  79436. * @param scene defines the scene the morphtarget belongs to
  79437. */
  79438. constructor(
  79439. /** defines the name of the target */
  79440. name: string, influence?: number, scene?: Nullable<Scene>);
  79441. /**
  79442. * Gets a boolean defining if the target contains position data
  79443. */
  79444. readonly hasPositions: boolean;
  79445. /**
  79446. * Gets a boolean defining if the target contains normal data
  79447. */
  79448. readonly hasNormals: boolean;
  79449. /**
  79450. * Gets a boolean defining if the target contains tangent data
  79451. */
  79452. readonly hasTangents: boolean;
  79453. /**
  79454. * Affects position data to this target
  79455. * @param data defines the position data to use
  79456. */
  79457. setPositions(data: Nullable<FloatArray>): void;
  79458. /**
  79459. * Gets the position data stored in this target
  79460. * @returns a FloatArray containing the position data (or null if not present)
  79461. */
  79462. getPositions(): Nullable<FloatArray>;
  79463. /**
  79464. * Affects normal data to this target
  79465. * @param data defines the normal data to use
  79466. */
  79467. setNormals(data: Nullable<FloatArray>): void;
  79468. /**
  79469. * Gets the normal data stored in this target
  79470. * @returns a FloatArray containing the normal data (or null if not present)
  79471. */
  79472. getNormals(): Nullable<FloatArray>;
  79473. /**
  79474. * Affects tangent data to this target
  79475. * @param data defines the tangent data to use
  79476. */
  79477. setTangents(data: Nullable<FloatArray>): void;
  79478. /**
  79479. * Gets the tangent data stored in this target
  79480. * @returns a FloatArray containing the tangent data (or null if not present)
  79481. */
  79482. getTangents(): Nullable<FloatArray>;
  79483. /**
  79484. * Serializes the current target into a Serialization object
  79485. * @returns the serialized object
  79486. */
  79487. serialize(): any;
  79488. /**
  79489. * Returns the string "MorphTarget"
  79490. * @returns "MorphTarget"
  79491. */
  79492. getClassName(): string;
  79493. /**
  79494. * Creates a new target from serialized data
  79495. * @param serializationObject defines the serialized data to use
  79496. * @returns a new MorphTarget
  79497. */
  79498. static Parse(serializationObject: any): MorphTarget;
  79499. /**
  79500. * Creates a MorphTarget from mesh data
  79501. * @param mesh defines the source mesh
  79502. * @param name defines the name to use for the new target
  79503. * @param influence defines the influence to attach to the target
  79504. * @returns a new MorphTarget
  79505. */
  79506. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  79507. }
  79508. }
  79509. declare module BABYLON {
  79510. /**
  79511. * This class is used to deform meshes using morphing between different targets
  79512. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79513. */
  79514. export class MorphTargetManager {
  79515. private _targets;
  79516. private _targetInfluenceChangedObservers;
  79517. private _targetDataLayoutChangedObservers;
  79518. private _activeTargets;
  79519. private _scene;
  79520. private _influences;
  79521. private _supportsNormals;
  79522. private _supportsTangents;
  79523. private _vertexCount;
  79524. private _uniqueId;
  79525. private _tempInfluences;
  79526. /**
  79527. * Creates a new MorphTargetManager
  79528. * @param scene defines the current scene
  79529. */
  79530. constructor(scene?: Nullable<Scene>);
  79531. /**
  79532. * Gets the unique ID of this manager
  79533. */
  79534. readonly uniqueId: number;
  79535. /**
  79536. * Gets the number of vertices handled by this manager
  79537. */
  79538. readonly vertexCount: number;
  79539. /**
  79540. * Gets a boolean indicating if this manager supports morphing of normals
  79541. */
  79542. readonly supportsNormals: boolean;
  79543. /**
  79544. * Gets a boolean indicating if this manager supports morphing of tangents
  79545. */
  79546. readonly supportsTangents: boolean;
  79547. /**
  79548. * Gets the number of targets stored in this manager
  79549. */
  79550. readonly numTargets: number;
  79551. /**
  79552. * Gets the number of influencers (ie. the number of targets with influences > 0)
  79553. */
  79554. readonly numInfluencers: number;
  79555. /**
  79556. * Gets the list of influences (one per target)
  79557. */
  79558. readonly influences: Float32Array;
  79559. /**
  79560. * Gets the active target at specified index. An active target is a target with an influence > 0
  79561. * @param index defines the index to check
  79562. * @returns the requested target
  79563. */
  79564. getActiveTarget(index: number): MorphTarget;
  79565. /**
  79566. * Gets the target at specified index
  79567. * @param index defines the index to check
  79568. * @returns the requested target
  79569. */
  79570. getTarget(index: number): MorphTarget;
  79571. /**
  79572. * Add a new target to this manager
  79573. * @param target defines the target to add
  79574. */
  79575. addTarget(target: MorphTarget): void;
  79576. /**
  79577. * Removes a target from the manager
  79578. * @param target defines the target to remove
  79579. */
  79580. removeTarget(target: MorphTarget): void;
  79581. /**
  79582. * Serializes the current manager into a Serialization object
  79583. * @returns the serialized object
  79584. */
  79585. serialize(): any;
  79586. private _syncActiveTargets;
  79587. /**
  79588. * Syncrhonize the targets with all the meshes using this morph target manager
  79589. */
  79590. synchronize(): void;
  79591. /**
  79592. * Creates a new MorphTargetManager from serialized data
  79593. * @param serializationObject defines the serialized data
  79594. * @param scene defines the hosting scene
  79595. * @returns the new MorphTargetManager
  79596. */
  79597. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  79598. }
  79599. }
  79600. declare module BABYLON {
  79601. /**
  79602. * Class used to represent a specific level of detail of a mesh
  79603. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79604. */
  79605. export class MeshLODLevel {
  79606. /** Defines the distance where this level should star being displayed */
  79607. distance: number;
  79608. /** Defines the mesh to use to render this level */
  79609. mesh: Nullable<Mesh>;
  79610. /**
  79611. * Creates a new LOD level
  79612. * @param distance defines the distance where this level should star being displayed
  79613. * @param mesh defines the mesh to use to render this level
  79614. */
  79615. constructor(
  79616. /** Defines the distance where this level should star being displayed */
  79617. distance: number,
  79618. /** Defines the mesh to use to render this level */
  79619. mesh: Nullable<Mesh>);
  79620. }
  79621. }
  79622. declare module BABYLON {
  79623. /**
  79624. * Mesh representing the gorund
  79625. */
  79626. export class GroundMesh extends Mesh {
  79627. /** If octree should be generated */
  79628. generateOctree: boolean;
  79629. private _heightQuads;
  79630. /** @hidden */
  79631. _subdivisionsX: number;
  79632. /** @hidden */
  79633. _subdivisionsY: number;
  79634. /** @hidden */
  79635. _width: number;
  79636. /** @hidden */
  79637. _height: number;
  79638. /** @hidden */
  79639. _minX: number;
  79640. /** @hidden */
  79641. _maxX: number;
  79642. /** @hidden */
  79643. _minZ: number;
  79644. /** @hidden */
  79645. _maxZ: number;
  79646. constructor(name: string, scene: Scene);
  79647. /**
  79648. * "GroundMesh"
  79649. * @returns "GroundMesh"
  79650. */
  79651. getClassName(): string;
  79652. /**
  79653. * The minimum of x and y subdivisions
  79654. */
  79655. readonly subdivisions: number;
  79656. /**
  79657. * X subdivisions
  79658. */
  79659. readonly subdivisionsX: number;
  79660. /**
  79661. * Y subdivisions
  79662. */
  79663. readonly subdivisionsY: number;
  79664. /**
  79665. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  79666. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  79667. * @param chunksCount the number of subdivisions for x and y
  79668. * @param octreeBlocksSize (Default: 32)
  79669. */
  79670. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  79671. /**
  79672. * Returns a height (y) value in the Worl system :
  79673. * the ground altitude at the coordinates (x, z) expressed in the World system.
  79674. * @param x x coordinate
  79675. * @param z z coordinate
  79676. * @returns the ground y position if (x, z) are outside the ground surface.
  79677. */
  79678. getHeightAtCoordinates(x: number, z: number): number;
  79679. /**
  79680. * Returns a normalized vector (Vector3) orthogonal to the ground
  79681. * at the ground coordinates (x, z) expressed in the World system.
  79682. * @param x x coordinate
  79683. * @param z z coordinate
  79684. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  79685. */
  79686. getNormalAtCoordinates(x: number, z: number): Vector3;
  79687. /**
  79688. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  79689. * at the ground coordinates (x, z) expressed in the World system.
  79690. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  79691. * @param x x coordinate
  79692. * @param z z coordinate
  79693. * @param ref vector to store the result
  79694. * @returns the GroundMesh.
  79695. */
  79696. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  79697. /**
  79698. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  79699. * if the ground has been updated.
  79700. * This can be used in the render loop.
  79701. * @returns the GroundMesh.
  79702. */
  79703. updateCoordinateHeights(): GroundMesh;
  79704. private _getFacetAt;
  79705. private _initHeightQuads;
  79706. private _computeHeightQuads;
  79707. /**
  79708. * Serializes this ground mesh
  79709. * @param serializationObject object to write serialization to
  79710. */
  79711. serialize(serializationObject: any): void;
  79712. /**
  79713. * Parses a serialized ground mesh
  79714. * @param parsedMesh the serialized mesh
  79715. * @param scene the scene to create the ground mesh in
  79716. * @returns the created ground mesh
  79717. */
  79718. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  79719. }
  79720. }
  79721. declare module BABYLON {
  79722. /**
  79723. * Interface for Physics-Joint data
  79724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79725. */
  79726. export interface PhysicsJointData {
  79727. /**
  79728. * The main pivot of the joint
  79729. */
  79730. mainPivot?: Vector3;
  79731. /**
  79732. * The connected pivot of the joint
  79733. */
  79734. connectedPivot?: Vector3;
  79735. /**
  79736. * The main axis of the joint
  79737. */
  79738. mainAxis?: Vector3;
  79739. /**
  79740. * The connected axis of the joint
  79741. */
  79742. connectedAxis?: Vector3;
  79743. /**
  79744. * The collision of the joint
  79745. */
  79746. collision?: boolean;
  79747. /**
  79748. * Native Oimo/Cannon/Energy data
  79749. */
  79750. nativeParams?: any;
  79751. }
  79752. /**
  79753. * This is a holder class for the physics joint created by the physics plugin
  79754. * It holds a set of functions to control the underlying joint
  79755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79756. */
  79757. export class PhysicsJoint {
  79758. /**
  79759. * The type of the physics joint
  79760. */
  79761. type: number;
  79762. /**
  79763. * The data for the physics joint
  79764. */
  79765. jointData: PhysicsJointData;
  79766. private _physicsJoint;
  79767. protected _physicsPlugin: IPhysicsEnginePlugin;
  79768. /**
  79769. * Initializes the physics joint
  79770. * @param type The type of the physics joint
  79771. * @param jointData The data for the physics joint
  79772. */
  79773. constructor(
  79774. /**
  79775. * The type of the physics joint
  79776. */
  79777. type: number,
  79778. /**
  79779. * The data for the physics joint
  79780. */
  79781. jointData: PhysicsJointData);
  79782. /**
  79783. * Gets the physics joint
  79784. */
  79785. /**
  79786. * Sets the physics joint
  79787. */
  79788. physicsJoint: any;
  79789. /**
  79790. * Sets the physics plugin
  79791. */
  79792. physicsPlugin: IPhysicsEnginePlugin;
  79793. /**
  79794. * Execute a function that is physics-plugin specific.
  79795. * @param {Function} func the function that will be executed.
  79796. * It accepts two parameters: the physics world and the physics joint
  79797. */
  79798. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  79799. /**
  79800. * Distance-Joint type
  79801. */
  79802. static DistanceJoint: number;
  79803. /**
  79804. * Hinge-Joint type
  79805. */
  79806. static HingeJoint: number;
  79807. /**
  79808. * Ball-and-Socket joint type
  79809. */
  79810. static BallAndSocketJoint: number;
  79811. /**
  79812. * Wheel-Joint type
  79813. */
  79814. static WheelJoint: number;
  79815. /**
  79816. * Slider-Joint type
  79817. */
  79818. static SliderJoint: number;
  79819. /**
  79820. * Prismatic-Joint type
  79821. */
  79822. static PrismaticJoint: number;
  79823. /**
  79824. * Universal-Joint type
  79825. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  79826. */
  79827. static UniversalJoint: number;
  79828. /**
  79829. * Hinge-Joint 2 type
  79830. */
  79831. static Hinge2Joint: number;
  79832. /**
  79833. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  79834. */
  79835. static PointToPointJoint: number;
  79836. /**
  79837. * Spring-Joint type
  79838. */
  79839. static SpringJoint: number;
  79840. /**
  79841. * Lock-Joint type
  79842. */
  79843. static LockJoint: number;
  79844. }
  79845. /**
  79846. * A class representing a physics distance joint
  79847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79848. */
  79849. export class DistanceJoint extends PhysicsJoint {
  79850. /**
  79851. *
  79852. * @param jointData The data for the Distance-Joint
  79853. */
  79854. constructor(jointData: DistanceJointData);
  79855. /**
  79856. * Update the predefined distance.
  79857. * @param maxDistance The maximum preferred distance
  79858. * @param minDistance The minimum preferred distance
  79859. */
  79860. updateDistance(maxDistance: number, minDistance?: number): void;
  79861. }
  79862. /**
  79863. * Represents a Motor-Enabled Joint
  79864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79865. */
  79866. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  79867. /**
  79868. * Initializes the Motor-Enabled Joint
  79869. * @param type The type of the joint
  79870. * @param jointData The physica joint data for the joint
  79871. */
  79872. constructor(type: number, jointData: PhysicsJointData);
  79873. /**
  79874. * Set the motor values.
  79875. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79876. * @param force the force to apply
  79877. * @param maxForce max force for this motor.
  79878. */
  79879. setMotor(force?: number, maxForce?: number): void;
  79880. /**
  79881. * Set the motor's limits.
  79882. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79883. * @param upperLimit The upper limit of the motor
  79884. * @param lowerLimit The lower limit of the motor
  79885. */
  79886. setLimit(upperLimit: number, lowerLimit?: number): void;
  79887. }
  79888. /**
  79889. * This class represents a single physics Hinge-Joint
  79890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79891. */
  79892. export class HingeJoint extends MotorEnabledJoint {
  79893. /**
  79894. * Initializes the Hinge-Joint
  79895. * @param jointData The joint data for the Hinge-Joint
  79896. */
  79897. constructor(jointData: PhysicsJointData);
  79898. /**
  79899. * Set the motor values.
  79900. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79901. * @param {number} force the force to apply
  79902. * @param {number} maxForce max force for this motor.
  79903. */
  79904. setMotor(force?: number, maxForce?: number): void;
  79905. /**
  79906. * Set the motor's limits.
  79907. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79908. * @param upperLimit The upper limit of the motor
  79909. * @param lowerLimit The lower limit of the motor
  79910. */
  79911. setLimit(upperLimit: number, lowerLimit?: number): void;
  79912. }
  79913. /**
  79914. * This class represents a dual hinge physics joint (same as wheel joint)
  79915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79916. */
  79917. export class Hinge2Joint extends MotorEnabledJoint {
  79918. /**
  79919. * Initializes the Hinge2-Joint
  79920. * @param jointData The joint data for the Hinge2-Joint
  79921. */
  79922. constructor(jointData: PhysicsJointData);
  79923. /**
  79924. * Set the motor values.
  79925. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79926. * @param {number} targetSpeed the speed the motor is to reach
  79927. * @param {number} maxForce max force for this motor.
  79928. * @param {motorIndex} the motor's index, 0 or 1.
  79929. */
  79930. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  79931. /**
  79932. * Set the motor limits.
  79933. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79934. * @param {number} upperLimit the upper limit
  79935. * @param {number} lowerLimit lower limit
  79936. * @param {motorIndex} the motor's index, 0 or 1.
  79937. */
  79938. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79939. }
  79940. /**
  79941. * Interface for a motor enabled joint
  79942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79943. */
  79944. export interface IMotorEnabledJoint {
  79945. /**
  79946. * Physics joint
  79947. */
  79948. physicsJoint: any;
  79949. /**
  79950. * Sets the motor of the motor-enabled joint
  79951. * @param force The force of the motor
  79952. * @param maxForce The maximum force of the motor
  79953. * @param motorIndex The index of the motor
  79954. */
  79955. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  79956. /**
  79957. * Sets the limit of the motor
  79958. * @param upperLimit The upper limit of the motor
  79959. * @param lowerLimit The lower limit of the motor
  79960. * @param motorIndex The index of the motor
  79961. */
  79962. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79963. }
  79964. /**
  79965. * Joint data for a Distance-Joint
  79966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79967. */
  79968. export interface DistanceJointData extends PhysicsJointData {
  79969. /**
  79970. * Max distance the 2 joint objects can be apart
  79971. */
  79972. maxDistance: number;
  79973. }
  79974. /**
  79975. * Joint data from a spring joint
  79976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79977. */
  79978. export interface SpringJointData extends PhysicsJointData {
  79979. /**
  79980. * Length of the spring
  79981. */
  79982. length: number;
  79983. /**
  79984. * Stiffness of the spring
  79985. */
  79986. stiffness: number;
  79987. /**
  79988. * Damping of the spring
  79989. */
  79990. damping: number;
  79991. /** this callback will be called when applying the force to the impostors. */
  79992. forceApplicationCallback: () => void;
  79993. }
  79994. }
  79995. declare module BABYLON {
  79996. /**
  79997. * Holds the data for the raycast result
  79998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79999. */
  80000. export class PhysicsRaycastResult {
  80001. private _hasHit;
  80002. private _hitDistance;
  80003. private _hitNormalWorld;
  80004. private _hitPointWorld;
  80005. private _rayFromWorld;
  80006. private _rayToWorld;
  80007. /**
  80008. * Gets if there was a hit
  80009. */
  80010. readonly hasHit: boolean;
  80011. /**
  80012. * Gets the distance from the hit
  80013. */
  80014. readonly hitDistance: number;
  80015. /**
  80016. * Gets the hit normal/direction in the world
  80017. */
  80018. readonly hitNormalWorld: Vector3;
  80019. /**
  80020. * Gets the hit point in the world
  80021. */
  80022. readonly hitPointWorld: Vector3;
  80023. /**
  80024. * Gets the ray "start point" of the ray in the world
  80025. */
  80026. readonly rayFromWorld: Vector3;
  80027. /**
  80028. * Gets the ray "end point" of the ray in the world
  80029. */
  80030. readonly rayToWorld: Vector3;
  80031. /**
  80032. * Sets the hit data (normal & point in world space)
  80033. * @param hitNormalWorld defines the normal in world space
  80034. * @param hitPointWorld defines the point in world space
  80035. */
  80036. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  80037. /**
  80038. * Sets the distance from the start point to the hit point
  80039. * @param distance
  80040. */
  80041. setHitDistance(distance: number): void;
  80042. /**
  80043. * Calculates the distance manually
  80044. */
  80045. calculateHitDistance(): void;
  80046. /**
  80047. * Resets all the values to default
  80048. * @param from The from point on world space
  80049. * @param to The to point on world space
  80050. */
  80051. reset(from?: Vector3, to?: Vector3): void;
  80052. }
  80053. /**
  80054. * Interface for the size containing width and height
  80055. */
  80056. interface IXYZ {
  80057. /**
  80058. * X
  80059. */
  80060. x: number;
  80061. /**
  80062. * Y
  80063. */
  80064. y: number;
  80065. /**
  80066. * Z
  80067. */
  80068. z: number;
  80069. }
  80070. }
  80071. declare module BABYLON {
  80072. /**
  80073. * Interface used to describe a physics joint
  80074. */
  80075. export interface PhysicsImpostorJoint {
  80076. /** Defines the main impostor to which the joint is linked */
  80077. mainImpostor: PhysicsImpostor;
  80078. /** Defines the impostor that is connected to the main impostor using this joint */
  80079. connectedImpostor: PhysicsImpostor;
  80080. /** Defines the joint itself */
  80081. joint: PhysicsJoint;
  80082. }
  80083. /** @hidden */
  80084. export interface IPhysicsEnginePlugin {
  80085. world: any;
  80086. name: string;
  80087. setGravity(gravity: Vector3): void;
  80088. setTimeStep(timeStep: number): void;
  80089. getTimeStep(): number;
  80090. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  80091. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  80092. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  80093. generatePhysicsBody(impostor: PhysicsImpostor): void;
  80094. removePhysicsBody(impostor: PhysicsImpostor): void;
  80095. generateJoint(joint: PhysicsImpostorJoint): void;
  80096. removeJoint(joint: PhysicsImpostorJoint): void;
  80097. isSupported(): boolean;
  80098. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  80099. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  80100. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  80101. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  80102. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  80103. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  80104. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  80105. getBodyMass(impostor: PhysicsImpostor): number;
  80106. getBodyFriction(impostor: PhysicsImpostor): number;
  80107. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  80108. getBodyRestitution(impostor: PhysicsImpostor): number;
  80109. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  80110. getBodyPressure?(impostor: PhysicsImpostor): number;
  80111. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  80112. getBodyStiffness?(impostor: PhysicsImpostor): number;
  80113. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  80114. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  80115. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  80116. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  80117. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  80118. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80119. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80120. sleepBody(impostor: PhysicsImpostor): void;
  80121. wakeUpBody(impostor: PhysicsImpostor): void;
  80122. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80123. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  80124. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  80125. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  80126. getRadius(impostor: PhysicsImpostor): number;
  80127. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  80128. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  80129. dispose(): void;
  80130. }
  80131. /**
  80132. * Interface used to define a physics engine
  80133. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  80134. */
  80135. export interface IPhysicsEngine {
  80136. /**
  80137. * Gets the gravity vector used by the simulation
  80138. */
  80139. gravity: Vector3;
  80140. /**
  80141. * Sets the gravity vector used by the simulation
  80142. * @param gravity defines the gravity vector to use
  80143. */
  80144. setGravity(gravity: Vector3): void;
  80145. /**
  80146. * Set the time step of the physics engine.
  80147. * Default is 1/60.
  80148. * To slow it down, enter 1/600 for example.
  80149. * To speed it up, 1/30
  80150. * @param newTimeStep the new timestep to apply to this world.
  80151. */
  80152. setTimeStep(newTimeStep: number): void;
  80153. /**
  80154. * Get the time step of the physics engine.
  80155. * @returns the current time step
  80156. */
  80157. getTimeStep(): number;
  80158. /**
  80159. * Release all resources
  80160. */
  80161. dispose(): void;
  80162. /**
  80163. * Gets the name of the current physics plugin
  80164. * @returns the name of the plugin
  80165. */
  80166. getPhysicsPluginName(): string;
  80167. /**
  80168. * Adding a new impostor for the impostor tracking.
  80169. * This will be done by the impostor itself.
  80170. * @param impostor the impostor to add
  80171. */
  80172. addImpostor(impostor: PhysicsImpostor): void;
  80173. /**
  80174. * Remove an impostor from the engine.
  80175. * This impostor and its mesh will not longer be updated by the physics engine.
  80176. * @param impostor the impostor to remove
  80177. */
  80178. removeImpostor(impostor: PhysicsImpostor): void;
  80179. /**
  80180. * Add a joint to the physics engine
  80181. * @param mainImpostor defines the main impostor to which the joint is added.
  80182. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  80183. * @param joint defines the joint that will connect both impostors.
  80184. */
  80185. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80186. /**
  80187. * Removes a joint from the simulation
  80188. * @param mainImpostor defines the impostor used with the joint
  80189. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  80190. * @param joint defines the joint to remove
  80191. */
  80192. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80193. /**
  80194. * Gets the current plugin used to run the simulation
  80195. * @returns current plugin
  80196. */
  80197. getPhysicsPlugin(): IPhysicsEnginePlugin;
  80198. /**
  80199. * Gets the list of physic impostors
  80200. * @returns an array of PhysicsImpostor
  80201. */
  80202. getImpostors(): Array<PhysicsImpostor>;
  80203. /**
  80204. * Gets the impostor for a physics enabled object
  80205. * @param object defines the object impersonated by the impostor
  80206. * @returns the PhysicsImpostor or null if not found
  80207. */
  80208. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80209. /**
  80210. * Gets the impostor for a physics body object
  80211. * @param body defines physics body used by the impostor
  80212. * @returns the PhysicsImpostor or null if not found
  80213. */
  80214. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  80215. /**
  80216. * Does a raycast in the physics world
  80217. * @param from when should the ray start?
  80218. * @param to when should the ray end?
  80219. * @returns PhysicsRaycastResult
  80220. */
  80221. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80222. /**
  80223. * Called by the scene. No need to call it.
  80224. * @param delta defines the timespam between frames
  80225. */
  80226. _step(delta: number): void;
  80227. }
  80228. }
  80229. declare module BABYLON {
  80230. /**
  80231. * The interface for the physics imposter parameters
  80232. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80233. */
  80234. export interface PhysicsImpostorParameters {
  80235. /**
  80236. * The mass of the physics imposter
  80237. */
  80238. mass: number;
  80239. /**
  80240. * The friction of the physics imposter
  80241. */
  80242. friction?: number;
  80243. /**
  80244. * The coefficient of restitution of the physics imposter
  80245. */
  80246. restitution?: number;
  80247. /**
  80248. * The native options of the physics imposter
  80249. */
  80250. nativeOptions?: any;
  80251. /**
  80252. * Specifies if the parent should be ignored
  80253. */
  80254. ignoreParent?: boolean;
  80255. /**
  80256. * Specifies if bi-directional transformations should be disabled
  80257. */
  80258. disableBidirectionalTransformation?: boolean;
  80259. /**
  80260. * The pressure inside the physics imposter, soft object only
  80261. */
  80262. pressure?: number;
  80263. /**
  80264. * The stiffness the physics imposter, soft object only
  80265. */
  80266. stiffness?: number;
  80267. /**
  80268. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  80269. */
  80270. velocityIterations?: number;
  80271. /**
  80272. * The number of iterations used in maintaining consistent vertex positions, soft object only
  80273. */
  80274. positionIterations?: number;
  80275. /**
  80276. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  80277. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  80278. * Add to fix multiple points
  80279. */
  80280. fixedPoints?: number;
  80281. /**
  80282. * The collision margin around a soft object
  80283. */
  80284. margin?: number;
  80285. /**
  80286. * The collision margin around a soft object
  80287. */
  80288. damping?: number;
  80289. /**
  80290. * The path for a rope based on an extrusion
  80291. */
  80292. path?: any;
  80293. /**
  80294. * The shape of an extrusion used for a rope based on an extrusion
  80295. */
  80296. shape?: any;
  80297. }
  80298. /**
  80299. * Interface for a physics-enabled object
  80300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80301. */
  80302. export interface IPhysicsEnabledObject {
  80303. /**
  80304. * The position of the physics-enabled object
  80305. */
  80306. position: Vector3;
  80307. /**
  80308. * The rotation of the physics-enabled object
  80309. */
  80310. rotationQuaternion: Nullable<Quaternion>;
  80311. /**
  80312. * The scale of the physics-enabled object
  80313. */
  80314. scaling: Vector3;
  80315. /**
  80316. * The rotation of the physics-enabled object
  80317. */
  80318. rotation?: Vector3;
  80319. /**
  80320. * The parent of the physics-enabled object
  80321. */
  80322. parent?: any;
  80323. /**
  80324. * The bounding info of the physics-enabled object
  80325. * @returns The bounding info of the physics-enabled object
  80326. */
  80327. getBoundingInfo(): BoundingInfo;
  80328. /**
  80329. * Computes the world matrix
  80330. * @param force Specifies if the world matrix should be computed by force
  80331. * @returns A world matrix
  80332. */
  80333. computeWorldMatrix(force: boolean): Matrix;
  80334. /**
  80335. * Gets the world matrix
  80336. * @returns A world matrix
  80337. */
  80338. getWorldMatrix?(): Matrix;
  80339. /**
  80340. * Gets the child meshes
  80341. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  80342. * @returns An array of abstract meshes
  80343. */
  80344. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  80345. /**
  80346. * Gets the vertex data
  80347. * @param kind The type of vertex data
  80348. * @returns A nullable array of numbers, or a float32 array
  80349. */
  80350. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  80351. /**
  80352. * Gets the indices from the mesh
  80353. * @returns A nullable array of index arrays
  80354. */
  80355. getIndices?(): Nullable<IndicesArray>;
  80356. /**
  80357. * Gets the scene from the mesh
  80358. * @returns the indices array or null
  80359. */
  80360. getScene?(): Scene;
  80361. /**
  80362. * Gets the absolute position from the mesh
  80363. * @returns the absolute position
  80364. */
  80365. getAbsolutePosition(): Vector3;
  80366. /**
  80367. * Gets the absolute pivot point from the mesh
  80368. * @returns the absolute pivot point
  80369. */
  80370. getAbsolutePivotPoint(): Vector3;
  80371. /**
  80372. * Rotates the mesh
  80373. * @param axis The axis of rotation
  80374. * @param amount The amount of rotation
  80375. * @param space The space of the rotation
  80376. * @returns The rotation transform node
  80377. */
  80378. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80379. /**
  80380. * Translates the mesh
  80381. * @param axis The axis of translation
  80382. * @param distance The distance of translation
  80383. * @param space The space of the translation
  80384. * @returns The transform node
  80385. */
  80386. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80387. /**
  80388. * Sets the absolute position of the mesh
  80389. * @param absolutePosition The absolute position of the mesh
  80390. * @returns The transform node
  80391. */
  80392. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80393. /**
  80394. * Gets the class name of the mesh
  80395. * @returns The class name
  80396. */
  80397. getClassName(): string;
  80398. }
  80399. /**
  80400. * Represents a physics imposter
  80401. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80402. */
  80403. export class PhysicsImpostor {
  80404. /**
  80405. * The physics-enabled object used as the physics imposter
  80406. */
  80407. object: IPhysicsEnabledObject;
  80408. /**
  80409. * The type of the physics imposter
  80410. */
  80411. type: number;
  80412. private _options;
  80413. private _scene?;
  80414. /**
  80415. * The default object size of the imposter
  80416. */
  80417. static DEFAULT_OBJECT_SIZE: Vector3;
  80418. /**
  80419. * The identity quaternion of the imposter
  80420. */
  80421. static IDENTITY_QUATERNION: Quaternion;
  80422. /** @hidden */
  80423. _pluginData: any;
  80424. private _physicsEngine;
  80425. private _physicsBody;
  80426. private _bodyUpdateRequired;
  80427. private _onBeforePhysicsStepCallbacks;
  80428. private _onAfterPhysicsStepCallbacks;
  80429. /** @hidden */
  80430. _onPhysicsCollideCallbacks: Array<{
  80431. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  80432. otherImpostors: Array<PhysicsImpostor>;
  80433. }>;
  80434. private _deltaPosition;
  80435. private _deltaRotation;
  80436. private _deltaRotationConjugated;
  80437. /** hidden */
  80438. _isFromLine: boolean;
  80439. private _parent;
  80440. private _isDisposed;
  80441. private static _tmpVecs;
  80442. private static _tmpQuat;
  80443. /**
  80444. * Specifies if the physics imposter is disposed
  80445. */
  80446. readonly isDisposed: boolean;
  80447. /**
  80448. * Gets the mass of the physics imposter
  80449. */
  80450. mass: number;
  80451. /**
  80452. * Gets the coefficient of friction
  80453. */
  80454. /**
  80455. * Sets the coefficient of friction
  80456. */
  80457. friction: number;
  80458. /**
  80459. * Gets the coefficient of restitution
  80460. */
  80461. /**
  80462. * Sets the coefficient of restitution
  80463. */
  80464. restitution: number;
  80465. /**
  80466. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  80467. */
  80468. /**
  80469. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  80470. */
  80471. pressure: number;
  80472. /**
  80473. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80474. */
  80475. /**
  80476. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80477. */
  80478. stiffness: number;
  80479. /**
  80480. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80481. */
  80482. /**
  80483. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80484. */
  80485. velocityIterations: number;
  80486. /**
  80487. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80488. */
  80489. /**
  80490. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80491. */
  80492. positionIterations: number;
  80493. /**
  80494. * The unique id of the physics imposter
  80495. * set by the physics engine when adding this impostor to the array
  80496. */
  80497. uniqueId: number;
  80498. /**
  80499. * @hidden
  80500. */
  80501. soft: boolean;
  80502. /**
  80503. * @hidden
  80504. */
  80505. segments: number;
  80506. private _joints;
  80507. /**
  80508. * Initializes the physics imposter
  80509. * @param object The physics-enabled object used as the physics imposter
  80510. * @param type The type of the physics imposter
  80511. * @param _options The options for the physics imposter
  80512. * @param _scene The Babylon scene
  80513. */
  80514. constructor(
  80515. /**
  80516. * The physics-enabled object used as the physics imposter
  80517. */
  80518. object: IPhysicsEnabledObject,
  80519. /**
  80520. * The type of the physics imposter
  80521. */
  80522. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  80523. /**
  80524. * This function will completly initialize this impostor.
  80525. * It will create a new body - but only if this mesh has no parent.
  80526. * If it has, this impostor will not be used other than to define the impostor
  80527. * of the child mesh.
  80528. * @hidden
  80529. */
  80530. _init(): void;
  80531. private _getPhysicsParent;
  80532. /**
  80533. * Should a new body be generated.
  80534. * @returns boolean specifying if body initialization is required
  80535. */
  80536. isBodyInitRequired(): boolean;
  80537. /**
  80538. * Sets the updated scaling
  80539. * @param updated Specifies if the scaling is updated
  80540. */
  80541. setScalingUpdated(): void;
  80542. /**
  80543. * Force a regeneration of this or the parent's impostor's body.
  80544. * Use under cautious - This will remove all joints already implemented.
  80545. */
  80546. forceUpdate(): void;
  80547. /**
  80548. * Gets the body that holds this impostor. Either its own, or its parent.
  80549. */
  80550. /**
  80551. * Set the physics body. Used mainly by the physics engine/plugin
  80552. */
  80553. physicsBody: any;
  80554. /**
  80555. * Get the parent of the physics imposter
  80556. * @returns Physics imposter or null
  80557. */
  80558. /**
  80559. * Sets the parent of the physics imposter
  80560. */
  80561. parent: Nullable<PhysicsImpostor>;
  80562. /**
  80563. * Resets the update flags
  80564. */
  80565. resetUpdateFlags(): void;
  80566. /**
  80567. * Gets the object extend size
  80568. * @returns the object extend size
  80569. */
  80570. getObjectExtendSize(): Vector3;
  80571. /**
  80572. * Gets the object center
  80573. * @returns The object center
  80574. */
  80575. getObjectCenter(): Vector3;
  80576. /**
  80577. * Get a specific parametes from the options parameter
  80578. * @param paramName The object parameter name
  80579. * @returns The object parameter
  80580. */
  80581. getParam(paramName: string): any;
  80582. /**
  80583. * Sets a specific parameter in the options given to the physics plugin
  80584. * @param paramName The parameter name
  80585. * @param value The value of the parameter
  80586. */
  80587. setParam(paramName: string, value: number): void;
  80588. /**
  80589. * Specifically change the body's mass option. Won't recreate the physics body object
  80590. * @param mass The mass of the physics imposter
  80591. */
  80592. setMass(mass: number): void;
  80593. /**
  80594. * Gets the linear velocity
  80595. * @returns linear velocity or null
  80596. */
  80597. getLinearVelocity(): Nullable<Vector3>;
  80598. /**
  80599. * Sets the linear velocity
  80600. * @param velocity linear velocity or null
  80601. */
  80602. setLinearVelocity(velocity: Nullable<Vector3>): void;
  80603. /**
  80604. * Gets the angular velocity
  80605. * @returns angular velocity or null
  80606. */
  80607. getAngularVelocity(): Nullable<Vector3>;
  80608. /**
  80609. * Sets the angular velocity
  80610. * @param velocity The velocity or null
  80611. */
  80612. setAngularVelocity(velocity: Nullable<Vector3>): void;
  80613. /**
  80614. * Execute a function with the physics plugin native code
  80615. * Provide a function the will have two variables - the world object and the physics body object
  80616. * @param func The function to execute with the physics plugin native code
  80617. */
  80618. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  80619. /**
  80620. * Register a function that will be executed before the physics world is stepping forward
  80621. * @param func The function to execute before the physics world is stepped forward
  80622. */
  80623. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80624. /**
  80625. * Unregister a function that will be executed before the physics world is stepping forward
  80626. * @param func The function to execute before the physics world is stepped forward
  80627. */
  80628. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80629. /**
  80630. * Register a function that will be executed after the physics step
  80631. * @param func The function to execute after physics step
  80632. */
  80633. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80634. /**
  80635. * Unregisters a function that will be executed after the physics step
  80636. * @param func The function to execute after physics step
  80637. */
  80638. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80639. /**
  80640. * register a function that will be executed when this impostor collides against a different body
  80641. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  80642. * @param func Callback that is executed on collision
  80643. */
  80644. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  80645. /**
  80646. * Unregisters the physics imposter on contact
  80647. * @param collideAgainst The physics object to collide against
  80648. * @param func Callback to execute on collision
  80649. */
  80650. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  80651. private _tmpQuat;
  80652. private _tmpQuat2;
  80653. /**
  80654. * Get the parent rotation
  80655. * @returns The parent rotation
  80656. */
  80657. getParentsRotation(): Quaternion;
  80658. /**
  80659. * this function is executed by the physics engine.
  80660. */
  80661. beforeStep: () => void;
  80662. /**
  80663. * this function is executed by the physics engine
  80664. */
  80665. afterStep: () => void;
  80666. /**
  80667. * Legacy collision detection event support
  80668. */
  80669. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  80670. /**
  80671. * event and body object due to cannon's event-based architecture.
  80672. */
  80673. onCollide: (e: {
  80674. body: any;
  80675. }) => void;
  80676. /**
  80677. * Apply a force
  80678. * @param force The force to apply
  80679. * @param contactPoint The contact point for the force
  80680. * @returns The physics imposter
  80681. */
  80682. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80683. /**
  80684. * Apply an impulse
  80685. * @param force The impulse force
  80686. * @param contactPoint The contact point for the impulse force
  80687. * @returns The physics imposter
  80688. */
  80689. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80690. /**
  80691. * A help function to create a joint
  80692. * @param otherImpostor A physics imposter used to create a joint
  80693. * @param jointType The type of joint
  80694. * @param jointData The data for the joint
  80695. * @returns The physics imposter
  80696. */
  80697. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  80698. /**
  80699. * Add a joint to this impostor with a different impostor
  80700. * @param otherImpostor A physics imposter used to add a joint
  80701. * @param joint The joint to add
  80702. * @returns The physics imposter
  80703. */
  80704. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  80705. /**
  80706. * Add an anchor to a cloth impostor
  80707. * @param otherImpostor rigid impostor to anchor to
  80708. * @param width ratio across width from 0 to 1
  80709. * @param height ratio up height from 0 to 1
  80710. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  80711. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  80712. * @returns impostor the soft imposter
  80713. */
  80714. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80715. /**
  80716. * Add a hook to a rope impostor
  80717. * @param otherImpostor rigid impostor to anchor to
  80718. * @param length ratio across rope from 0 to 1
  80719. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  80720. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  80721. * @returns impostor the rope imposter
  80722. */
  80723. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80724. /**
  80725. * Will keep this body still, in a sleep mode.
  80726. * @returns the physics imposter
  80727. */
  80728. sleep(): PhysicsImpostor;
  80729. /**
  80730. * Wake the body up.
  80731. * @returns The physics imposter
  80732. */
  80733. wakeUp(): PhysicsImpostor;
  80734. /**
  80735. * Clones the physics imposter
  80736. * @param newObject The physics imposter clones to this physics-enabled object
  80737. * @returns A nullable physics imposter
  80738. */
  80739. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80740. /**
  80741. * Disposes the physics imposter
  80742. */
  80743. dispose(): void;
  80744. /**
  80745. * Sets the delta position
  80746. * @param position The delta position amount
  80747. */
  80748. setDeltaPosition(position: Vector3): void;
  80749. /**
  80750. * Sets the delta rotation
  80751. * @param rotation The delta rotation amount
  80752. */
  80753. setDeltaRotation(rotation: Quaternion): void;
  80754. /**
  80755. * Gets the box size of the physics imposter and stores the result in the input parameter
  80756. * @param result Stores the box size
  80757. * @returns The physics imposter
  80758. */
  80759. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  80760. /**
  80761. * Gets the radius of the physics imposter
  80762. * @returns Radius of the physics imposter
  80763. */
  80764. getRadius(): number;
  80765. /**
  80766. * Sync a bone with this impostor
  80767. * @param bone The bone to sync to the impostor.
  80768. * @param boneMesh The mesh that the bone is influencing.
  80769. * @param jointPivot The pivot of the joint / bone in local space.
  80770. * @param distToJoint Optional distance from the impostor to the joint.
  80771. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80772. */
  80773. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  80774. /**
  80775. * Sync impostor to a bone
  80776. * @param bone The bone that the impostor will be synced to.
  80777. * @param boneMesh The mesh that the bone is influencing.
  80778. * @param jointPivot The pivot of the joint / bone in local space.
  80779. * @param distToJoint Optional distance from the impostor to the joint.
  80780. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80781. * @param boneAxis Optional vector3 axis the bone is aligned with
  80782. */
  80783. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  80784. /**
  80785. * No-Imposter type
  80786. */
  80787. static NoImpostor: number;
  80788. /**
  80789. * Sphere-Imposter type
  80790. */
  80791. static SphereImpostor: number;
  80792. /**
  80793. * Box-Imposter type
  80794. */
  80795. static BoxImpostor: number;
  80796. /**
  80797. * Plane-Imposter type
  80798. */
  80799. static PlaneImpostor: number;
  80800. /**
  80801. * Mesh-imposter type
  80802. */
  80803. static MeshImpostor: number;
  80804. /**
  80805. * Cylinder-Imposter type
  80806. */
  80807. static CylinderImpostor: number;
  80808. /**
  80809. * Particle-Imposter type
  80810. */
  80811. static ParticleImpostor: number;
  80812. /**
  80813. * Heightmap-Imposter type
  80814. */
  80815. static HeightmapImpostor: number;
  80816. /**
  80817. * ConvexHull-Impostor type (Ammo.js plugin only)
  80818. */
  80819. static ConvexHullImpostor: number;
  80820. /**
  80821. * Rope-Imposter type
  80822. */
  80823. static RopeImpostor: number;
  80824. /**
  80825. * Cloth-Imposter type
  80826. */
  80827. static ClothImpostor: number;
  80828. /**
  80829. * Softbody-Imposter type
  80830. */
  80831. static SoftbodyImpostor: number;
  80832. }
  80833. }
  80834. declare module BABYLON {
  80835. /**
  80836. * @hidden
  80837. **/
  80838. export class _CreationDataStorage {
  80839. closePath?: boolean;
  80840. closeArray?: boolean;
  80841. idx: number[];
  80842. dashSize: number;
  80843. gapSize: number;
  80844. path3D: Path3D;
  80845. pathArray: Vector3[][];
  80846. arc: number;
  80847. radius: number;
  80848. cap: number;
  80849. tessellation: number;
  80850. }
  80851. /**
  80852. * @hidden
  80853. **/
  80854. class _InstanceDataStorage {
  80855. visibleInstances: any;
  80856. batchCache: _InstancesBatch;
  80857. instancesBufferSize: number;
  80858. instancesBuffer: Nullable<Buffer>;
  80859. instancesData: Float32Array;
  80860. overridenInstanceCount: number;
  80861. isFrozen: boolean;
  80862. previousBatch: _InstancesBatch;
  80863. hardwareInstancedRendering: boolean;
  80864. sideOrientation: number;
  80865. }
  80866. /**
  80867. * @hidden
  80868. **/
  80869. export class _InstancesBatch {
  80870. mustReturn: boolean;
  80871. visibleInstances: Nullable<InstancedMesh[]>[];
  80872. renderSelf: boolean[];
  80873. hardwareInstancedRendering: boolean[];
  80874. }
  80875. /**
  80876. * Class used to represent renderable models
  80877. */
  80878. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  80879. /**
  80880. * Mesh side orientation : usually the external or front surface
  80881. */
  80882. static readonly FRONTSIDE: number;
  80883. /**
  80884. * Mesh side orientation : usually the internal or back surface
  80885. */
  80886. static readonly BACKSIDE: number;
  80887. /**
  80888. * Mesh side orientation : both internal and external or front and back surfaces
  80889. */
  80890. static readonly DOUBLESIDE: number;
  80891. /**
  80892. * Mesh side orientation : by default, `FRONTSIDE`
  80893. */
  80894. static readonly DEFAULTSIDE: number;
  80895. /**
  80896. * Mesh cap setting : no cap
  80897. */
  80898. static readonly NO_CAP: number;
  80899. /**
  80900. * Mesh cap setting : one cap at the beginning of the mesh
  80901. */
  80902. static readonly CAP_START: number;
  80903. /**
  80904. * Mesh cap setting : one cap at the end of the mesh
  80905. */
  80906. static readonly CAP_END: number;
  80907. /**
  80908. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  80909. */
  80910. static readonly CAP_ALL: number;
  80911. /**
  80912. * Gets the default side orientation.
  80913. * @param orientation the orientation to value to attempt to get
  80914. * @returns the default orientation
  80915. * @hidden
  80916. */
  80917. static _GetDefaultSideOrientation(orientation?: number): number;
  80918. private _internalMeshDataInfo;
  80919. /**
  80920. * An event triggered before rendering the mesh
  80921. */
  80922. readonly onBeforeRenderObservable: Observable<Mesh>;
  80923. /**
  80924. * An event triggered before binding the mesh
  80925. */
  80926. readonly onBeforeBindObservable: Observable<Mesh>;
  80927. /**
  80928. * An event triggered after rendering the mesh
  80929. */
  80930. readonly onAfterRenderObservable: Observable<Mesh>;
  80931. /**
  80932. * An event triggered before drawing the mesh
  80933. */
  80934. readonly onBeforeDrawObservable: Observable<Mesh>;
  80935. private _onBeforeDrawObserver;
  80936. /**
  80937. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  80938. */
  80939. onBeforeDraw: () => void;
  80940. /**
  80941. * Gets the delay loading state of the mesh (when delay loading is turned on)
  80942. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  80943. */
  80944. delayLoadState: number;
  80945. /**
  80946. * Gets the list of instances created from this mesh
  80947. * it is not supposed to be modified manually.
  80948. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  80949. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80950. */
  80951. instances: InstancedMesh[];
  80952. /**
  80953. * Gets the file containing delay loading data for this mesh
  80954. */
  80955. delayLoadingFile: string;
  80956. /** @hidden */
  80957. _binaryInfo: any;
  80958. /**
  80959. * User defined function used to change how LOD level selection is done
  80960. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80961. */
  80962. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  80963. /**
  80964. * Gets or sets the morph target manager
  80965. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  80966. */
  80967. morphTargetManager: Nullable<MorphTargetManager>;
  80968. /** @hidden */
  80969. _creationDataStorage: Nullable<_CreationDataStorage>;
  80970. /** @hidden */
  80971. _geometry: Nullable<Geometry>;
  80972. /** @hidden */
  80973. _delayInfo: Array<string>;
  80974. /** @hidden */
  80975. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  80976. /** @hidden */
  80977. _instanceDataStorage: _InstanceDataStorage;
  80978. private _effectiveMaterial;
  80979. /** @hidden */
  80980. _shouldGenerateFlatShading: boolean;
  80981. /** @hidden */
  80982. _originalBuilderSideOrientation: number;
  80983. /**
  80984. * Use this property to change the original side orientation defined at construction time
  80985. */
  80986. overrideMaterialSideOrientation: Nullable<number>;
  80987. /**
  80988. * Gets the source mesh (the one used to clone this one from)
  80989. */
  80990. readonly source: Nullable<Mesh>;
  80991. /**
  80992. * Gets or sets a boolean indicating that this mesh does not use index buffer
  80993. */
  80994. isUnIndexed: boolean;
  80995. /**
  80996. * @constructor
  80997. * @param name The value used by scene.getMeshByName() to do a lookup.
  80998. * @param scene The scene to add this mesh to.
  80999. * @param parent The parent of this mesh, if it has one
  81000. * @param source An optional Mesh from which geometry is shared, cloned.
  81001. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  81002. * When false, achieved by calling a clone(), also passing False.
  81003. * This will make creation of children, recursive.
  81004. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  81005. */
  81006. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  81007. /**
  81008. * Gets the class name
  81009. * @returns the string "Mesh".
  81010. */
  81011. getClassName(): string;
  81012. /** @hidden */
  81013. readonly _isMesh: boolean;
  81014. /**
  81015. * Returns a description of this mesh
  81016. * @param fullDetails define if full details about this mesh must be used
  81017. * @returns a descriptive string representing this mesh
  81018. */
  81019. toString(fullDetails?: boolean): string;
  81020. /** @hidden */
  81021. _unBindEffect(): void;
  81022. /**
  81023. * Gets a boolean indicating if this mesh has LOD
  81024. */
  81025. readonly hasLODLevels: boolean;
  81026. /**
  81027. * Gets the list of MeshLODLevel associated with the current mesh
  81028. * @returns an array of MeshLODLevel
  81029. */
  81030. getLODLevels(): MeshLODLevel[];
  81031. private _sortLODLevels;
  81032. /**
  81033. * Add a mesh as LOD level triggered at the given distance.
  81034. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  81035. * @param distance The distance from the center of the object to show this level
  81036. * @param mesh The mesh to be added as LOD level (can be null)
  81037. * @return This mesh (for chaining)
  81038. */
  81039. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  81040. /**
  81041. * Returns the LOD level mesh at the passed distance or null if not found.
  81042. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  81043. * @param distance The distance from the center of the object to show this level
  81044. * @returns a Mesh or `null`
  81045. */
  81046. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  81047. /**
  81048. * Remove a mesh from the LOD array
  81049. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  81050. * @param mesh defines the mesh to be removed
  81051. * @return This mesh (for chaining)
  81052. */
  81053. removeLODLevel(mesh: Mesh): Mesh;
  81054. /**
  81055. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  81056. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  81057. * @param camera defines the camera to use to compute distance
  81058. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  81059. * @return This mesh (for chaining)
  81060. */
  81061. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  81062. /**
  81063. * Gets the mesh internal Geometry object
  81064. */
  81065. readonly geometry: Nullable<Geometry>;
  81066. /**
  81067. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  81068. * @returns the total number of vertices
  81069. */
  81070. getTotalVertices(): number;
  81071. /**
  81072. * Returns the content of an associated vertex buffer
  81073. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81074. * - VertexBuffer.PositionKind
  81075. * - VertexBuffer.UVKind
  81076. * - VertexBuffer.UV2Kind
  81077. * - VertexBuffer.UV3Kind
  81078. * - VertexBuffer.UV4Kind
  81079. * - VertexBuffer.UV5Kind
  81080. * - VertexBuffer.UV6Kind
  81081. * - VertexBuffer.ColorKind
  81082. * - VertexBuffer.MatricesIndicesKind
  81083. * - VertexBuffer.MatricesIndicesExtraKind
  81084. * - VertexBuffer.MatricesWeightsKind
  81085. * - VertexBuffer.MatricesWeightsExtraKind
  81086. * @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
  81087. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  81088. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  81089. */
  81090. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81091. /**
  81092. * Returns the mesh VertexBuffer object from the requested `kind`
  81093. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81094. * - VertexBuffer.PositionKind
  81095. * - VertexBuffer.UVKind
  81096. * - VertexBuffer.UV2Kind
  81097. * - VertexBuffer.UV3Kind
  81098. * - VertexBuffer.UV4Kind
  81099. * - VertexBuffer.UV5Kind
  81100. * - VertexBuffer.UV6Kind
  81101. * - VertexBuffer.ColorKind
  81102. * - VertexBuffer.MatricesIndicesKind
  81103. * - VertexBuffer.MatricesIndicesExtraKind
  81104. * - VertexBuffer.MatricesWeightsKind
  81105. * - VertexBuffer.MatricesWeightsExtraKind
  81106. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  81107. */
  81108. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81109. /**
  81110. * Tests if a specific vertex buffer is associated with this mesh
  81111. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81112. * - VertexBuffer.PositionKind
  81113. * - VertexBuffer.UVKind
  81114. * - VertexBuffer.UV2Kind
  81115. * - VertexBuffer.UV3Kind
  81116. * - VertexBuffer.UV4Kind
  81117. * - VertexBuffer.UV5Kind
  81118. * - VertexBuffer.UV6Kind
  81119. * - VertexBuffer.ColorKind
  81120. * - VertexBuffer.MatricesIndicesKind
  81121. * - VertexBuffer.MatricesIndicesExtraKind
  81122. * - VertexBuffer.MatricesWeightsKind
  81123. * - VertexBuffer.MatricesWeightsExtraKind
  81124. * @returns a boolean
  81125. */
  81126. isVerticesDataPresent(kind: string): boolean;
  81127. /**
  81128. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  81129. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81130. * - VertexBuffer.PositionKind
  81131. * - VertexBuffer.UVKind
  81132. * - VertexBuffer.UV2Kind
  81133. * - VertexBuffer.UV3Kind
  81134. * - VertexBuffer.UV4Kind
  81135. * - VertexBuffer.UV5Kind
  81136. * - VertexBuffer.UV6Kind
  81137. * - VertexBuffer.ColorKind
  81138. * - VertexBuffer.MatricesIndicesKind
  81139. * - VertexBuffer.MatricesIndicesExtraKind
  81140. * - VertexBuffer.MatricesWeightsKind
  81141. * - VertexBuffer.MatricesWeightsExtraKind
  81142. * @returns a boolean
  81143. */
  81144. isVertexBufferUpdatable(kind: string): boolean;
  81145. /**
  81146. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  81147. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81148. * - VertexBuffer.PositionKind
  81149. * - VertexBuffer.UVKind
  81150. * - VertexBuffer.UV2Kind
  81151. * - VertexBuffer.UV3Kind
  81152. * - VertexBuffer.UV4Kind
  81153. * - VertexBuffer.UV5Kind
  81154. * - VertexBuffer.UV6Kind
  81155. * - VertexBuffer.ColorKind
  81156. * - VertexBuffer.MatricesIndicesKind
  81157. * - VertexBuffer.MatricesIndicesExtraKind
  81158. * - VertexBuffer.MatricesWeightsKind
  81159. * - VertexBuffer.MatricesWeightsExtraKind
  81160. * @returns an array of strings
  81161. */
  81162. getVerticesDataKinds(): string[];
  81163. /**
  81164. * Returns a positive integer : the total number of indices in this mesh geometry.
  81165. * @returns the numner of indices or zero if the mesh has no geometry.
  81166. */
  81167. getTotalIndices(): number;
  81168. /**
  81169. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81170. * @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.
  81171. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81172. * @returns the indices array or an empty array if the mesh has no geometry
  81173. */
  81174. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81175. readonly isBlocked: boolean;
  81176. /**
  81177. * Determine if the current mesh is ready to be rendered
  81178. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81179. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  81180. * @returns true if all associated assets are ready (material, textures, shaders)
  81181. */
  81182. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  81183. /**
  81184. * 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.
  81185. */
  81186. readonly areNormalsFrozen: boolean;
  81187. /**
  81188. * 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.
  81189. * @returns the current mesh
  81190. */
  81191. freezeNormals(): Mesh;
  81192. /**
  81193. * 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
  81194. * @returns the current mesh
  81195. */
  81196. unfreezeNormals(): Mesh;
  81197. /**
  81198. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  81199. */
  81200. overridenInstanceCount: number;
  81201. /** @hidden */
  81202. _preActivate(): Mesh;
  81203. /** @hidden */
  81204. _preActivateForIntermediateRendering(renderId: number): Mesh;
  81205. /** @hidden */
  81206. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  81207. /**
  81208. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81209. * This means the mesh underlying bounding box and sphere are recomputed.
  81210. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81211. * @returns the current mesh
  81212. */
  81213. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  81214. /** @hidden */
  81215. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  81216. /**
  81217. * This function will subdivide the mesh into multiple submeshes
  81218. * @param count defines the expected number of submeshes
  81219. */
  81220. subdivide(count: number): void;
  81221. /**
  81222. * Copy a FloatArray into a specific associated vertex buffer
  81223. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81224. * - VertexBuffer.PositionKind
  81225. * - VertexBuffer.UVKind
  81226. * - VertexBuffer.UV2Kind
  81227. * - VertexBuffer.UV3Kind
  81228. * - VertexBuffer.UV4Kind
  81229. * - VertexBuffer.UV5Kind
  81230. * - VertexBuffer.UV6Kind
  81231. * - VertexBuffer.ColorKind
  81232. * - VertexBuffer.MatricesIndicesKind
  81233. * - VertexBuffer.MatricesIndicesExtraKind
  81234. * - VertexBuffer.MatricesWeightsKind
  81235. * - VertexBuffer.MatricesWeightsExtraKind
  81236. * @param data defines the data source
  81237. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81238. * @param stride defines the data stride size (can be null)
  81239. * @returns the current mesh
  81240. */
  81241. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  81242. /**
  81243. * Flags an associated vertex buffer as updatable
  81244. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  81245. * - VertexBuffer.PositionKind
  81246. * - VertexBuffer.UVKind
  81247. * - VertexBuffer.UV2Kind
  81248. * - VertexBuffer.UV3Kind
  81249. * - VertexBuffer.UV4Kind
  81250. * - VertexBuffer.UV5Kind
  81251. * - VertexBuffer.UV6Kind
  81252. * - VertexBuffer.ColorKind
  81253. * - VertexBuffer.MatricesIndicesKind
  81254. * - VertexBuffer.MatricesIndicesExtraKind
  81255. * - VertexBuffer.MatricesWeightsKind
  81256. * - VertexBuffer.MatricesWeightsExtraKind
  81257. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81258. */
  81259. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  81260. /**
  81261. * Sets the mesh global Vertex Buffer
  81262. * @param buffer defines the buffer to use
  81263. * @returns the current mesh
  81264. */
  81265. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  81266. /**
  81267. * Update a specific associated vertex buffer
  81268. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81269. * - VertexBuffer.PositionKind
  81270. * - VertexBuffer.UVKind
  81271. * - VertexBuffer.UV2Kind
  81272. * - VertexBuffer.UV3Kind
  81273. * - VertexBuffer.UV4Kind
  81274. * - VertexBuffer.UV5Kind
  81275. * - VertexBuffer.UV6Kind
  81276. * - VertexBuffer.ColorKind
  81277. * - VertexBuffer.MatricesIndicesKind
  81278. * - VertexBuffer.MatricesIndicesExtraKind
  81279. * - VertexBuffer.MatricesWeightsKind
  81280. * - VertexBuffer.MatricesWeightsExtraKind
  81281. * @param data defines the data source
  81282. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81283. * @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)
  81284. * @returns the current mesh
  81285. */
  81286. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  81287. /**
  81288. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  81289. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  81290. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  81291. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  81292. * @returns the current mesh
  81293. */
  81294. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  81295. /**
  81296. * Creates a un-shared specific occurence of the geometry for the mesh.
  81297. * @returns the current mesh
  81298. */
  81299. makeGeometryUnique(): Mesh;
  81300. /**
  81301. * Set the index buffer of this mesh
  81302. * @param indices defines the source data
  81303. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  81304. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  81305. * @returns the current mesh
  81306. */
  81307. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  81308. /**
  81309. * Update the current index buffer
  81310. * @param indices defines the source data
  81311. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81312. * @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)
  81313. * @returns the current mesh
  81314. */
  81315. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  81316. /**
  81317. * Invert the geometry to move from a right handed system to a left handed one.
  81318. * @returns the current mesh
  81319. */
  81320. toLeftHanded(): Mesh;
  81321. /** @hidden */
  81322. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  81323. /** @hidden */
  81324. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  81325. /**
  81326. * Registers for this mesh a javascript function called just before the rendering process
  81327. * @param func defines the function to call before rendering this mesh
  81328. * @returns the current mesh
  81329. */
  81330. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81331. /**
  81332. * Disposes a previously registered javascript function called before the rendering
  81333. * @param func defines the function to remove
  81334. * @returns the current mesh
  81335. */
  81336. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81337. /**
  81338. * Registers for this mesh a javascript function called just after the rendering is complete
  81339. * @param func defines the function to call after rendering this mesh
  81340. * @returns the current mesh
  81341. */
  81342. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81343. /**
  81344. * Disposes a previously registered javascript function called after the rendering.
  81345. * @param func defines the function to remove
  81346. * @returns the current mesh
  81347. */
  81348. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81349. /** @hidden */
  81350. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  81351. /** @hidden */
  81352. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  81353. /** @hidden */
  81354. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  81355. /** @hidden */
  81356. _freeze(): void;
  81357. /** @hidden */
  81358. _unFreeze(): void;
  81359. /**
  81360. * 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
  81361. * @param subMesh defines the subMesh to render
  81362. * @param enableAlphaMode defines if alpha mode can be changed
  81363. * @returns the current mesh
  81364. */
  81365. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  81366. private _onBeforeDraw;
  81367. /**
  81368. * Renormalize the mesh and patch it up if there are no weights
  81369. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  81370. * However in the case of zero weights then we set just a single influence to 1.
  81371. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  81372. */
  81373. cleanMatrixWeights(): void;
  81374. private normalizeSkinFourWeights;
  81375. private normalizeSkinWeightsAndExtra;
  81376. /**
  81377. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  81378. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  81379. * the user know there was an issue with importing the mesh
  81380. * @returns a validation object with skinned, valid and report string
  81381. */
  81382. validateSkinning(): {
  81383. skinned: boolean;
  81384. valid: boolean;
  81385. report: string;
  81386. };
  81387. /** @hidden */
  81388. _checkDelayState(): Mesh;
  81389. private _queueLoad;
  81390. /**
  81391. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81392. * A mesh is in the frustum if its bounding box intersects the frustum
  81393. * @param frustumPlanes defines the frustum to test
  81394. * @returns true if the mesh is in the frustum planes
  81395. */
  81396. isInFrustum(frustumPlanes: Plane[]): boolean;
  81397. /**
  81398. * Sets the mesh material by the material or multiMaterial `id` property
  81399. * @param id is a string identifying the material or the multiMaterial
  81400. * @returns the current mesh
  81401. */
  81402. setMaterialByID(id: string): Mesh;
  81403. /**
  81404. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  81405. * @returns an array of IAnimatable
  81406. */
  81407. getAnimatables(): IAnimatable[];
  81408. /**
  81409. * Modifies the mesh geometry according to the passed transformation matrix.
  81410. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  81411. * The mesh normals are modified using the same transformation.
  81412. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81413. * @param transform defines the transform matrix to use
  81414. * @see http://doc.babylonjs.com/resources/baking_transformations
  81415. * @returns the current mesh
  81416. */
  81417. bakeTransformIntoVertices(transform: Matrix): Mesh;
  81418. /**
  81419. * Modifies the mesh geometry according to its own current World Matrix.
  81420. * The mesh World Matrix is then reset.
  81421. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  81422. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81423. * @see http://doc.babylonjs.com/resources/baking_transformations
  81424. * @returns the current mesh
  81425. */
  81426. bakeCurrentTransformIntoVertices(): Mesh;
  81427. /** @hidden */
  81428. readonly _positions: Nullable<Vector3[]>;
  81429. /** @hidden */
  81430. _resetPointsArrayCache(): Mesh;
  81431. /** @hidden */
  81432. _generatePointsArray(): boolean;
  81433. /**
  81434. * Returns a new Mesh object generated from the current mesh properties.
  81435. * This method must not get confused with createInstance()
  81436. * @param name is a string, the name given to the new mesh
  81437. * @param newParent can be any Node object (default `null`)
  81438. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  81439. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  81440. * @returns a new mesh
  81441. */
  81442. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  81443. /**
  81444. * Releases resources associated with this mesh.
  81445. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81446. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81447. */
  81448. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81449. /**
  81450. * Modifies the mesh geometry according to a displacement map.
  81451. * 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.
  81452. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81453. * @param url is a string, the URL from the image file is to be downloaded.
  81454. * @param minHeight is the lower limit of the displacement.
  81455. * @param maxHeight is the upper limit of the displacement.
  81456. * @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.
  81457. * @param uvOffset is an optional vector2 used to offset UV.
  81458. * @param uvScale is an optional vector2 used to scale UV.
  81459. * @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.
  81460. * @returns the Mesh.
  81461. */
  81462. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81463. /**
  81464. * Modifies the mesh geometry according to a displacementMap buffer.
  81465. * 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.
  81466. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81467. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  81468. * @param heightMapWidth is the width of the buffer image.
  81469. * @param heightMapHeight is the height of the buffer image.
  81470. * @param minHeight is the lower limit of the displacement.
  81471. * @param maxHeight is the upper limit of the displacement.
  81472. * @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.
  81473. * @param uvOffset is an optional vector2 used to offset UV.
  81474. * @param uvScale is an optional vector2 used to scale UV.
  81475. * @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.
  81476. * @returns the Mesh.
  81477. */
  81478. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81479. /**
  81480. * Modify the mesh to get a flat shading rendering.
  81481. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  81482. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  81483. * @returns current mesh
  81484. */
  81485. convertToFlatShadedMesh(): Mesh;
  81486. /**
  81487. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  81488. * In other words, more vertices, no more indices and a single bigger VBO.
  81489. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  81490. * @returns current mesh
  81491. */
  81492. convertToUnIndexedMesh(): Mesh;
  81493. /**
  81494. * Inverses facet orientations.
  81495. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81496. * @param flipNormals will also inverts the normals
  81497. * @returns current mesh
  81498. */
  81499. flipFaces(flipNormals?: boolean): Mesh;
  81500. /**
  81501. * Increase the number of facets and hence vertices in a mesh
  81502. * Vertex normals are interpolated from existing vertex normals
  81503. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81504. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  81505. */
  81506. increaseVertices(numberPerEdge: number): void;
  81507. /**
  81508. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  81509. * This will undo any application of covertToFlatShadedMesh
  81510. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81511. */
  81512. forceSharedVertices(): void;
  81513. /** @hidden */
  81514. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  81515. /** @hidden */
  81516. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  81517. /**
  81518. * Creates a new InstancedMesh object from the mesh model.
  81519. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  81520. * @param name defines the name of the new instance
  81521. * @returns a new InstancedMesh
  81522. */
  81523. createInstance(name: string): InstancedMesh;
  81524. /**
  81525. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  81526. * After this call, all the mesh instances have the same submeshes than the current mesh.
  81527. * @returns the current mesh
  81528. */
  81529. synchronizeInstances(): Mesh;
  81530. /**
  81531. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  81532. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  81533. * This should be used together with the simplification to avoid disappearing triangles.
  81534. * @param successCallback an optional success callback to be called after the optimization finished.
  81535. * @returns the current mesh
  81536. */
  81537. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  81538. /**
  81539. * Serialize current mesh
  81540. * @param serializationObject defines the object which will receive the serialization data
  81541. */
  81542. serialize(serializationObject: any): void;
  81543. /** @hidden */
  81544. _syncGeometryWithMorphTargetManager(): void;
  81545. /** @hidden */
  81546. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  81547. /**
  81548. * Returns a new Mesh object parsed from the source provided.
  81549. * @param parsedMesh is the source
  81550. * @param scene defines the hosting scene
  81551. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  81552. * @returns a new Mesh
  81553. */
  81554. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  81555. /**
  81556. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  81557. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81558. * @param name defines the name of the mesh to create
  81559. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  81560. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  81561. * @param closePath creates a seam between the first and the last points of each path of the path array
  81562. * @param offset is taken in account only if the `pathArray` is containing a single path
  81563. * @param scene defines the hosting scene
  81564. * @param updatable defines if the mesh must be flagged as updatable
  81565. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81566. * @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)
  81567. * @returns a new Mesh
  81568. */
  81569. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81570. /**
  81571. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  81572. * @param name defines the name of the mesh to create
  81573. * @param radius sets the radius size (float) of the polygon (default 0.5)
  81574. * @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
  81575. * @param scene defines the hosting scene
  81576. * @param updatable defines if the mesh must be flagged as updatable
  81577. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81578. * @returns a new Mesh
  81579. */
  81580. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81581. /**
  81582. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  81583. * @param name defines the name of the mesh to create
  81584. * @param size sets the size (float) of each box side (default 1)
  81585. * @param scene defines the hosting scene
  81586. * @param updatable defines if the mesh must be flagged as updatable
  81587. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81588. * @returns a new Mesh
  81589. */
  81590. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81591. /**
  81592. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  81593. * @param name defines the name of the mesh to create
  81594. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81595. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81596. * @param scene defines the hosting scene
  81597. * @param updatable defines if the mesh must be flagged as updatable
  81598. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81599. * @returns a new Mesh
  81600. */
  81601. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81602. /**
  81603. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  81604. * @param name defines the name of the mesh to create
  81605. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81606. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81607. * @param scene defines the hosting scene
  81608. * @returns a new Mesh
  81609. */
  81610. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  81611. /**
  81612. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  81613. * @param name defines the name of the mesh to create
  81614. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  81615. * @param diameterTop set the top cap diameter (floats, default 1)
  81616. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  81617. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  81618. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  81619. * @param scene defines the hosting scene
  81620. * @param updatable defines if the mesh must be flagged as updatable
  81621. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81622. * @returns a new Mesh
  81623. */
  81624. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  81625. /**
  81626. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  81627. * @param name defines the name of the mesh to create
  81628. * @param diameter sets the diameter size (float) of the torus (default 1)
  81629. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  81630. * @param tessellation sets the number of torus sides (postive integer, default 16)
  81631. * @param scene defines the hosting scene
  81632. * @param updatable defines if the mesh must be flagged as updatable
  81633. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81634. * @returns a new Mesh
  81635. */
  81636. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81637. /**
  81638. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  81639. * @param name defines the name of the mesh to create
  81640. * @param radius sets the global radius size (float) of the torus knot (default 2)
  81641. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  81642. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  81643. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  81644. * @param p the number of windings on X axis (positive integers, default 2)
  81645. * @param q the number of windings on Y axis (positive integers, default 3)
  81646. * @param scene defines the hosting scene
  81647. * @param updatable defines if the mesh must be flagged as updatable
  81648. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81649. * @returns a new Mesh
  81650. */
  81651. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81652. /**
  81653. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  81654. * @param name defines the name of the mesh to create
  81655. * @param points is an array successive Vector3
  81656. * @param scene defines the hosting scene
  81657. * @param updatable defines if the mesh must be flagged as updatable
  81658. * @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).
  81659. * @returns a new Mesh
  81660. */
  81661. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  81662. /**
  81663. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  81664. * @param name defines the name of the mesh to create
  81665. * @param points is an array successive Vector3
  81666. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  81667. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  81668. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  81669. * @param scene defines the hosting scene
  81670. * @param updatable defines if the mesh must be flagged as updatable
  81671. * @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)
  81672. * @returns a new Mesh
  81673. */
  81674. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  81675. /**
  81676. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  81677. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  81678. * 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.
  81679. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81680. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81681. * Remember you can only change the shape positions, not their number when updating a polygon.
  81682. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  81683. * @param name defines the name of the mesh to create
  81684. * @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
  81685. * @param scene defines the hosting scene
  81686. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81687. * @param updatable defines if the mesh must be flagged as updatable
  81688. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81689. * @param earcutInjection can be used to inject your own earcut reference
  81690. * @returns a new Mesh
  81691. */
  81692. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81693. /**
  81694. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  81695. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  81696. * @param name defines the name of the mesh to create
  81697. * @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
  81698. * @param depth defines the height of extrusion
  81699. * @param scene defines the hosting scene
  81700. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81701. * @param updatable defines if the mesh must be flagged as updatable
  81702. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81703. * @param earcutInjection can be used to inject your own earcut reference
  81704. * @returns a new Mesh
  81705. */
  81706. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81707. /**
  81708. * Creates an extruded shape mesh.
  81709. * 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
  81710. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81711. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81712. * @param name defines the name of the mesh to create
  81713. * @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
  81714. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81715. * @param scale is the value to scale the shape
  81716. * @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
  81717. * @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
  81718. * @param scene defines the hosting scene
  81719. * @param updatable defines if the mesh must be flagged as updatable
  81720. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81721. * @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)
  81722. * @returns a new Mesh
  81723. */
  81724. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81725. /**
  81726. * Creates an custom extruded shape mesh.
  81727. * The custom extrusion is a parametric shape.
  81728. * It has no predefined shape. Its final shape will depend on the input parameters.
  81729. * Please consider using the same method from the MeshBuilder class instead
  81730. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81731. * @param name defines the name of the mesh to create
  81732. * @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
  81733. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81734. * @param scaleFunction is a custom Javascript function called on each path point
  81735. * @param rotationFunction is a custom Javascript function called on each path point
  81736. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  81737. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  81738. * @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
  81739. * @param scene defines the hosting scene
  81740. * @param updatable defines if the mesh must be flagged as updatable
  81741. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81742. * @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)
  81743. * @returns a new Mesh
  81744. */
  81745. 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;
  81746. /**
  81747. * Creates lathe mesh.
  81748. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  81749. * Please consider using the same method from the MeshBuilder class instead
  81750. * @param name defines the name of the mesh to create
  81751. * @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
  81752. * @param radius is the radius value of the lathe
  81753. * @param tessellation is the side number of the lathe.
  81754. * @param scene defines the hosting scene
  81755. * @param updatable defines if the mesh must be flagged as updatable
  81756. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81757. * @returns a new Mesh
  81758. */
  81759. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81760. /**
  81761. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  81762. * @param name defines the name of the mesh to create
  81763. * @param size sets the size (float) of both sides of the plane at once (default 1)
  81764. * @param scene defines the hosting scene
  81765. * @param updatable defines if the mesh must be flagged as updatable
  81766. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81767. * @returns a new Mesh
  81768. */
  81769. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81770. /**
  81771. * Creates a ground mesh.
  81772. * Please consider using the same method from the MeshBuilder class instead
  81773. * @param name defines the name of the mesh to create
  81774. * @param width set the width of the ground
  81775. * @param height set the height of the ground
  81776. * @param subdivisions sets the number of subdivisions per side
  81777. * @param scene defines the hosting scene
  81778. * @param updatable defines if the mesh must be flagged as updatable
  81779. * @returns a new Mesh
  81780. */
  81781. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  81782. /**
  81783. * Creates a tiled ground mesh.
  81784. * Please consider using the same method from the MeshBuilder class instead
  81785. * @param name defines the name of the mesh to create
  81786. * @param xmin set the ground minimum X coordinate
  81787. * @param zmin set the ground minimum Y coordinate
  81788. * @param xmax set the ground maximum X coordinate
  81789. * @param zmax set the ground maximum Z coordinate
  81790. * @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
  81791. * @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
  81792. * @param scene defines the hosting scene
  81793. * @param updatable defines if the mesh must be flagged as updatable
  81794. * @returns a new Mesh
  81795. */
  81796. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  81797. w: number;
  81798. h: number;
  81799. }, precision: {
  81800. w: number;
  81801. h: number;
  81802. }, scene: Scene, updatable?: boolean): Mesh;
  81803. /**
  81804. * Creates a ground mesh from a height map.
  81805. * Please consider using the same method from the MeshBuilder class instead
  81806. * @see http://doc.babylonjs.com/babylon101/height_map
  81807. * @param name defines the name of the mesh to create
  81808. * @param url sets the URL of the height map image resource
  81809. * @param width set the ground width size
  81810. * @param height set the ground height size
  81811. * @param subdivisions sets the number of subdivision per side
  81812. * @param minHeight is the minimum altitude on the ground
  81813. * @param maxHeight is the maximum altitude on the ground
  81814. * @param scene defines the hosting scene
  81815. * @param updatable defines if the mesh must be flagged as updatable
  81816. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  81817. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  81818. * @returns a new Mesh
  81819. */
  81820. 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;
  81821. /**
  81822. * Creates a tube mesh.
  81823. * The tube is a parametric shape.
  81824. * It has no predefined shape. Its final shape will depend on the input parameters.
  81825. * Please consider using the same method from the MeshBuilder class instead
  81826. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81827. * @param name defines the name of the mesh to create
  81828. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  81829. * @param radius sets the tube radius size
  81830. * @param tessellation is the number of sides on the tubular surface
  81831. * @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
  81832. * @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
  81833. * @param scene defines the hosting scene
  81834. * @param updatable defines if the mesh must be flagged as updatable
  81835. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81836. * @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)
  81837. * @returns a new Mesh
  81838. */
  81839. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  81840. (i: number, distance: number): number;
  81841. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81842. /**
  81843. * Creates a polyhedron mesh.
  81844. * Please consider using the same method from the MeshBuilder class instead.
  81845. * * 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
  81846. * * The parameter `size` (positive float, default 1) sets the polygon size
  81847. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  81848. * * 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`
  81849. * * 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
  81850. * * 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)`)
  81851. * * 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
  81852. * * 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
  81853. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81854. * * If you create a double-sided mesh, you can choose what parts of 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
  81855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81856. * @param name defines the name of the mesh to create
  81857. * @param options defines the options used to create the mesh
  81858. * @param scene defines the hosting scene
  81859. * @returns a new Mesh
  81860. */
  81861. static CreatePolyhedron(name: string, options: {
  81862. type?: number;
  81863. size?: number;
  81864. sizeX?: number;
  81865. sizeY?: number;
  81866. sizeZ?: number;
  81867. custom?: any;
  81868. faceUV?: Vector4[];
  81869. faceColors?: Color4[];
  81870. updatable?: boolean;
  81871. sideOrientation?: number;
  81872. }, scene: Scene): Mesh;
  81873. /**
  81874. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  81875. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  81876. * * 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`)
  81877. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  81878. * * 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
  81879. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81880. * * If you create a double-sided mesh, you can choose what parts of 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
  81881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81882. * @param name defines the name of the mesh
  81883. * @param options defines the options used to create the mesh
  81884. * @param scene defines the hosting scene
  81885. * @returns a new Mesh
  81886. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  81887. */
  81888. static CreateIcoSphere(name: string, options: {
  81889. radius?: number;
  81890. flat?: boolean;
  81891. subdivisions?: number;
  81892. sideOrientation?: number;
  81893. updatable?: boolean;
  81894. }, scene: Scene): Mesh;
  81895. /**
  81896. * Creates a decal mesh.
  81897. * Please consider using the same method from the MeshBuilder class instead.
  81898. * A decal is a mesh usually applied as a model onto the surface of another mesh
  81899. * @param name defines the name of the mesh
  81900. * @param sourceMesh defines the mesh receiving the decal
  81901. * @param position sets the position of the decal in world coordinates
  81902. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  81903. * @param size sets the decal scaling
  81904. * @param angle sets the angle to rotate the decal
  81905. * @returns a new Mesh
  81906. */
  81907. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  81908. /**
  81909. * Prepare internal position array for software CPU skinning
  81910. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  81911. */
  81912. setPositionsForCPUSkinning(): Float32Array;
  81913. /**
  81914. * Prepare internal normal array for software CPU skinning
  81915. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  81916. */
  81917. setNormalsForCPUSkinning(): Float32Array;
  81918. /**
  81919. * Updates the vertex buffer by applying transformation from the bones
  81920. * @param skeleton defines the skeleton to apply to current mesh
  81921. * @returns the current mesh
  81922. */
  81923. applySkeleton(skeleton: Skeleton): Mesh;
  81924. /**
  81925. * 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
  81926. * @param meshes defines the list of meshes to scan
  81927. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  81928. */
  81929. static MinMax(meshes: AbstractMesh[]): {
  81930. min: Vector3;
  81931. max: Vector3;
  81932. };
  81933. /**
  81934. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  81935. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  81936. * @returns a vector3
  81937. */
  81938. static Center(meshesOrMinMaxVector: {
  81939. min: Vector3;
  81940. max: Vector3;
  81941. } | AbstractMesh[]): Vector3;
  81942. /**
  81943. * Merge the array of meshes into a single mesh for performance reasons.
  81944. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  81945. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  81946. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  81947. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  81948. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  81949. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  81950. * @returns a new mesh
  81951. */
  81952. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  81953. /** @hidden */
  81954. addInstance(instance: InstancedMesh): void;
  81955. /** @hidden */
  81956. removeInstance(instance: InstancedMesh): void;
  81957. }
  81958. }
  81959. declare module BABYLON {
  81960. /**
  81961. * Base class for the main features of a material in Babylon.js
  81962. */
  81963. export class Material implements IAnimatable {
  81964. /**
  81965. * Returns the triangle fill mode
  81966. */
  81967. static readonly TriangleFillMode: number;
  81968. /**
  81969. * Returns the wireframe mode
  81970. */
  81971. static readonly WireFrameFillMode: number;
  81972. /**
  81973. * Returns the point fill mode
  81974. */
  81975. static readonly PointFillMode: number;
  81976. /**
  81977. * Returns the point list draw mode
  81978. */
  81979. static readonly PointListDrawMode: number;
  81980. /**
  81981. * Returns the line list draw mode
  81982. */
  81983. static readonly LineListDrawMode: number;
  81984. /**
  81985. * Returns the line loop draw mode
  81986. */
  81987. static readonly LineLoopDrawMode: number;
  81988. /**
  81989. * Returns the line strip draw mode
  81990. */
  81991. static readonly LineStripDrawMode: number;
  81992. /**
  81993. * Returns the triangle strip draw mode
  81994. */
  81995. static readonly TriangleStripDrawMode: number;
  81996. /**
  81997. * Returns the triangle fan draw mode
  81998. */
  81999. static readonly TriangleFanDrawMode: number;
  82000. /**
  82001. * Stores the clock-wise side orientation
  82002. */
  82003. static readonly ClockWiseSideOrientation: number;
  82004. /**
  82005. * Stores the counter clock-wise side orientation
  82006. */
  82007. static readonly CounterClockWiseSideOrientation: number;
  82008. /**
  82009. * The dirty texture flag value
  82010. */
  82011. static readonly TextureDirtyFlag: number;
  82012. /**
  82013. * The dirty light flag value
  82014. */
  82015. static readonly LightDirtyFlag: number;
  82016. /**
  82017. * The dirty fresnel flag value
  82018. */
  82019. static readonly FresnelDirtyFlag: number;
  82020. /**
  82021. * The dirty attribute flag value
  82022. */
  82023. static readonly AttributesDirtyFlag: number;
  82024. /**
  82025. * The dirty misc flag value
  82026. */
  82027. static readonly MiscDirtyFlag: number;
  82028. /**
  82029. * The all dirty flag value
  82030. */
  82031. static readonly AllDirtyFlag: number;
  82032. /**
  82033. * The ID of the material
  82034. */
  82035. id: string;
  82036. /**
  82037. * Gets or sets the unique id of the material
  82038. */
  82039. uniqueId: number;
  82040. /**
  82041. * The name of the material
  82042. */
  82043. name: string;
  82044. /**
  82045. * Gets or sets user defined metadata
  82046. */
  82047. metadata: any;
  82048. /**
  82049. * For internal use only. Please do not use.
  82050. */
  82051. reservedDataStore: any;
  82052. /**
  82053. * Specifies if the ready state should be checked on each call
  82054. */
  82055. checkReadyOnEveryCall: boolean;
  82056. /**
  82057. * Specifies if the ready state should be checked once
  82058. */
  82059. checkReadyOnlyOnce: boolean;
  82060. /**
  82061. * The state of the material
  82062. */
  82063. state: string;
  82064. /**
  82065. * The alpha value of the material
  82066. */
  82067. protected _alpha: number;
  82068. /**
  82069. * List of inspectable custom properties (used by the Inspector)
  82070. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82071. */
  82072. inspectableCustomProperties: IInspectable[];
  82073. /**
  82074. * Sets the alpha value of the material
  82075. */
  82076. /**
  82077. * Gets the alpha value of the material
  82078. */
  82079. alpha: number;
  82080. /**
  82081. * Specifies if back face culling is enabled
  82082. */
  82083. protected _backFaceCulling: boolean;
  82084. /**
  82085. * Sets the back-face culling state
  82086. */
  82087. /**
  82088. * Gets the back-face culling state
  82089. */
  82090. backFaceCulling: boolean;
  82091. /**
  82092. * Stores the value for side orientation
  82093. */
  82094. sideOrientation: number;
  82095. /**
  82096. * Callback triggered when the material is compiled
  82097. */
  82098. onCompiled: Nullable<(effect: Effect) => void>;
  82099. /**
  82100. * Callback triggered when an error occurs
  82101. */
  82102. onError: Nullable<(effect: Effect, errors: string) => void>;
  82103. /**
  82104. * Callback triggered to get the render target textures
  82105. */
  82106. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  82107. /**
  82108. * Gets a boolean indicating that current material needs to register RTT
  82109. */
  82110. readonly hasRenderTargetTextures: boolean;
  82111. /**
  82112. * Specifies if the material should be serialized
  82113. */
  82114. doNotSerialize: boolean;
  82115. /**
  82116. * @hidden
  82117. */
  82118. _storeEffectOnSubMeshes: boolean;
  82119. /**
  82120. * Stores the animations for the material
  82121. */
  82122. animations: Nullable<Array<Animation>>;
  82123. /**
  82124. * An event triggered when the material is disposed
  82125. */
  82126. onDisposeObservable: Observable<Material>;
  82127. /**
  82128. * An observer which watches for dispose events
  82129. */
  82130. private _onDisposeObserver;
  82131. private _onUnBindObservable;
  82132. /**
  82133. * Called during a dispose event
  82134. */
  82135. onDispose: () => void;
  82136. private _onBindObservable;
  82137. /**
  82138. * An event triggered when the material is bound
  82139. */
  82140. readonly onBindObservable: Observable<AbstractMesh>;
  82141. /**
  82142. * An observer which watches for bind events
  82143. */
  82144. private _onBindObserver;
  82145. /**
  82146. * Called during a bind event
  82147. */
  82148. onBind: (Mesh: AbstractMesh) => void;
  82149. /**
  82150. * An event triggered when the material is unbound
  82151. */
  82152. readonly onUnBindObservable: Observable<Material>;
  82153. /**
  82154. * Stores the value of the alpha mode
  82155. */
  82156. private _alphaMode;
  82157. /**
  82158. * Sets the value of the alpha mode.
  82159. *
  82160. * | Value | Type | Description |
  82161. * | --- | --- | --- |
  82162. * | 0 | ALPHA_DISABLE | |
  82163. * | 1 | ALPHA_ADD | |
  82164. * | 2 | ALPHA_COMBINE | |
  82165. * | 3 | ALPHA_SUBTRACT | |
  82166. * | 4 | ALPHA_MULTIPLY | |
  82167. * | 5 | ALPHA_MAXIMIZED | |
  82168. * | 6 | ALPHA_ONEONE | |
  82169. * | 7 | ALPHA_PREMULTIPLIED | |
  82170. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  82171. * | 9 | ALPHA_INTERPOLATE | |
  82172. * | 10 | ALPHA_SCREENMODE | |
  82173. *
  82174. */
  82175. /**
  82176. * Gets the value of the alpha mode
  82177. */
  82178. alphaMode: number;
  82179. /**
  82180. * Stores the state of the need depth pre-pass value
  82181. */
  82182. private _needDepthPrePass;
  82183. /**
  82184. * Sets the need depth pre-pass value
  82185. */
  82186. /**
  82187. * Gets the depth pre-pass value
  82188. */
  82189. needDepthPrePass: boolean;
  82190. /**
  82191. * Specifies if depth writing should be disabled
  82192. */
  82193. disableDepthWrite: boolean;
  82194. /**
  82195. * Specifies if depth writing should be forced
  82196. */
  82197. forceDepthWrite: boolean;
  82198. /**
  82199. * Specifies if there should be a separate pass for culling
  82200. */
  82201. separateCullingPass: boolean;
  82202. /**
  82203. * Stores the state specifing if fog should be enabled
  82204. */
  82205. private _fogEnabled;
  82206. /**
  82207. * Sets the state for enabling fog
  82208. */
  82209. /**
  82210. * Gets the value of the fog enabled state
  82211. */
  82212. fogEnabled: boolean;
  82213. /**
  82214. * Stores the size of points
  82215. */
  82216. pointSize: number;
  82217. /**
  82218. * Stores the z offset value
  82219. */
  82220. zOffset: number;
  82221. /**
  82222. * Gets a value specifying if wireframe mode is enabled
  82223. */
  82224. /**
  82225. * Sets the state of wireframe mode
  82226. */
  82227. wireframe: boolean;
  82228. /**
  82229. * Gets the value specifying if point clouds are enabled
  82230. */
  82231. /**
  82232. * Sets the state of point cloud mode
  82233. */
  82234. pointsCloud: boolean;
  82235. /**
  82236. * Gets the material fill mode
  82237. */
  82238. /**
  82239. * Sets the material fill mode
  82240. */
  82241. fillMode: number;
  82242. /**
  82243. * @hidden
  82244. * Stores the effects for the material
  82245. */
  82246. _effect: Nullable<Effect>;
  82247. /**
  82248. * @hidden
  82249. * Specifies if the material was previously ready
  82250. */
  82251. _wasPreviouslyReady: boolean;
  82252. /**
  82253. * Specifies if uniform buffers should be used
  82254. */
  82255. private _useUBO;
  82256. /**
  82257. * Stores a reference to the scene
  82258. */
  82259. private _scene;
  82260. /**
  82261. * Stores the fill mode state
  82262. */
  82263. private _fillMode;
  82264. /**
  82265. * Specifies if the depth write state should be cached
  82266. */
  82267. private _cachedDepthWriteState;
  82268. /**
  82269. * Stores the uniform buffer
  82270. */
  82271. protected _uniformBuffer: UniformBuffer;
  82272. /** @hidden */
  82273. _indexInSceneMaterialArray: number;
  82274. /** @hidden */
  82275. meshMap: Nullable<{
  82276. [id: string]: AbstractMesh | undefined;
  82277. }>;
  82278. /**
  82279. * Creates a material instance
  82280. * @param name defines the name of the material
  82281. * @param scene defines the scene to reference
  82282. * @param doNotAdd specifies if the material should be added to the scene
  82283. */
  82284. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  82285. /**
  82286. * Returns a string representation of the current material
  82287. * @param fullDetails defines a boolean indicating which levels of logging is desired
  82288. * @returns a string with material information
  82289. */
  82290. toString(fullDetails?: boolean): string;
  82291. /**
  82292. * Gets the class name of the material
  82293. * @returns a string with the class name of the material
  82294. */
  82295. getClassName(): string;
  82296. /**
  82297. * Specifies if updates for the material been locked
  82298. */
  82299. readonly isFrozen: boolean;
  82300. /**
  82301. * Locks updates for the material
  82302. */
  82303. freeze(): void;
  82304. /**
  82305. * Unlocks updates for the material
  82306. */
  82307. unfreeze(): void;
  82308. /**
  82309. * Specifies if the material is ready to be used
  82310. * @param mesh defines the mesh to check
  82311. * @param useInstances specifies if instances should be used
  82312. * @returns a boolean indicating if the material is ready to be used
  82313. */
  82314. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  82315. /**
  82316. * Specifies that the submesh is ready to be used
  82317. * @param mesh defines the mesh to check
  82318. * @param subMesh defines which submesh to check
  82319. * @param useInstances specifies that instances should be used
  82320. * @returns a boolean indicating that the submesh is ready or not
  82321. */
  82322. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  82323. /**
  82324. * Returns the material effect
  82325. * @returns the effect associated with the material
  82326. */
  82327. getEffect(): Nullable<Effect>;
  82328. /**
  82329. * Returns the current scene
  82330. * @returns a Scene
  82331. */
  82332. getScene(): Scene;
  82333. /**
  82334. * Specifies if the material will require alpha blending
  82335. * @returns a boolean specifying if alpha blending is needed
  82336. */
  82337. needAlphaBlending(): boolean;
  82338. /**
  82339. * Specifies if the mesh will require alpha blending
  82340. * @param mesh defines the mesh to check
  82341. * @returns a boolean specifying if alpha blending is needed for the mesh
  82342. */
  82343. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  82344. /**
  82345. * Specifies if this material should be rendered in alpha test mode
  82346. * @returns a boolean specifying if an alpha test is needed.
  82347. */
  82348. needAlphaTesting(): boolean;
  82349. /**
  82350. * Gets the texture used for the alpha test
  82351. * @returns the texture to use for alpha testing
  82352. */
  82353. getAlphaTestTexture(): Nullable<BaseTexture>;
  82354. /**
  82355. * Marks the material to indicate that it needs to be re-calculated
  82356. */
  82357. markDirty(): void;
  82358. /** @hidden */
  82359. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  82360. /**
  82361. * Binds the material to the mesh
  82362. * @param world defines the world transformation matrix
  82363. * @param mesh defines the mesh to bind the material to
  82364. */
  82365. bind(world: Matrix, mesh?: Mesh): void;
  82366. /**
  82367. * Binds the submesh to the material
  82368. * @param world defines the world transformation matrix
  82369. * @param mesh defines the mesh containing the submesh
  82370. * @param subMesh defines the submesh to bind the material to
  82371. */
  82372. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  82373. /**
  82374. * Binds the world matrix to the material
  82375. * @param world defines the world transformation matrix
  82376. */
  82377. bindOnlyWorldMatrix(world: Matrix): void;
  82378. /**
  82379. * Binds the scene's uniform buffer to the effect.
  82380. * @param effect defines the effect to bind to the scene uniform buffer
  82381. * @param sceneUbo defines the uniform buffer storing scene data
  82382. */
  82383. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  82384. /**
  82385. * Binds the view matrix to the effect
  82386. * @param effect defines the effect to bind the view matrix to
  82387. */
  82388. bindView(effect: Effect): void;
  82389. /**
  82390. * Binds the view projection matrix to the effect
  82391. * @param effect defines the effect to bind the view projection matrix to
  82392. */
  82393. bindViewProjection(effect: Effect): void;
  82394. /**
  82395. * Specifies if material alpha testing should be turned on for the mesh
  82396. * @param mesh defines the mesh to check
  82397. */
  82398. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  82399. /**
  82400. * Processes to execute after binding the material to a mesh
  82401. * @param mesh defines the rendered mesh
  82402. */
  82403. protected _afterBind(mesh?: Mesh): void;
  82404. /**
  82405. * Unbinds the material from the mesh
  82406. */
  82407. unbind(): void;
  82408. /**
  82409. * Gets the active textures from the material
  82410. * @returns an array of textures
  82411. */
  82412. getActiveTextures(): BaseTexture[];
  82413. /**
  82414. * Specifies if the material uses a texture
  82415. * @param texture defines the texture to check against the material
  82416. * @returns a boolean specifying if the material uses the texture
  82417. */
  82418. hasTexture(texture: BaseTexture): boolean;
  82419. /**
  82420. * Makes a duplicate of the material, and gives it a new name
  82421. * @param name defines the new name for the duplicated material
  82422. * @returns the cloned material
  82423. */
  82424. clone(name: string): Nullable<Material>;
  82425. /**
  82426. * Gets the meshes bound to the material
  82427. * @returns an array of meshes bound to the material
  82428. */
  82429. getBindedMeshes(): AbstractMesh[];
  82430. /**
  82431. * Force shader compilation
  82432. * @param mesh defines the mesh associated with this material
  82433. * @param onCompiled defines a function to execute once the material is compiled
  82434. * @param options defines the options to configure the compilation
  82435. */
  82436. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  82437. clipPlane: boolean;
  82438. }>): void;
  82439. /**
  82440. * Force shader compilation
  82441. * @param mesh defines the mesh that will use this material
  82442. * @param options defines additional options for compiling the shaders
  82443. * @returns a promise that resolves when the compilation completes
  82444. */
  82445. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  82446. clipPlane: boolean;
  82447. }>): Promise<void>;
  82448. private static readonly _ImageProcessingDirtyCallBack;
  82449. private static readonly _TextureDirtyCallBack;
  82450. private static readonly _FresnelDirtyCallBack;
  82451. private static readonly _MiscDirtyCallBack;
  82452. private static readonly _LightsDirtyCallBack;
  82453. private static readonly _AttributeDirtyCallBack;
  82454. private static _FresnelAndMiscDirtyCallBack;
  82455. private static _TextureAndMiscDirtyCallBack;
  82456. private static readonly _DirtyCallbackArray;
  82457. private static readonly _RunDirtyCallBacks;
  82458. /**
  82459. * Marks a define in the material to indicate that it needs to be re-computed
  82460. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  82461. */
  82462. markAsDirty(flag: number): void;
  82463. /**
  82464. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  82465. * @param func defines a function which checks material defines against the submeshes
  82466. */
  82467. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  82468. /**
  82469. * Indicates that image processing needs to be re-calculated for all submeshes
  82470. */
  82471. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  82472. /**
  82473. * Indicates that textures need to be re-calculated for all submeshes
  82474. */
  82475. protected _markAllSubMeshesAsTexturesDirty(): void;
  82476. /**
  82477. * Indicates that fresnel needs to be re-calculated for all submeshes
  82478. */
  82479. protected _markAllSubMeshesAsFresnelDirty(): void;
  82480. /**
  82481. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  82482. */
  82483. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  82484. /**
  82485. * Indicates that lights need to be re-calculated for all submeshes
  82486. */
  82487. protected _markAllSubMeshesAsLightsDirty(): void;
  82488. /**
  82489. * Indicates that attributes need to be re-calculated for all submeshes
  82490. */
  82491. protected _markAllSubMeshesAsAttributesDirty(): void;
  82492. /**
  82493. * Indicates that misc needs to be re-calculated for all submeshes
  82494. */
  82495. protected _markAllSubMeshesAsMiscDirty(): void;
  82496. /**
  82497. * Indicates that textures and misc need to be re-calculated for all submeshes
  82498. */
  82499. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  82500. /**
  82501. * Disposes the material
  82502. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82503. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82504. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82505. */
  82506. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82507. /** @hidden */
  82508. private releaseVertexArrayObject;
  82509. /**
  82510. * Serializes this material
  82511. * @returns the serialized material object
  82512. */
  82513. serialize(): any;
  82514. /**
  82515. * Creates a material from parsed material data
  82516. * @param parsedMaterial defines parsed material data
  82517. * @param scene defines the hosting scene
  82518. * @param rootUrl defines the root URL to use to load textures
  82519. * @returns a new material
  82520. */
  82521. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  82522. }
  82523. }
  82524. declare module BABYLON {
  82525. /**
  82526. * Base class for submeshes
  82527. */
  82528. export class BaseSubMesh {
  82529. /** @hidden */
  82530. _materialDefines: Nullable<MaterialDefines>;
  82531. /** @hidden */
  82532. _materialEffect: Nullable<Effect>;
  82533. /**
  82534. * Gets associated effect
  82535. */
  82536. readonly effect: Nullable<Effect>;
  82537. /**
  82538. * Sets associated effect (effect used to render this submesh)
  82539. * @param effect defines the effect to associate with
  82540. * @param defines defines the set of defines used to compile this effect
  82541. */
  82542. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  82543. }
  82544. /**
  82545. * Defines a subdivision inside a mesh
  82546. */
  82547. export class SubMesh extends BaseSubMesh implements ICullable {
  82548. /** the material index to use */
  82549. materialIndex: number;
  82550. /** vertex index start */
  82551. verticesStart: number;
  82552. /** vertices count */
  82553. verticesCount: number;
  82554. /** index start */
  82555. indexStart: number;
  82556. /** indices count */
  82557. indexCount: number;
  82558. /** @hidden */
  82559. _linesIndexCount: number;
  82560. private _mesh;
  82561. private _renderingMesh;
  82562. private _boundingInfo;
  82563. private _linesIndexBuffer;
  82564. /** @hidden */
  82565. _lastColliderWorldVertices: Nullable<Vector3[]>;
  82566. /** @hidden */
  82567. _trianglePlanes: Plane[];
  82568. /** @hidden */
  82569. _lastColliderTransformMatrix: Nullable<Matrix>;
  82570. /** @hidden */
  82571. _renderId: number;
  82572. /** @hidden */
  82573. _alphaIndex: number;
  82574. /** @hidden */
  82575. _distanceToCamera: number;
  82576. /** @hidden */
  82577. _id: number;
  82578. private _currentMaterial;
  82579. /**
  82580. * Add a new submesh to a mesh
  82581. * @param materialIndex defines the material index to use
  82582. * @param verticesStart defines vertex index start
  82583. * @param verticesCount defines vertices count
  82584. * @param indexStart defines index start
  82585. * @param indexCount defines indices count
  82586. * @param mesh defines the parent mesh
  82587. * @param renderingMesh defines an optional rendering mesh
  82588. * @param createBoundingBox defines if bounding box should be created for this submesh
  82589. * @returns the new submesh
  82590. */
  82591. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  82592. /**
  82593. * Creates a new submesh
  82594. * @param materialIndex defines the material index to use
  82595. * @param verticesStart defines vertex index start
  82596. * @param verticesCount defines vertices count
  82597. * @param indexStart defines index start
  82598. * @param indexCount defines indices count
  82599. * @param mesh defines the parent mesh
  82600. * @param renderingMesh defines an optional rendering mesh
  82601. * @param createBoundingBox defines if bounding box should be created for this submesh
  82602. */
  82603. constructor(
  82604. /** the material index to use */
  82605. materialIndex: number,
  82606. /** vertex index start */
  82607. verticesStart: number,
  82608. /** vertices count */
  82609. verticesCount: number,
  82610. /** index start */
  82611. indexStart: number,
  82612. /** indices count */
  82613. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  82614. /**
  82615. * Returns true if this submesh covers the entire parent mesh
  82616. * @ignorenaming
  82617. */
  82618. readonly IsGlobal: boolean;
  82619. /**
  82620. * Returns the submesh BoudingInfo object
  82621. * @returns current bounding info (or mesh's one if the submesh is global)
  82622. */
  82623. getBoundingInfo(): BoundingInfo;
  82624. /**
  82625. * Sets the submesh BoundingInfo
  82626. * @param boundingInfo defines the new bounding info to use
  82627. * @returns the SubMesh
  82628. */
  82629. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  82630. /**
  82631. * Returns the mesh of the current submesh
  82632. * @return the parent mesh
  82633. */
  82634. getMesh(): AbstractMesh;
  82635. /**
  82636. * Returns the rendering mesh of the submesh
  82637. * @returns the rendering mesh (could be different from parent mesh)
  82638. */
  82639. getRenderingMesh(): Mesh;
  82640. /**
  82641. * Returns the submesh material
  82642. * @returns null or the current material
  82643. */
  82644. getMaterial(): Nullable<Material>;
  82645. /**
  82646. * Sets a new updated BoundingInfo object to the submesh
  82647. * @param data defines an optional position array to use to determine the bounding info
  82648. * @returns the SubMesh
  82649. */
  82650. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  82651. /** @hidden */
  82652. _checkCollision(collider: Collider): boolean;
  82653. /**
  82654. * Updates the submesh BoundingInfo
  82655. * @param world defines the world matrix to use to update the bounding info
  82656. * @returns the submesh
  82657. */
  82658. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  82659. /**
  82660. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  82661. * @param frustumPlanes defines the frustum planes
  82662. * @returns true if the submesh is intersecting with the frustum
  82663. */
  82664. isInFrustum(frustumPlanes: Plane[]): boolean;
  82665. /**
  82666. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  82667. * @param frustumPlanes defines the frustum planes
  82668. * @returns true if the submesh is inside the frustum
  82669. */
  82670. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82671. /**
  82672. * Renders the submesh
  82673. * @param enableAlphaMode defines if alpha needs to be used
  82674. * @returns the submesh
  82675. */
  82676. render(enableAlphaMode: boolean): SubMesh;
  82677. /**
  82678. * @hidden
  82679. */
  82680. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  82681. /**
  82682. * Checks if the submesh intersects with a ray
  82683. * @param ray defines the ray to test
  82684. * @returns true is the passed ray intersects the submesh bounding box
  82685. */
  82686. canIntersects(ray: Ray): boolean;
  82687. /**
  82688. * Intersects current submesh with a ray
  82689. * @param ray defines the ray to test
  82690. * @param positions defines mesh's positions array
  82691. * @param indices defines mesh's indices array
  82692. * @param fastCheck defines if only bounding info should be used
  82693. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82694. * @returns intersection info or null if no intersection
  82695. */
  82696. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  82697. /** @hidden */
  82698. private _intersectLines;
  82699. /** @hidden */
  82700. private _intersectUnIndexedLines;
  82701. /** @hidden */
  82702. private _intersectTriangles;
  82703. /** @hidden */
  82704. private _intersectUnIndexedTriangles;
  82705. /** @hidden */
  82706. _rebuild(): void;
  82707. /**
  82708. * Creates a new submesh from the passed mesh
  82709. * @param newMesh defines the new hosting mesh
  82710. * @param newRenderingMesh defines an optional rendering mesh
  82711. * @returns the new submesh
  82712. */
  82713. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  82714. /**
  82715. * Release associated resources
  82716. */
  82717. dispose(): void;
  82718. /**
  82719. * Gets the class name
  82720. * @returns the string "SubMesh".
  82721. */
  82722. getClassName(): string;
  82723. /**
  82724. * Creates a new submesh from indices data
  82725. * @param materialIndex the index of the main mesh material
  82726. * @param startIndex the index where to start the copy in the mesh indices array
  82727. * @param indexCount the number of indices to copy then from the startIndex
  82728. * @param mesh the main mesh to create the submesh from
  82729. * @param renderingMesh the optional rendering mesh
  82730. * @returns a new submesh
  82731. */
  82732. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  82733. }
  82734. }
  82735. declare module BABYLON {
  82736. /**
  82737. * Class used to store geometry data (vertex buffers + index buffer)
  82738. */
  82739. export class Geometry implements IGetSetVerticesData {
  82740. /**
  82741. * Gets or sets the ID of the geometry
  82742. */
  82743. id: string;
  82744. /**
  82745. * Gets or sets the unique ID of the geometry
  82746. */
  82747. uniqueId: number;
  82748. /**
  82749. * Gets the delay loading state of the geometry (none by default which means not delayed)
  82750. */
  82751. delayLoadState: number;
  82752. /**
  82753. * Gets the file containing the data to load when running in delay load state
  82754. */
  82755. delayLoadingFile: Nullable<string>;
  82756. /**
  82757. * Callback called when the geometry is updated
  82758. */
  82759. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  82760. private _scene;
  82761. private _engine;
  82762. private _meshes;
  82763. private _totalVertices;
  82764. /** @hidden */
  82765. _indices: IndicesArray;
  82766. /** @hidden */
  82767. _vertexBuffers: {
  82768. [key: string]: VertexBuffer;
  82769. };
  82770. private _isDisposed;
  82771. private _extend;
  82772. private _boundingBias;
  82773. /** @hidden */
  82774. _delayInfo: Array<string>;
  82775. private _indexBuffer;
  82776. private _indexBufferIsUpdatable;
  82777. /** @hidden */
  82778. _boundingInfo: Nullable<BoundingInfo>;
  82779. /** @hidden */
  82780. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  82781. /** @hidden */
  82782. _softwareSkinningFrameId: number;
  82783. private _vertexArrayObjects;
  82784. private _updatable;
  82785. /** @hidden */
  82786. _positions: Nullable<Vector3[]>;
  82787. /**
  82788. * 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
  82789. */
  82790. /**
  82791. * 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
  82792. */
  82793. boundingBias: Vector2;
  82794. /**
  82795. * Static function used to attach a new empty geometry to a mesh
  82796. * @param mesh defines the mesh to attach the geometry to
  82797. * @returns the new Geometry
  82798. */
  82799. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  82800. /**
  82801. * Creates a new geometry
  82802. * @param id defines the unique ID
  82803. * @param scene defines the hosting scene
  82804. * @param vertexData defines the VertexData used to get geometry data
  82805. * @param updatable defines if geometry must be updatable (false by default)
  82806. * @param mesh defines the mesh that will be associated with the geometry
  82807. */
  82808. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  82809. /**
  82810. * Gets the current extend of the geometry
  82811. */
  82812. readonly extend: {
  82813. minimum: Vector3;
  82814. maximum: Vector3;
  82815. };
  82816. /**
  82817. * Gets the hosting scene
  82818. * @returns the hosting Scene
  82819. */
  82820. getScene(): Scene;
  82821. /**
  82822. * Gets the hosting engine
  82823. * @returns the hosting Engine
  82824. */
  82825. getEngine(): Engine;
  82826. /**
  82827. * Defines if the geometry is ready to use
  82828. * @returns true if the geometry is ready to be used
  82829. */
  82830. isReady(): boolean;
  82831. /**
  82832. * Gets a value indicating that the geometry should not be serialized
  82833. */
  82834. readonly doNotSerialize: boolean;
  82835. /** @hidden */
  82836. _rebuild(): void;
  82837. /**
  82838. * Affects all geometry data in one call
  82839. * @param vertexData defines the geometry data
  82840. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  82841. */
  82842. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  82843. /**
  82844. * Set specific vertex data
  82845. * @param kind defines the data kind (Position, normal, etc...)
  82846. * @param data defines the vertex data to use
  82847. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82848. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82849. */
  82850. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  82851. /**
  82852. * Removes a specific vertex data
  82853. * @param kind defines the data kind (Position, normal, etc...)
  82854. */
  82855. removeVerticesData(kind: string): void;
  82856. /**
  82857. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  82858. * @param buffer defines the vertex buffer to use
  82859. * @param totalVertices defines the total number of vertices for position kind (could be null)
  82860. */
  82861. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  82862. /**
  82863. * Update a specific vertex buffer
  82864. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  82865. * It will do nothing if the buffer is not updatable
  82866. * @param kind defines the data kind (Position, normal, etc...)
  82867. * @param data defines the data to use
  82868. * @param offset defines the offset in the target buffer where to store the data
  82869. * @param useBytes set to true if the offset is in bytes
  82870. */
  82871. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  82872. /**
  82873. * Update a specific vertex buffer
  82874. * This function will create a new buffer if the current one is not updatable
  82875. * @param kind defines the data kind (Position, normal, etc...)
  82876. * @param data defines the data to use
  82877. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  82878. */
  82879. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  82880. private _updateBoundingInfo;
  82881. /** @hidden */
  82882. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  82883. /**
  82884. * Gets total number of vertices
  82885. * @returns the total number of vertices
  82886. */
  82887. getTotalVertices(): number;
  82888. /**
  82889. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82890. * @param kind defines the data kind (Position, normal, etc...)
  82891. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82892. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82893. * @returns a float array containing vertex data
  82894. */
  82895. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82896. /**
  82897. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  82898. * @param kind defines the data kind (Position, normal, etc...)
  82899. * @returns true if the vertex buffer with the specified kind is updatable
  82900. */
  82901. isVertexBufferUpdatable(kind: string): boolean;
  82902. /**
  82903. * Gets a specific vertex buffer
  82904. * @param kind defines the data kind (Position, normal, etc...)
  82905. * @returns a VertexBuffer
  82906. */
  82907. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  82908. /**
  82909. * Returns all vertex buffers
  82910. * @return an object holding all vertex buffers indexed by kind
  82911. */
  82912. getVertexBuffers(): Nullable<{
  82913. [key: string]: VertexBuffer;
  82914. }>;
  82915. /**
  82916. * Gets a boolean indicating if specific vertex buffer is present
  82917. * @param kind defines the data kind (Position, normal, etc...)
  82918. * @returns true if data is present
  82919. */
  82920. isVerticesDataPresent(kind: string): boolean;
  82921. /**
  82922. * Gets a list of all attached data kinds (Position, normal, etc...)
  82923. * @returns a list of string containing all kinds
  82924. */
  82925. getVerticesDataKinds(): string[];
  82926. /**
  82927. * Update index buffer
  82928. * @param indices defines the indices to store in the index buffer
  82929. * @param offset defines the offset in the target buffer where to store the data
  82930. * @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)
  82931. */
  82932. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  82933. /**
  82934. * Creates a new index buffer
  82935. * @param indices defines the indices to store in the index buffer
  82936. * @param totalVertices defines the total number of vertices (could be null)
  82937. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82938. */
  82939. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  82940. /**
  82941. * Return the total number of indices
  82942. * @returns the total number of indices
  82943. */
  82944. getTotalIndices(): number;
  82945. /**
  82946. * Gets the index buffer array
  82947. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82948. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82949. * @returns the index buffer array
  82950. */
  82951. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82952. /**
  82953. * Gets the index buffer
  82954. * @return the index buffer
  82955. */
  82956. getIndexBuffer(): Nullable<DataBuffer>;
  82957. /** @hidden */
  82958. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  82959. /**
  82960. * Release the associated resources for a specific mesh
  82961. * @param mesh defines the source mesh
  82962. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  82963. */
  82964. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  82965. /**
  82966. * Apply current geometry to a given mesh
  82967. * @param mesh defines the mesh to apply geometry to
  82968. */
  82969. applyToMesh(mesh: Mesh): void;
  82970. private _updateExtend;
  82971. private _applyToMesh;
  82972. private notifyUpdate;
  82973. /**
  82974. * Load the geometry if it was flagged as delay loaded
  82975. * @param scene defines the hosting scene
  82976. * @param onLoaded defines a callback called when the geometry is loaded
  82977. */
  82978. load(scene: Scene, onLoaded?: () => void): void;
  82979. private _queueLoad;
  82980. /**
  82981. * Invert the geometry to move from a right handed system to a left handed one.
  82982. */
  82983. toLeftHanded(): void;
  82984. /** @hidden */
  82985. _resetPointsArrayCache(): void;
  82986. /** @hidden */
  82987. _generatePointsArray(): boolean;
  82988. /**
  82989. * Gets a value indicating if the geometry is disposed
  82990. * @returns true if the geometry was disposed
  82991. */
  82992. isDisposed(): boolean;
  82993. private _disposeVertexArrayObjects;
  82994. /**
  82995. * Free all associated resources
  82996. */
  82997. dispose(): void;
  82998. /**
  82999. * Clone the current geometry into a new geometry
  83000. * @param id defines the unique ID of the new geometry
  83001. * @returns a new geometry object
  83002. */
  83003. copy(id: string): Geometry;
  83004. /**
  83005. * Serialize the current geometry info (and not the vertices data) into a JSON object
  83006. * @return a JSON representation of the current geometry data (without the vertices data)
  83007. */
  83008. serialize(): any;
  83009. private toNumberArray;
  83010. /**
  83011. * Serialize all vertices data into a JSON oject
  83012. * @returns a JSON representation of the current geometry data
  83013. */
  83014. serializeVerticeData(): any;
  83015. /**
  83016. * Extracts a clone of a mesh geometry
  83017. * @param mesh defines the source mesh
  83018. * @param id defines the unique ID of the new geometry object
  83019. * @returns the new geometry object
  83020. */
  83021. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  83022. /**
  83023. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  83024. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  83025. * Be aware Math.random() could cause collisions, but:
  83026. * "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"
  83027. * @returns a string containing a new GUID
  83028. */
  83029. static RandomId(): string;
  83030. /** @hidden */
  83031. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  83032. private static _CleanMatricesWeights;
  83033. /**
  83034. * Create a new geometry from persisted data (Using .babylon file format)
  83035. * @param parsedVertexData defines the persisted data
  83036. * @param scene defines the hosting scene
  83037. * @param rootUrl defines the root url to use to load assets (like delayed data)
  83038. * @returns the new geometry object
  83039. */
  83040. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  83041. }
  83042. }
  83043. declare module BABYLON {
  83044. /**
  83045. * Define an interface for all classes that will get and set the data on vertices
  83046. */
  83047. export interface IGetSetVerticesData {
  83048. /**
  83049. * Gets a boolean indicating if specific vertex data is present
  83050. * @param kind defines the vertex data kind to use
  83051. * @returns true is data kind is present
  83052. */
  83053. isVerticesDataPresent(kind: string): boolean;
  83054. /**
  83055. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  83056. * @param kind defines the data kind (Position, normal, etc...)
  83057. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  83058. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  83059. * @returns a float array containing vertex data
  83060. */
  83061. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  83062. /**
  83063. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83064. * @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.
  83065. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  83066. * @returns the indices array or an empty array if the mesh has no geometry
  83067. */
  83068. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  83069. /**
  83070. * Set specific vertex data
  83071. * @param kind defines the data kind (Position, normal, etc...)
  83072. * @param data defines the vertex data to use
  83073. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  83074. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  83075. */
  83076. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  83077. /**
  83078. * Update a specific associated vertex buffer
  83079. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  83080. * - VertexBuffer.PositionKind
  83081. * - VertexBuffer.UVKind
  83082. * - VertexBuffer.UV2Kind
  83083. * - VertexBuffer.UV3Kind
  83084. * - VertexBuffer.UV4Kind
  83085. * - VertexBuffer.UV5Kind
  83086. * - VertexBuffer.UV6Kind
  83087. * - VertexBuffer.ColorKind
  83088. * - VertexBuffer.MatricesIndicesKind
  83089. * - VertexBuffer.MatricesIndicesExtraKind
  83090. * - VertexBuffer.MatricesWeightsKind
  83091. * - VertexBuffer.MatricesWeightsExtraKind
  83092. * @param data defines the data source
  83093. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  83094. * @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)
  83095. */
  83096. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  83097. /**
  83098. * Creates a new index buffer
  83099. * @param indices defines the indices to store in the index buffer
  83100. * @param totalVertices defines the total number of vertices (could be null)
  83101. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  83102. */
  83103. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  83104. }
  83105. /**
  83106. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  83107. */
  83108. export class VertexData {
  83109. /**
  83110. * Mesh side orientation : usually the external or front surface
  83111. */
  83112. static readonly FRONTSIDE: number;
  83113. /**
  83114. * Mesh side orientation : usually the internal or back surface
  83115. */
  83116. static readonly BACKSIDE: number;
  83117. /**
  83118. * Mesh side orientation : both internal and external or front and back surfaces
  83119. */
  83120. static readonly DOUBLESIDE: number;
  83121. /**
  83122. * Mesh side orientation : by default, `FRONTSIDE`
  83123. */
  83124. static readonly DEFAULTSIDE: number;
  83125. /**
  83126. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  83127. */
  83128. positions: Nullable<FloatArray>;
  83129. /**
  83130. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  83131. */
  83132. normals: Nullable<FloatArray>;
  83133. /**
  83134. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  83135. */
  83136. tangents: Nullable<FloatArray>;
  83137. /**
  83138. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83139. */
  83140. uvs: Nullable<FloatArray>;
  83141. /**
  83142. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83143. */
  83144. uvs2: Nullable<FloatArray>;
  83145. /**
  83146. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83147. */
  83148. uvs3: Nullable<FloatArray>;
  83149. /**
  83150. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83151. */
  83152. uvs4: Nullable<FloatArray>;
  83153. /**
  83154. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83155. */
  83156. uvs5: Nullable<FloatArray>;
  83157. /**
  83158. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83159. */
  83160. uvs6: Nullable<FloatArray>;
  83161. /**
  83162. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  83163. */
  83164. colors: Nullable<FloatArray>;
  83165. /**
  83166. * 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).
  83167. */
  83168. matricesIndices: Nullable<FloatArray>;
  83169. /**
  83170. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  83171. */
  83172. matricesWeights: Nullable<FloatArray>;
  83173. /**
  83174. * An array extending the number of possible indices
  83175. */
  83176. matricesIndicesExtra: Nullable<FloatArray>;
  83177. /**
  83178. * An array extending the number of possible weights when the number of indices is extended
  83179. */
  83180. matricesWeightsExtra: Nullable<FloatArray>;
  83181. /**
  83182. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  83183. */
  83184. indices: Nullable<IndicesArray>;
  83185. /**
  83186. * Uses the passed data array to set the set the values for the specified kind of data
  83187. * @param data a linear array of floating numbers
  83188. * @param kind the type of data that is being set, eg positions, colors etc
  83189. */
  83190. set(data: FloatArray, kind: string): void;
  83191. /**
  83192. * Associates the vertexData to the passed Mesh.
  83193. * Sets it as updatable or not (default `false`)
  83194. * @param mesh the mesh the vertexData is applied to
  83195. * @param updatable when used and having the value true allows new data to update the vertexData
  83196. * @returns the VertexData
  83197. */
  83198. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  83199. /**
  83200. * Associates the vertexData to the passed Geometry.
  83201. * Sets it as updatable or not (default `false`)
  83202. * @param geometry the geometry the vertexData is applied to
  83203. * @param updatable when used and having the value true allows new data to update the vertexData
  83204. * @returns VertexData
  83205. */
  83206. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  83207. /**
  83208. * Updates the associated mesh
  83209. * @param mesh the mesh to be updated
  83210. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83211. * @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
  83212. * @returns VertexData
  83213. */
  83214. updateMesh(mesh: Mesh): VertexData;
  83215. /**
  83216. * Updates the associated geometry
  83217. * @param geometry the geometry to be updated
  83218. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83219. * @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
  83220. * @returns VertexData.
  83221. */
  83222. updateGeometry(geometry: Geometry): VertexData;
  83223. private _applyTo;
  83224. private _update;
  83225. /**
  83226. * Transforms each position and each normal of the vertexData according to the passed Matrix
  83227. * @param matrix the transforming matrix
  83228. * @returns the VertexData
  83229. */
  83230. transform(matrix: Matrix): VertexData;
  83231. /**
  83232. * Merges the passed VertexData into the current one
  83233. * @param other the VertexData to be merged into the current one
  83234. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  83235. * @returns the modified VertexData
  83236. */
  83237. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  83238. private _mergeElement;
  83239. private _validate;
  83240. /**
  83241. * Serializes the VertexData
  83242. * @returns a serialized object
  83243. */
  83244. serialize(): any;
  83245. /**
  83246. * Extracts the vertexData from a mesh
  83247. * @param mesh the mesh from which to extract the VertexData
  83248. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  83249. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83250. * @returns the object VertexData associated to the passed mesh
  83251. */
  83252. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83253. /**
  83254. * Extracts the vertexData from the geometry
  83255. * @param geometry the geometry from which to extract the VertexData
  83256. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  83257. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83258. * @returns the object VertexData associated to the passed mesh
  83259. */
  83260. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83261. private static _ExtractFrom;
  83262. /**
  83263. * Creates the VertexData for a Ribbon
  83264. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  83265. * * pathArray array of paths, each of which an array of successive Vector3
  83266. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  83267. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  83268. * * 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
  83269. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83270. * * 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)
  83271. * * 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)
  83272. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  83273. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  83274. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  83275. * @returns the VertexData of the ribbon
  83276. */
  83277. static CreateRibbon(options: {
  83278. pathArray: Vector3[][];
  83279. closeArray?: boolean;
  83280. closePath?: boolean;
  83281. offset?: number;
  83282. sideOrientation?: number;
  83283. frontUVs?: Vector4;
  83284. backUVs?: Vector4;
  83285. invertUV?: boolean;
  83286. uvs?: Vector2[];
  83287. colors?: Color4[];
  83288. }): VertexData;
  83289. /**
  83290. * Creates the VertexData for a box
  83291. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83292. * * size sets the width, height and depth of the box to the value of size, optional default 1
  83293. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  83294. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  83295. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  83296. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  83297. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  83298. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83299. * * 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)
  83300. * * 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)
  83301. * @returns the VertexData of the box
  83302. */
  83303. static CreateBox(options: {
  83304. size?: number;
  83305. width?: number;
  83306. height?: number;
  83307. depth?: number;
  83308. faceUV?: Vector4[];
  83309. faceColors?: Color4[];
  83310. sideOrientation?: number;
  83311. frontUVs?: Vector4;
  83312. backUVs?: Vector4;
  83313. }): VertexData;
  83314. /**
  83315. * Creates the VertexData for an ellipsoid, defaults to a sphere
  83316. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83317. * * segments sets the number of horizontal strips optional, default 32
  83318. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  83319. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  83320. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  83321. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  83322. * * 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
  83323. * * 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
  83324. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83325. * * 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)
  83326. * * 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)
  83327. * @returns the VertexData of the ellipsoid
  83328. */
  83329. static CreateSphere(options: {
  83330. segments?: number;
  83331. diameter?: number;
  83332. diameterX?: number;
  83333. diameterY?: number;
  83334. diameterZ?: number;
  83335. arc?: number;
  83336. slice?: number;
  83337. sideOrientation?: number;
  83338. frontUVs?: Vector4;
  83339. backUVs?: Vector4;
  83340. }): VertexData;
  83341. /**
  83342. * Creates the VertexData for a cylinder, cone or prism
  83343. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83344. * * height sets the height (y direction) of the cylinder, optional, default 2
  83345. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  83346. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  83347. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  83348. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83349. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  83350. * * 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
  83351. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83352. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83353. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  83354. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  83355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83356. * * 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)
  83357. * * 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)
  83358. * @returns the VertexData of the cylinder, cone or prism
  83359. */
  83360. static CreateCylinder(options: {
  83361. height?: number;
  83362. diameterTop?: number;
  83363. diameterBottom?: number;
  83364. diameter?: number;
  83365. tessellation?: number;
  83366. subdivisions?: number;
  83367. arc?: number;
  83368. faceColors?: Color4[];
  83369. faceUV?: Vector4[];
  83370. hasRings?: boolean;
  83371. enclose?: boolean;
  83372. sideOrientation?: number;
  83373. frontUVs?: Vector4;
  83374. backUVs?: Vector4;
  83375. }): VertexData;
  83376. /**
  83377. * Creates the VertexData for a torus
  83378. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83379. * * diameter the diameter of the torus, optional default 1
  83380. * * thickness the diameter of the tube forming the torus, optional default 0.5
  83381. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83382. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83383. * * 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)
  83384. * * 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)
  83385. * @returns the VertexData of the torus
  83386. */
  83387. static CreateTorus(options: {
  83388. diameter?: number;
  83389. thickness?: number;
  83390. tessellation?: number;
  83391. sideOrientation?: number;
  83392. frontUVs?: Vector4;
  83393. backUVs?: Vector4;
  83394. }): VertexData;
  83395. /**
  83396. * Creates the VertexData of the LineSystem
  83397. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  83398. * - lines an array of lines, each line being an array of successive Vector3
  83399. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  83400. * @returns the VertexData of the LineSystem
  83401. */
  83402. static CreateLineSystem(options: {
  83403. lines: Vector3[][];
  83404. colors?: Nullable<Color4[][]>;
  83405. }): VertexData;
  83406. /**
  83407. * Create the VertexData for a DashedLines
  83408. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  83409. * - points an array successive Vector3
  83410. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  83411. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  83412. * - dashNb the intended total number of dashes, optional, default 200
  83413. * @returns the VertexData for the DashedLines
  83414. */
  83415. static CreateDashedLines(options: {
  83416. points: Vector3[];
  83417. dashSize?: number;
  83418. gapSize?: number;
  83419. dashNb?: number;
  83420. }): VertexData;
  83421. /**
  83422. * Creates the VertexData for a Ground
  83423. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83424. * - width the width (x direction) of the ground, optional, default 1
  83425. * - height the height (z direction) of the ground, optional, default 1
  83426. * - subdivisions the number of subdivisions per side, optional, default 1
  83427. * @returns the VertexData of the Ground
  83428. */
  83429. static CreateGround(options: {
  83430. width?: number;
  83431. height?: number;
  83432. subdivisions?: number;
  83433. subdivisionsX?: number;
  83434. subdivisionsY?: number;
  83435. }): VertexData;
  83436. /**
  83437. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  83438. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83439. * * xmin the ground minimum X coordinate, optional, default -1
  83440. * * zmin the ground minimum Z coordinate, optional, default -1
  83441. * * xmax the ground maximum X coordinate, optional, default 1
  83442. * * zmax the ground maximum Z coordinate, optional, default 1
  83443. * * 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}
  83444. * * 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}
  83445. * @returns the VertexData of the TiledGround
  83446. */
  83447. static CreateTiledGround(options: {
  83448. xmin: number;
  83449. zmin: number;
  83450. xmax: number;
  83451. zmax: number;
  83452. subdivisions?: {
  83453. w: number;
  83454. h: number;
  83455. };
  83456. precision?: {
  83457. w: number;
  83458. h: number;
  83459. };
  83460. }): VertexData;
  83461. /**
  83462. * Creates the VertexData of the Ground designed from a heightmap
  83463. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  83464. * * width the width (x direction) of the ground
  83465. * * height the height (z direction) of the ground
  83466. * * subdivisions the number of subdivisions per side
  83467. * * minHeight the minimum altitude on the ground, optional, default 0
  83468. * * maxHeight the maximum altitude on the ground, optional default 1
  83469. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  83470. * * buffer the array holding the image color data
  83471. * * bufferWidth the width of image
  83472. * * bufferHeight the height of image
  83473. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  83474. * @returns the VertexData of the Ground designed from a heightmap
  83475. */
  83476. static CreateGroundFromHeightMap(options: {
  83477. width: number;
  83478. height: number;
  83479. subdivisions: number;
  83480. minHeight: number;
  83481. maxHeight: number;
  83482. colorFilter: Color3;
  83483. buffer: Uint8Array;
  83484. bufferWidth: number;
  83485. bufferHeight: number;
  83486. alphaFilter: number;
  83487. }): VertexData;
  83488. /**
  83489. * Creates the VertexData for a Plane
  83490. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  83491. * * size sets the width and height of the plane to the value of size, optional default 1
  83492. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  83493. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  83494. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83495. * * 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)
  83496. * * 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)
  83497. * @returns the VertexData of the box
  83498. */
  83499. static CreatePlane(options: {
  83500. size?: number;
  83501. width?: number;
  83502. height?: number;
  83503. sideOrientation?: number;
  83504. frontUVs?: Vector4;
  83505. backUVs?: Vector4;
  83506. }): VertexData;
  83507. /**
  83508. * Creates the VertexData of the Disc or regular Polygon
  83509. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  83510. * * radius the radius of the disc, optional default 0.5
  83511. * * tessellation the number of polygon sides, optional, default 64
  83512. * * 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
  83513. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83514. * * 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)
  83515. * * 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)
  83516. * @returns the VertexData of the box
  83517. */
  83518. static CreateDisc(options: {
  83519. radius?: number;
  83520. tessellation?: number;
  83521. arc?: number;
  83522. sideOrientation?: number;
  83523. frontUVs?: Vector4;
  83524. backUVs?: Vector4;
  83525. }): VertexData;
  83526. /**
  83527. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  83528. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  83529. * @param polygon a mesh built from polygonTriangulation.build()
  83530. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83531. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83532. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83533. * @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)
  83534. * @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)
  83535. * @returns the VertexData of the Polygon
  83536. */
  83537. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  83538. /**
  83539. * Creates the VertexData of the IcoSphere
  83540. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  83541. * * radius the radius of the IcoSphere, optional default 1
  83542. * * radiusX allows stretching in the x direction, optional, default radius
  83543. * * radiusY allows stretching in the y direction, optional, default radius
  83544. * * radiusZ allows stretching in the z direction, optional, default radius
  83545. * * flat when true creates a flat shaded mesh, optional, default true
  83546. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83547. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83548. * * 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)
  83549. * * 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)
  83550. * @returns the VertexData of the IcoSphere
  83551. */
  83552. static CreateIcoSphere(options: {
  83553. radius?: number;
  83554. radiusX?: number;
  83555. radiusY?: number;
  83556. radiusZ?: number;
  83557. flat?: boolean;
  83558. subdivisions?: number;
  83559. sideOrientation?: number;
  83560. frontUVs?: Vector4;
  83561. backUVs?: Vector4;
  83562. }): VertexData;
  83563. /**
  83564. * Creates the VertexData for a Polyhedron
  83565. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  83566. * * type provided types are:
  83567. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  83568. * * 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)
  83569. * * size the size of the IcoSphere, optional default 1
  83570. * * sizeX allows stretching in the x direction, optional, default size
  83571. * * sizeY allows stretching in the y direction, optional, default size
  83572. * * sizeZ allows stretching in the z direction, optional, default size
  83573. * * 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
  83574. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83575. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83576. * * flat when true creates a flat shaded mesh, optional, default true
  83577. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83578. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83579. * * 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)
  83580. * * 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)
  83581. * @returns the VertexData of the Polyhedron
  83582. */
  83583. static CreatePolyhedron(options: {
  83584. type?: number;
  83585. size?: number;
  83586. sizeX?: number;
  83587. sizeY?: number;
  83588. sizeZ?: number;
  83589. custom?: any;
  83590. faceUV?: Vector4[];
  83591. faceColors?: Color4[];
  83592. flat?: boolean;
  83593. sideOrientation?: number;
  83594. frontUVs?: Vector4;
  83595. backUVs?: Vector4;
  83596. }): VertexData;
  83597. /**
  83598. * Creates the VertexData for a TorusKnot
  83599. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  83600. * * radius the radius of the torus knot, optional, default 2
  83601. * * tube the thickness of the tube, optional, default 0.5
  83602. * * radialSegments the number of sides on each tube segments, optional, default 32
  83603. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  83604. * * p the number of windings around the z axis, optional, default 2
  83605. * * q the number of windings around the x axis, optional, default 3
  83606. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83607. * * 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)
  83608. * * 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)
  83609. * @returns the VertexData of the Torus Knot
  83610. */
  83611. static CreateTorusKnot(options: {
  83612. radius?: number;
  83613. tube?: number;
  83614. radialSegments?: number;
  83615. tubularSegments?: number;
  83616. p?: number;
  83617. q?: number;
  83618. sideOrientation?: number;
  83619. frontUVs?: Vector4;
  83620. backUVs?: Vector4;
  83621. }): VertexData;
  83622. /**
  83623. * Compute normals for given positions and indices
  83624. * @param positions an array of vertex positions, [...., x, y, z, ......]
  83625. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  83626. * @param normals an array of vertex normals, [...., x, y, z, ......]
  83627. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  83628. * * facetNormals : optional array of facet normals (vector3)
  83629. * * facetPositions : optional array of facet positions (vector3)
  83630. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  83631. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  83632. * * bInfo : optional bounding info, required for facetPartitioning computation
  83633. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  83634. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  83635. * * useRightHandedSystem: optional boolean to for right handed system computation
  83636. * * depthSort : optional boolean to enable the facet depth sort computation
  83637. * * distanceTo : optional Vector3 to compute the facet depth from this location
  83638. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  83639. */
  83640. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  83641. facetNormals?: any;
  83642. facetPositions?: any;
  83643. facetPartitioning?: any;
  83644. ratio?: number;
  83645. bInfo?: any;
  83646. bbSize?: Vector3;
  83647. subDiv?: any;
  83648. useRightHandedSystem?: boolean;
  83649. depthSort?: boolean;
  83650. distanceTo?: Vector3;
  83651. depthSortedFacets?: any;
  83652. }): void;
  83653. /** @hidden */
  83654. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  83655. /**
  83656. * Applies VertexData created from the imported parameters to the geometry
  83657. * @param parsedVertexData the parsed data from an imported file
  83658. * @param geometry the geometry to apply the VertexData to
  83659. */
  83660. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  83661. }
  83662. }
  83663. declare module BABYLON {
  83664. /**
  83665. * Class containing static functions to help procedurally build meshes
  83666. */
  83667. export class DiscBuilder {
  83668. /**
  83669. * Creates a plane polygonal mesh. By default, this is a disc
  83670. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  83671. * * 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
  83672. * * 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
  83673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  83674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  83675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83676. * @param name defines the name of the mesh
  83677. * @param options defines the options used to create the mesh
  83678. * @param scene defines the hosting scene
  83679. * @returns the plane polygonal mesh
  83680. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  83681. */
  83682. static CreateDisc(name: string, options: {
  83683. radius?: number;
  83684. tessellation?: number;
  83685. arc?: number;
  83686. updatable?: boolean;
  83687. sideOrientation?: number;
  83688. frontUVs?: Vector4;
  83689. backUVs?: Vector4;
  83690. }, scene?: Nullable<Scene>): Mesh;
  83691. }
  83692. }
  83693. declare module BABYLON {
  83694. /**
  83695. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  83696. *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.
  83697. * The SPS is also a particle system. It provides some methods to manage the particles.
  83698. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  83699. *
  83700. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  83701. */
  83702. export class SolidParticleSystem implements IDisposable {
  83703. /**
  83704. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  83705. * Example : var p = SPS.particles[i];
  83706. */
  83707. particles: SolidParticle[];
  83708. /**
  83709. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  83710. */
  83711. nbParticles: number;
  83712. /**
  83713. * If the particles must ever face the camera (default false). Useful for planar particles.
  83714. */
  83715. billboard: boolean;
  83716. /**
  83717. * Recompute normals when adding a shape
  83718. */
  83719. recomputeNormals: boolean;
  83720. /**
  83721. * This a counter ofr your own usage. It's not set by any SPS functions.
  83722. */
  83723. counter: number;
  83724. /**
  83725. * The SPS name. This name is also given to the underlying mesh.
  83726. */
  83727. name: string;
  83728. /**
  83729. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  83730. */
  83731. mesh: Mesh;
  83732. /**
  83733. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  83734. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  83735. */
  83736. vars: any;
  83737. /**
  83738. * This array is populated when the SPS is set as 'pickable'.
  83739. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  83740. * Each element of this array is an object `{idx: int, faceId: int}`.
  83741. * `idx` is the picked particle index in the `SPS.particles` array
  83742. * `faceId` is the picked face index counted within this particle.
  83743. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  83744. */
  83745. pickedParticles: {
  83746. idx: number;
  83747. faceId: number;
  83748. }[];
  83749. /**
  83750. * This array is populated when `enableDepthSort` is set to true.
  83751. * Each element of this array is an instance of the class DepthSortedParticle.
  83752. */
  83753. depthSortedParticles: DepthSortedParticle[];
  83754. /**
  83755. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  83756. * @hidden
  83757. */
  83758. _bSphereOnly: boolean;
  83759. /**
  83760. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  83761. * @hidden
  83762. */
  83763. _bSphereRadiusFactor: number;
  83764. private _scene;
  83765. private _positions;
  83766. private _indices;
  83767. private _normals;
  83768. private _colors;
  83769. private _uvs;
  83770. private _indices32;
  83771. private _positions32;
  83772. private _normals32;
  83773. private _fixedNormal32;
  83774. private _colors32;
  83775. private _uvs32;
  83776. private _index;
  83777. private _updatable;
  83778. private _pickable;
  83779. private _isVisibilityBoxLocked;
  83780. private _alwaysVisible;
  83781. private _depthSort;
  83782. private _shapeCounter;
  83783. private _copy;
  83784. private _color;
  83785. private _computeParticleColor;
  83786. private _computeParticleTexture;
  83787. private _computeParticleRotation;
  83788. private _computeParticleVertex;
  83789. private _computeBoundingBox;
  83790. private _depthSortParticles;
  83791. private _camera;
  83792. private _mustUnrotateFixedNormals;
  83793. private _particlesIntersect;
  83794. private _needs32Bits;
  83795. /**
  83796. * Creates a SPS (Solid Particle System) object.
  83797. * @param name (String) is the SPS name, this will be the underlying mesh name.
  83798. * @param scene (Scene) is the scene in which the SPS is added.
  83799. * @param options defines the options of the sps e.g.
  83800. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  83801. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  83802. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  83803. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  83804. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  83805. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  83806. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  83807. */
  83808. constructor(name: string, scene: Scene, options?: {
  83809. updatable?: boolean;
  83810. isPickable?: boolean;
  83811. enableDepthSort?: boolean;
  83812. particleIntersection?: boolean;
  83813. boundingSphereOnly?: boolean;
  83814. bSphereRadiusFactor?: number;
  83815. });
  83816. /**
  83817. * Builds the SPS underlying mesh. Returns a standard Mesh.
  83818. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  83819. * @returns the created mesh
  83820. */
  83821. buildMesh(): Mesh;
  83822. /**
  83823. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  83824. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  83825. * Thus the particles generated from `digest()` have their property `position` set yet.
  83826. * @param mesh ( Mesh ) is the mesh to be digested
  83827. * @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
  83828. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  83829. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  83830. * @returns the current SPS
  83831. */
  83832. digest(mesh: Mesh, options?: {
  83833. facetNb?: number;
  83834. number?: number;
  83835. delta?: number;
  83836. }): SolidParticleSystem;
  83837. private _unrotateFixedNormals;
  83838. private _resetCopy;
  83839. private _meshBuilder;
  83840. private _posToShape;
  83841. private _uvsToShapeUV;
  83842. private _addParticle;
  83843. /**
  83844. * Adds some particles to the SPS from the model shape. Returns the shape id.
  83845. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  83846. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  83847. * @param nb (positive integer) the number of particles to be created from this model
  83848. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  83849. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  83850. * @returns the number of shapes in the system
  83851. */
  83852. addShape(mesh: Mesh, nb: number, options?: {
  83853. positionFunction?: any;
  83854. vertexFunction?: any;
  83855. }): number;
  83856. private _rebuildParticle;
  83857. /**
  83858. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  83859. * @returns the SPS.
  83860. */
  83861. rebuildMesh(): SolidParticleSystem;
  83862. /**
  83863. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  83864. * This method calls `updateParticle()` for each particle of the SPS.
  83865. * For an animated SPS, it is usually called within the render loop.
  83866. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  83867. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  83868. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  83869. * @returns the SPS.
  83870. */
  83871. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  83872. /**
  83873. * Disposes the SPS.
  83874. */
  83875. dispose(): void;
  83876. /**
  83877. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  83878. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83879. * @returns the SPS.
  83880. */
  83881. refreshVisibleSize(): SolidParticleSystem;
  83882. /**
  83883. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  83884. * @param size the size (float) of the visibility box
  83885. * note : this doesn't lock the SPS mesh bounding box.
  83886. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83887. */
  83888. setVisibilityBox(size: number): void;
  83889. /**
  83890. * Gets whether the SPS as always visible or not
  83891. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83892. */
  83893. /**
  83894. * Sets the SPS as always visible or not
  83895. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83896. */
  83897. isAlwaysVisible: boolean;
  83898. /**
  83899. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83900. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83901. */
  83902. /**
  83903. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83904. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83905. */
  83906. isVisibilityBoxLocked: boolean;
  83907. /**
  83908. * Tells to `setParticles()` to compute the particle rotations or not.
  83909. * Default value : true. The SPS is faster when it's set to false.
  83910. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83911. */
  83912. /**
  83913. * Gets if `setParticles()` computes the particle rotations or not.
  83914. * Default value : true. The SPS is faster when it's set to false.
  83915. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83916. */
  83917. computeParticleRotation: boolean;
  83918. /**
  83919. * Tells to `setParticles()` to compute the particle colors or not.
  83920. * Default value : true. The SPS is faster when it's set to false.
  83921. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83922. */
  83923. /**
  83924. * Gets if `setParticles()` computes the particle colors or not.
  83925. * Default value : true. The SPS is faster when it's set to false.
  83926. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83927. */
  83928. computeParticleColor: boolean;
  83929. /**
  83930. * Gets if `setParticles()` computes the particle textures or not.
  83931. * Default value : true. The SPS is faster when it's set to false.
  83932. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  83933. */
  83934. computeParticleTexture: boolean;
  83935. /**
  83936. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  83937. * Default value : false. The SPS is faster when it's set to false.
  83938. * Note : the particle custom vertex positions aren't stored values.
  83939. */
  83940. /**
  83941. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  83942. * Default value : false. The SPS is faster when it's set to false.
  83943. * Note : the particle custom vertex positions aren't stored values.
  83944. */
  83945. computeParticleVertex: boolean;
  83946. /**
  83947. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  83948. */
  83949. /**
  83950. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  83951. */
  83952. computeBoundingBox: boolean;
  83953. /**
  83954. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  83955. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83956. * Default : `true`
  83957. */
  83958. /**
  83959. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  83960. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83961. * Default : `true`
  83962. */
  83963. depthSortParticles: boolean;
  83964. /**
  83965. * This function does nothing. It may be overwritten to set all the particle first values.
  83966. * The SPS doesn't call this function, you may have to call it by your own.
  83967. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83968. */
  83969. initParticles(): void;
  83970. /**
  83971. * This function does nothing. It may be overwritten to recycle a particle.
  83972. * The SPS doesn't call this function, you may have to call it by your own.
  83973. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83974. * @param particle The particle to recycle
  83975. * @returns the recycled particle
  83976. */
  83977. recycleParticle(particle: SolidParticle): SolidParticle;
  83978. /**
  83979. * Updates a particle : this function should be overwritten by the user.
  83980. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  83981. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83982. * @example : just set a particle position or velocity and recycle conditions
  83983. * @param particle The particle to update
  83984. * @returns the updated particle
  83985. */
  83986. updateParticle(particle: SolidParticle): SolidParticle;
  83987. /**
  83988. * Updates a vertex of a particle : it can be overwritten by the user.
  83989. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  83990. * @param particle the current particle
  83991. * @param vertex the current index of the current particle
  83992. * @param pt the index of the current vertex in the particle shape
  83993. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  83994. * @example : just set a vertex particle position
  83995. * @returns the updated vertex
  83996. */
  83997. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  83998. /**
  83999. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  84000. * This does nothing and may be overwritten by the user.
  84001. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  84002. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  84003. * @param update the boolean update value actually passed to setParticles()
  84004. */
  84005. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  84006. /**
  84007. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  84008. * This will be passed three parameters.
  84009. * This does nothing and may be overwritten by the user.
  84010. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  84011. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  84012. * @param update the boolean update value actually passed to setParticles()
  84013. */
  84014. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  84015. }
  84016. }
  84017. declare module BABYLON {
  84018. /**
  84019. * Represents one particle of a solid particle system.
  84020. */
  84021. export class SolidParticle {
  84022. /**
  84023. * particle global index
  84024. */
  84025. idx: number;
  84026. /**
  84027. * The color of the particle
  84028. */
  84029. color: Nullable<Color4>;
  84030. /**
  84031. * The world space position of the particle.
  84032. */
  84033. position: Vector3;
  84034. /**
  84035. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  84036. */
  84037. rotation: Vector3;
  84038. /**
  84039. * The world space rotation quaternion of the particle.
  84040. */
  84041. rotationQuaternion: Nullable<Quaternion>;
  84042. /**
  84043. * The scaling of the particle.
  84044. */
  84045. scaling: Vector3;
  84046. /**
  84047. * The uvs of the particle.
  84048. */
  84049. uvs: Vector4;
  84050. /**
  84051. * The current speed of the particle.
  84052. */
  84053. velocity: Vector3;
  84054. /**
  84055. * The pivot point in the particle local space.
  84056. */
  84057. pivot: Vector3;
  84058. /**
  84059. * Must the particle be translated from its pivot point in its local space ?
  84060. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  84061. * Default : false
  84062. */
  84063. translateFromPivot: boolean;
  84064. /**
  84065. * Is the particle active or not ?
  84066. */
  84067. alive: boolean;
  84068. /**
  84069. * Is the particle visible or not ?
  84070. */
  84071. isVisible: boolean;
  84072. /**
  84073. * Index of this particle in the global "positions" array (Internal use)
  84074. * @hidden
  84075. */
  84076. _pos: number;
  84077. /**
  84078. * @hidden Index of this particle in the global "indices" array (Internal use)
  84079. */
  84080. _ind: number;
  84081. /**
  84082. * @hidden ModelShape of this particle (Internal use)
  84083. */
  84084. _model: ModelShape;
  84085. /**
  84086. * ModelShape id of this particle
  84087. */
  84088. shapeId: number;
  84089. /**
  84090. * Index of the particle in its shape id (Internal use)
  84091. */
  84092. idxInShape: number;
  84093. /**
  84094. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  84095. */
  84096. _modelBoundingInfo: BoundingInfo;
  84097. /**
  84098. * @hidden Particle BoundingInfo object (Internal use)
  84099. */
  84100. _boundingInfo: BoundingInfo;
  84101. /**
  84102. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  84103. */
  84104. _sps: SolidParticleSystem;
  84105. /**
  84106. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  84107. */
  84108. _stillInvisible: boolean;
  84109. /**
  84110. * @hidden Last computed particle rotation matrix
  84111. */
  84112. _rotationMatrix: number[];
  84113. /**
  84114. * Parent particle Id, if any.
  84115. * Default null.
  84116. */
  84117. parentId: Nullable<number>;
  84118. /**
  84119. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  84120. * The possible values are :
  84121. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84122. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84123. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84124. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84125. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84126. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  84127. * */
  84128. cullingStrategy: number;
  84129. /**
  84130. * @hidden Internal global position in the SPS.
  84131. */
  84132. _globalPosition: Vector3;
  84133. /**
  84134. * Creates a Solid Particle object.
  84135. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  84136. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  84137. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  84138. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  84139. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  84140. * @param shapeId (integer) is the model shape identifier in the SPS.
  84141. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  84142. * @param sps defines the sps it is associated to
  84143. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  84144. */
  84145. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  84146. /**
  84147. * Legacy support, changed scale to scaling
  84148. */
  84149. /**
  84150. * Legacy support, changed scale to scaling
  84151. */
  84152. scale: Vector3;
  84153. /**
  84154. * Legacy support, changed quaternion to rotationQuaternion
  84155. */
  84156. /**
  84157. * Legacy support, changed quaternion to rotationQuaternion
  84158. */
  84159. quaternion: Nullable<Quaternion>;
  84160. /**
  84161. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  84162. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  84163. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  84164. * @returns true if it intersects
  84165. */
  84166. intersectsMesh(target: Mesh | SolidParticle): boolean;
  84167. /**
  84168. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  84169. * A particle is in the frustum if its bounding box intersects the frustum
  84170. * @param frustumPlanes defines the frustum to test
  84171. * @returns true if the particle is in the frustum planes
  84172. */
  84173. isInFrustum(frustumPlanes: Plane[]): boolean;
  84174. /**
  84175. * get the rotation matrix of the particle
  84176. * @hidden
  84177. */
  84178. getRotationMatrix(m: Matrix): void;
  84179. }
  84180. /**
  84181. * Represents the shape of the model used by one particle of a solid particle system.
  84182. * SPS internal tool, don't use it manually.
  84183. */
  84184. export class ModelShape {
  84185. /**
  84186. * The shape id
  84187. * @hidden
  84188. */
  84189. shapeID: number;
  84190. /**
  84191. * flat array of model positions (internal use)
  84192. * @hidden
  84193. */
  84194. _shape: Vector3[];
  84195. /**
  84196. * flat array of model UVs (internal use)
  84197. * @hidden
  84198. */
  84199. _shapeUV: number[];
  84200. /**
  84201. * length of the shape in the model indices array (internal use)
  84202. * @hidden
  84203. */
  84204. _indicesLength: number;
  84205. /**
  84206. * Custom position function (internal use)
  84207. * @hidden
  84208. */
  84209. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  84210. /**
  84211. * Custom vertex function (internal use)
  84212. * @hidden
  84213. */
  84214. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  84215. /**
  84216. * 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.
  84217. * SPS internal tool, don't use it manually.
  84218. * @hidden
  84219. */
  84220. 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>);
  84221. }
  84222. /**
  84223. * Represents a Depth Sorted Particle in the solid particle system.
  84224. */
  84225. export class DepthSortedParticle {
  84226. /**
  84227. * Index of the particle in the "indices" array
  84228. */
  84229. ind: number;
  84230. /**
  84231. * Length of the particle shape in the "indices" array
  84232. */
  84233. indicesLength: number;
  84234. /**
  84235. * Squared distance from the particle to the camera
  84236. */
  84237. sqDistance: number;
  84238. }
  84239. }
  84240. declare module BABYLON {
  84241. /**
  84242. * @hidden
  84243. */
  84244. export class _MeshCollisionData {
  84245. _checkCollisions: boolean;
  84246. _collisionMask: number;
  84247. _collisionGroup: number;
  84248. _collider: Nullable<Collider>;
  84249. _oldPositionForCollisions: Vector3;
  84250. _diffPositionForCollisions: Vector3;
  84251. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  84252. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  84253. }
  84254. }
  84255. declare module BABYLON {
  84256. /** @hidden */
  84257. class _FacetDataStorage {
  84258. facetPositions: Vector3[];
  84259. facetNormals: Vector3[];
  84260. facetPartitioning: number[][];
  84261. facetNb: number;
  84262. partitioningSubdivisions: number;
  84263. partitioningBBoxRatio: number;
  84264. facetDataEnabled: boolean;
  84265. facetParameters: any;
  84266. bbSize: Vector3;
  84267. subDiv: {
  84268. max: number;
  84269. X: number;
  84270. Y: number;
  84271. Z: number;
  84272. };
  84273. facetDepthSort: boolean;
  84274. facetDepthSortEnabled: boolean;
  84275. depthSortedIndices: IndicesArray;
  84276. depthSortedFacets: {
  84277. ind: number;
  84278. sqDistance: number;
  84279. }[];
  84280. facetDepthSortFunction: (f1: {
  84281. ind: number;
  84282. sqDistance: number;
  84283. }, f2: {
  84284. ind: number;
  84285. sqDistance: number;
  84286. }) => number;
  84287. facetDepthSortFrom: Vector3;
  84288. facetDepthSortOrigin: Vector3;
  84289. invertedMatrix: Matrix;
  84290. }
  84291. /**
  84292. * @hidden
  84293. **/
  84294. class _InternalAbstractMeshDataInfo {
  84295. _hasVertexAlpha: boolean;
  84296. _useVertexColors: boolean;
  84297. _numBoneInfluencers: number;
  84298. _applyFog: boolean;
  84299. _receiveShadows: boolean;
  84300. _facetData: _FacetDataStorage;
  84301. _visibility: number;
  84302. _skeleton: Nullable<Skeleton>;
  84303. _layerMask: number;
  84304. _computeBonesUsingShaders: boolean;
  84305. _isActive: boolean;
  84306. _onlyForInstances: boolean;
  84307. _isActiveIntermediate: boolean;
  84308. _onlyForInstancesIntermediate: boolean;
  84309. }
  84310. /**
  84311. * Class used to store all common mesh properties
  84312. */
  84313. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  84314. /** No occlusion */
  84315. static OCCLUSION_TYPE_NONE: number;
  84316. /** Occlusion set to optimisitic */
  84317. static OCCLUSION_TYPE_OPTIMISTIC: number;
  84318. /** Occlusion set to strict */
  84319. static OCCLUSION_TYPE_STRICT: number;
  84320. /** Use an accurante occlusion algorithm */
  84321. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  84322. /** Use a conservative occlusion algorithm */
  84323. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  84324. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  84325. * Test order :
  84326. * Is the bounding sphere outside the frustum ?
  84327. * If not, are the bounding box vertices outside the frustum ?
  84328. * It not, then the cullable object is in the frustum.
  84329. */
  84330. static readonly CULLINGSTRATEGY_STANDARD: number;
  84331. /** Culling strategy : Bounding Sphere Only.
  84332. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  84333. * It's also less accurate than the standard because some not visible objects can still be selected.
  84334. * Test : is the bounding sphere outside the frustum ?
  84335. * If not, then the cullable object is in the frustum.
  84336. */
  84337. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  84338. /** Culling strategy : Optimistic Inclusion.
  84339. * This in an inclusion test first, then the standard exclusion test.
  84340. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  84341. * 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.
  84342. * Anyway, it's as accurate as the standard strategy.
  84343. * Test :
  84344. * Is the cullable object bounding sphere center in the frustum ?
  84345. * If not, apply the default culling strategy.
  84346. */
  84347. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  84348. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  84349. * This in an inclusion test first, then the bounding sphere only exclusion test.
  84350. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  84351. * 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.
  84352. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  84353. * Test :
  84354. * Is the cullable object bounding sphere center in the frustum ?
  84355. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  84356. */
  84357. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  84358. /**
  84359. * No billboard
  84360. */
  84361. static readonly BILLBOARDMODE_NONE: number;
  84362. /** Billboard on X axis */
  84363. static readonly BILLBOARDMODE_X: number;
  84364. /** Billboard on Y axis */
  84365. static readonly BILLBOARDMODE_Y: number;
  84366. /** Billboard on Z axis */
  84367. static readonly BILLBOARDMODE_Z: number;
  84368. /** Billboard on all axes */
  84369. static readonly BILLBOARDMODE_ALL: number;
  84370. /** @hidden */
  84371. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  84372. /**
  84373. * The culling strategy to use to check whether the mesh must be rendered or not.
  84374. * This value can be changed at any time and will be used on the next render mesh selection.
  84375. * The possible values are :
  84376. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84377. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84378. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84379. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84380. * Please read each static variable documentation to get details about the culling process.
  84381. * */
  84382. cullingStrategy: number;
  84383. /**
  84384. * Gets the number of facets in the mesh
  84385. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84386. */
  84387. readonly facetNb: number;
  84388. /**
  84389. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  84390. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84391. */
  84392. partitioningSubdivisions: number;
  84393. /**
  84394. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  84395. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  84396. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84397. */
  84398. partitioningBBoxRatio: number;
  84399. /**
  84400. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  84401. * Works only for updatable meshes.
  84402. * Doesn't work with multi-materials
  84403. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84404. */
  84405. mustDepthSortFacets: boolean;
  84406. /**
  84407. * The location (Vector3) where the facet depth sort must be computed from.
  84408. * By default, the active camera position.
  84409. * Used only when facet depth sort is enabled
  84410. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84411. */
  84412. facetDepthSortFrom: Vector3;
  84413. /**
  84414. * gets a boolean indicating if facetData is enabled
  84415. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84416. */
  84417. readonly isFacetDataEnabled: boolean;
  84418. /** @hidden */
  84419. _updateNonUniformScalingState(value: boolean): boolean;
  84420. /**
  84421. * An event triggered when this mesh collides with another one
  84422. */
  84423. onCollideObservable: Observable<AbstractMesh>;
  84424. /** Set a function to call when this mesh collides with another one */
  84425. onCollide: () => void;
  84426. /**
  84427. * An event triggered when the collision's position changes
  84428. */
  84429. onCollisionPositionChangeObservable: Observable<Vector3>;
  84430. /** Set a function to call when the collision's position changes */
  84431. onCollisionPositionChange: () => void;
  84432. /**
  84433. * An event triggered when material is changed
  84434. */
  84435. onMaterialChangedObservable: Observable<AbstractMesh>;
  84436. /**
  84437. * Gets or sets the orientation for POV movement & rotation
  84438. */
  84439. definedFacingForward: boolean;
  84440. /** @hidden */
  84441. _occlusionQuery: Nullable<WebGLQuery>;
  84442. /** @hidden */
  84443. _renderingGroup: Nullable<RenderingGroup>;
  84444. /**
  84445. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84446. */
  84447. /**
  84448. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84449. */
  84450. visibility: number;
  84451. /** Gets or sets the alpha index used to sort transparent meshes
  84452. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  84453. */
  84454. alphaIndex: number;
  84455. /**
  84456. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  84457. */
  84458. isVisible: boolean;
  84459. /**
  84460. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84461. */
  84462. isPickable: boolean;
  84463. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  84464. showSubMeshesBoundingBox: boolean;
  84465. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  84466. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  84467. */
  84468. isBlocker: boolean;
  84469. /**
  84470. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  84471. */
  84472. enablePointerMoveEvents: boolean;
  84473. /**
  84474. * Specifies the rendering group id for this mesh (0 by default)
  84475. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84476. */
  84477. renderingGroupId: number;
  84478. private _material;
  84479. /** Gets or sets current material */
  84480. material: Nullable<Material>;
  84481. /**
  84482. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  84483. * @see http://doc.babylonjs.com/babylon101/shadows
  84484. */
  84485. receiveShadows: boolean;
  84486. /** Defines color to use when rendering outline */
  84487. outlineColor: Color3;
  84488. /** Define width to use when rendering outline */
  84489. outlineWidth: number;
  84490. /** Defines color to use when rendering overlay */
  84491. overlayColor: Color3;
  84492. /** Defines alpha to use when rendering overlay */
  84493. overlayAlpha: number;
  84494. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  84495. hasVertexAlpha: boolean;
  84496. /** 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) */
  84497. useVertexColors: boolean;
  84498. /**
  84499. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  84500. */
  84501. computeBonesUsingShaders: boolean;
  84502. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  84503. numBoneInfluencers: number;
  84504. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  84505. applyFog: boolean;
  84506. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  84507. useOctreeForRenderingSelection: boolean;
  84508. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  84509. useOctreeForPicking: boolean;
  84510. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  84511. useOctreeForCollisions: boolean;
  84512. /**
  84513. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  84514. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  84515. */
  84516. layerMask: number;
  84517. /**
  84518. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  84519. */
  84520. alwaysSelectAsActiveMesh: boolean;
  84521. /**
  84522. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  84523. */
  84524. doNotSyncBoundingInfo: boolean;
  84525. /**
  84526. * Gets or sets the current action manager
  84527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84528. */
  84529. actionManager: Nullable<AbstractActionManager>;
  84530. private _meshCollisionData;
  84531. /**
  84532. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  84533. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84534. */
  84535. ellipsoid: Vector3;
  84536. /**
  84537. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  84538. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84539. */
  84540. ellipsoidOffset: Vector3;
  84541. /**
  84542. * Gets or sets a collision mask used to mask collisions (default is -1).
  84543. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84544. */
  84545. collisionMask: number;
  84546. /**
  84547. * Gets or sets the current collision group mask (-1 by default).
  84548. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84549. */
  84550. collisionGroup: number;
  84551. /**
  84552. * Defines edge width used when edgesRenderer is enabled
  84553. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84554. */
  84555. edgesWidth: number;
  84556. /**
  84557. * Defines edge color used when edgesRenderer is enabled
  84558. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84559. */
  84560. edgesColor: Color4;
  84561. /** @hidden */
  84562. _edgesRenderer: Nullable<IEdgesRenderer>;
  84563. /** @hidden */
  84564. _masterMesh: Nullable<AbstractMesh>;
  84565. /** @hidden */
  84566. _boundingInfo: Nullable<BoundingInfo>;
  84567. /** @hidden */
  84568. _renderId: number;
  84569. /**
  84570. * Gets or sets the list of subMeshes
  84571. * @see http://doc.babylonjs.com/how_to/multi_materials
  84572. */
  84573. subMeshes: SubMesh[];
  84574. /** @hidden */
  84575. _intersectionsInProgress: AbstractMesh[];
  84576. /** @hidden */
  84577. _unIndexed: boolean;
  84578. /** @hidden */
  84579. _lightSources: Light[];
  84580. /** Gets the list of lights affecting that mesh */
  84581. readonly lightSources: Light[];
  84582. /** @hidden */
  84583. readonly _positions: Nullable<Vector3[]>;
  84584. /** @hidden */
  84585. _waitingData: {
  84586. lods: Nullable<any>;
  84587. actions: Nullable<any>;
  84588. freezeWorldMatrix: Nullable<boolean>;
  84589. };
  84590. /** @hidden */
  84591. _bonesTransformMatrices: Nullable<Float32Array>;
  84592. /**
  84593. * Gets or sets a skeleton to apply skining transformations
  84594. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84595. */
  84596. skeleton: Nullable<Skeleton>;
  84597. /**
  84598. * An event triggered when the mesh is rebuilt.
  84599. */
  84600. onRebuildObservable: Observable<AbstractMesh>;
  84601. /**
  84602. * Creates a new AbstractMesh
  84603. * @param name defines the name of the mesh
  84604. * @param scene defines the hosting scene
  84605. */
  84606. constructor(name: string, scene?: Nullable<Scene>);
  84607. /**
  84608. * Returns the string "AbstractMesh"
  84609. * @returns "AbstractMesh"
  84610. */
  84611. getClassName(): string;
  84612. /**
  84613. * Gets a string representation of the current mesh
  84614. * @param fullDetails defines a boolean indicating if full details must be included
  84615. * @returns a string representation of the current mesh
  84616. */
  84617. toString(fullDetails?: boolean): string;
  84618. /**
  84619. * @hidden
  84620. */
  84621. protected _getEffectiveParent(): Nullable<Node>;
  84622. /** @hidden */
  84623. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84624. /** @hidden */
  84625. _rebuild(): void;
  84626. /** @hidden */
  84627. _resyncLightSources(): void;
  84628. /** @hidden */
  84629. _resyncLighSource(light: Light): void;
  84630. /** @hidden */
  84631. _unBindEffect(): void;
  84632. /** @hidden */
  84633. _removeLightSource(light: Light): void;
  84634. private _markSubMeshesAsDirty;
  84635. /** @hidden */
  84636. _markSubMeshesAsLightDirty(): void;
  84637. /** @hidden */
  84638. _markSubMeshesAsAttributesDirty(): void;
  84639. /** @hidden */
  84640. _markSubMeshesAsMiscDirty(): void;
  84641. /**
  84642. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  84643. */
  84644. scaling: Vector3;
  84645. /**
  84646. * Returns true if the mesh is blocked. Implemented by child classes
  84647. */
  84648. readonly isBlocked: boolean;
  84649. /**
  84650. * Returns the mesh itself by default. Implemented by child classes
  84651. * @param camera defines the camera to use to pick the right LOD level
  84652. * @returns the currentAbstractMesh
  84653. */
  84654. getLOD(camera: Camera): Nullable<AbstractMesh>;
  84655. /**
  84656. * Returns 0 by default. Implemented by child classes
  84657. * @returns an integer
  84658. */
  84659. getTotalVertices(): number;
  84660. /**
  84661. * Returns a positive integer : the total number of indices in this mesh geometry.
  84662. * @returns the numner of indices or zero if the mesh has no geometry.
  84663. */
  84664. getTotalIndices(): number;
  84665. /**
  84666. * Returns null by default. Implemented by child classes
  84667. * @returns null
  84668. */
  84669. getIndices(): Nullable<IndicesArray>;
  84670. /**
  84671. * Returns the array of the requested vertex data kind. Implemented by child classes
  84672. * @param kind defines the vertex data kind to use
  84673. * @returns null
  84674. */
  84675. getVerticesData(kind: string): Nullable<FloatArray>;
  84676. /**
  84677. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84678. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84679. * Note that a new underlying VertexBuffer object is created each call.
  84680. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84681. * @param kind defines vertex data kind:
  84682. * * VertexBuffer.PositionKind
  84683. * * VertexBuffer.UVKind
  84684. * * VertexBuffer.UV2Kind
  84685. * * VertexBuffer.UV3Kind
  84686. * * VertexBuffer.UV4Kind
  84687. * * VertexBuffer.UV5Kind
  84688. * * VertexBuffer.UV6Kind
  84689. * * VertexBuffer.ColorKind
  84690. * * VertexBuffer.MatricesIndicesKind
  84691. * * VertexBuffer.MatricesIndicesExtraKind
  84692. * * VertexBuffer.MatricesWeightsKind
  84693. * * VertexBuffer.MatricesWeightsExtraKind
  84694. * @param data defines the data source
  84695. * @param updatable defines if the data must be flagged as updatable (or static)
  84696. * @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
  84697. * @returns the current mesh
  84698. */
  84699. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84700. /**
  84701. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84702. * If the mesh has no geometry, it is simply returned as it is.
  84703. * @param kind defines vertex data kind:
  84704. * * VertexBuffer.PositionKind
  84705. * * VertexBuffer.UVKind
  84706. * * VertexBuffer.UV2Kind
  84707. * * VertexBuffer.UV3Kind
  84708. * * VertexBuffer.UV4Kind
  84709. * * VertexBuffer.UV5Kind
  84710. * * VertexBuffer.UV6Kind
  84711. * * VertexBuffer.ColorKind
  84712. * * VertexBuffer.MatricesIndicesKind
  84713. * * VertexBuffer.MatricesIndicesExtraKind
  84714. * * VertexBuffer.MatricesWeightsKind
  84715. * * VertexBuffer.MatricesWeightsExtraKind
  84716. * @param data defines the data source
  84717. * @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
  84718. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  84719. * @returns the current mesh
  84720. */
  84721. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  84722. /**
  84723. * Sets the mesh indices,
  84724. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84725. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  84726. * @param totalVertices Defines the total number of vertices
  84727. * @returns the current mesh
  84728. */
  84729. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  84730. /**
  84731. * Gets a boolean indicating if specific vertex data is present
  84732. * @param kind defines the vertex data kind to use
  84733. * @returns true is data kind is present
  84734. */
  84735. isVerticesDataPresent(kind: string): boolean;
  84736. /**
  84737. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  84738. * @returns a BoundingInfo
  84739. */
  84740. getBoundingInfo(): BoundingInfo;
  84741. /**
  84742. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  84743. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  84744. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  84745. * @returns the current mesh
  84746. */
  84747. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  84748. /**
  84749. * Overwrite the current bounding info
  84750. * @param boundingInfo defines the new bounding info
  84751. * @returns the current mesh
  84752. */
  84753. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  84754. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  84755. readonly useBones: boolean;
  84756. /** @hidden */
  84757. _preActivate(): void;
  84758. /** @hidden */
  84759. _preActivateForIntermediateRendering(renderId: number): void;
  84760. /** @hidden */
  84761. _activate(renderId: number, intermediateRendering: boolean): boolean;
  84762. /** @hidden */
  84763. _postActivate(): void;
  84764. /** @hidden */
  84765. _freeze(): void;
  84766. /** @hidden */
  84767. _unFreeze(): void;
  84768. /**
  84769. * Gets the current world matrix
  84770. * @returns a Matrix
  84771. */
  84772. getWorldMatrix(): Matrix;
  84773. /** @hidden */
  84774. _getWorldMatrixDeterminant(): number;
  84775. /**
  84776. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  84777. */
  84778. readonly isAnInstance: boolean;
  84779. /**
  84780. * Perform relative position change from the point of view of behind the front of the mesh.
  84781. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84782. * Supports definition of mesh facing forward or backward
  84783. * @param amountRight defines the distance on the right axis
  84784. * @param amountUp defines the distance on the up axis
  84785. * @param amountForward defines the distance on the forward axis
  84786. * @returns the current mesh
  84787. */
  84788. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  84789. /**
  84790. * Calculate relative position change from the point of view of behind the front of the mesh.
  84791. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84792. * Supports definition of mesh facing forward or backward
  84793. * @param amountRight defines the distance on the right axis
  84794. * @param amountUp defines the distance on the up axis
  84795. * @param amountForward defines the distance on the forward axis
  84796. * @returns the new displacement vector
  84797. */
  84798. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  84799. /**
  84800. * Perform relative rotation change from the point of view of behind the front of the mesh.
  84801. * Supports definition of mesh facing forward or backward
  84802. * @param flipBack defines the flip
  84803. * @param twirlClockwise defines the twirl
  84804. * @param tiltRight defines the tilt
  84805. * @returns the current mesh
  84806. */
  84807. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  84808. /**
  84809. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  84810. * Supports definition of mesh facing forward or backward.
  84811. * @param flipBack defines the flip
  84812. * @param twirlClockwise defines the twirl
  84813. * @param tiltRight defines the tilt
  84814. * @returns the new rotation vector
  84815. */
  84816. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  84817. /**
  84818. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84819. * This means the mesh underlying bounding box and sphere are recomputed.
  84820. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84821. * @returns the current mesh
  84822. */
  84823. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  84824. /** @hidden */
  84825. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  84826. /** @hidden */
  84827. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  84828. /** @hidden */
  84829. _updateBoundingInfo(): AbstractMesh;
  84830. /** @hidden */
  84831. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  84832. /** @hidden */
  84833. protected _afterComputeWorldMatrix(): void;
  84834. /** @hidden */
  84835. readonly _effectiveMesh: AbstractMesh;
  84836. /**
  84837. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  84838. * A mesh is in the frustum if its bounding box intersects the frustum
  84839. * @param frustumPlanes defines the frustum to test
  84840. * @returns true if the mesh is in the frustum planes
  84841. */
  84842. isInFrustum(frustumPlanes: Plane[]): boolean;
  84843. /**
  84844. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  84845. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  84846. * @param frustumPlanes defines the frustum to test
  84847. * @returns true if the mesh is completely in the frustum planes
  84848. */
  84849. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84850. /**
  84851. * True if the mesh intersects another mesh or a SolidParticle object
  84852. * @param mesh defines a target mesh or SolidParticle to test
  84853. * @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)
  84854. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  84855. * @returns true if there is an intersection
  84856. */
  84857. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  84858. /**
  84859. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  84860. * @param point defines the point to test
  84861. * @returns true if there is an intersection
  84862. */
  84863. intersectsPoint(point: Vector3): boolean;
  84864. /**
  84865. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  84866. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84867. */
  84868. checkCollisions: boolean;
  84869. /**
  84870. * Gets Collider object used to compute collisions (not physics)
  84871. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84872. */
  84873. readonly collider: Nullable<Collider>;
  84874. /**
  84875. * Move the mesh using collision engine
  84876. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84877. * @param displacement defines the requested displacement vector
  84878. * @returns the current mesh
  84879. */
  84880. moveWithCollisions(displacement: Vector3): AbstractMesh;
  84881. private _onCollisionPositionChange;
  84882. /** @hidden */
  84883. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  84884. /** @hidden */
  84885. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  84886. /** @hidden */
  84887. _checkCollision(collider: Collider): AbstractMesh;
  84888. /** @hidden */
  84889. _generatePointsArray(): boolean;
  84890. /**
  84891. * Checks if the passed Ray intersects with the mesh
  84892. * @param ray defines the ray to use
  84893. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  84894. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84895. * @returns the picking info
  84896. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84897. */
  84898. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  84899. /**
  84900. * Clones the current mesh
  84901. * @param name defines the mesh name
  84902. * @param newParent defines the new mesh parent
  84903. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  84904. * @returns the new mesh
  84905. */
  84906. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84907. /**
  84908. * Disposes all the submeshes of the current meshnp
  84909. * @returns the current mesh
  84910. */
  84911. releaseSubMeshes(): AbstractMesh;
  84912. /**
  84913. * Releases resources associated with this abstract mesh.
  84914. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84915. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84916. */
  84917. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84918. /**
  84919. * Adds the passed mesh as a child to the current mesh
  84920. * @param mesh defines the child mesh
  84921. * @returns the current mesh
  84922. */
  84923. addChild(mesh: AbstractMesh): AbstractMesh;
  84924. /**
  84925. * Removes the passed mesh from the current mesh children list
  84926. * @param mesh defines the child mesh
  84927. * @returns the current mesh
  84928. */
  84929. removeChild(mesh: AbstractMesh): AbstractMesh;
  84930. /** @hidden */
  84931. private _initFacetData;
  84932. /**
  84933. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  84934. * This method can be called within the render loop.
  84935. * 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
  84936. * @returns the current mesh
  84937. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84938. */
  84939. updateFacetData(): AbstractMesh;
  84940. /**
  84941. * Returns the facetLocalNormals array.
  84942. * The normals are expressed in the mesh local spac
  84943. * @returns an array of Vector3
  84944. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84945. */
  84946. getFacetLocalNormals(): Vector3[];
  84947. /**
  84948. * Returns the facetLocalPositions array.
  84949. * The facet positions are expressed in the mesh local space
  84950. * @returns an array of Vector3
  84951. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84952. */
  84953. getFacetLocalPositions(): Vector3[];
  84954. /**
  84955. * Returns the facetLocalPartioning array
  84956. * @returns an array of array of numbers
  84957. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84958. */
  84959. getFacetLocalPartitioning(): number[][];
  84960. /**
  84961. * Returns the i-th facet position in the world system.
  84962. * This method allocates a new Vector3 per call
  84963. * @param i defines the facet index
  84964. * @returns a new Vector3
  84965. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84966. */
  84967. getFacetPosition(i: number): Vector3;
  84968. /**
  84969. * Sets the reference Vector3 with the i-th facet position in the world system
  84970. * @param i defines the facet index
  84971. * @param ref defines the target vector
  84972. * @returns the current mesh
  84973. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84974. */
  84975. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  84976. /**
  84977. * Returns the i-th facet normal in the world system.
  84978. * This method allocates a new Vector3 per call
  84979. * @param i defines the facet index
  84980. * @returns a new Vector3
  84981. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84982. */
  84983. getFacetNormal(i: number): Vector3;
  84984. /**
  84985. * Sets the reference Vector3 with the i-th facet normal in the world system
  84986. * @param i defines the facet index
  84987. * @param ref defines the target vector
  84988. * @returns the current mesh
  84989. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84990. */
  84991. getFacetNormalToRef(i: number, ref: Vector3): this;
  84992. /**
  84993. * 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)
  84994. * @param x defines x coordinate
  84995. * @param y defines y coordinate
  84996. * @param z defines z coordinate
  84997. * @returns the array of facet indexes
  84998. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84999. */
  85000. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  85001. /**
  85002. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  85003. * @param projected sets as the (x,y,z) world projection on the facet
  85004. * @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
  85005. * @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
  85006. * @param x defines x coordinate
  85007. * @param y defines y coordinate
  85008. * @param z defines z coordinate
  85009. * @returns the face index if found (or null instead)
  85010. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85011. */
  85012. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  85013. /**
  85014. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  85015. * @param projected sets as the (x,y,z) local projection on the facet
  85016. * @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
  85017. * @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
  85018. * @param x defines x coordinate
  85019. * @param y defines y coordinate
  85020. * @param z defines z coordinate
  85021. * @returns the face index if found (or null instead)
  85022. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85023. */
  85024. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  85025. /**
  85026. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  85027. * @returns the parameters
  85028. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85029. */
  85030. getFacetDataParameters(): any;
  85031. /**
  85032. * Disables the feature FacetData and frees the related memory
  85033. * @returns the current mesh
  85034. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  85035. */
  85036. disableFacetData(): AbstractMesh;
  85037. /**
  85038. * Updates the AbstractMesh indices array
  85039. * @param indices defines the data source
  85040. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  85041. * @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)
  85042. * @returns the current mesh
  85043. */
  85044. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  85045. /**
  85046. * Creates new normals data for the mesh
  85047. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  85048. * @returns the current mesh
  85049. */
  85050. createNormals(updatable: boolean): AbstractMesh;
  85051. /**
  85052. * Align the mesh with a normal
  85053. * @param normal defines the normal to use
  85054. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  85055. * @returns the current mesh
  85056. */
  85057. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  85058. /** @hidden */
  85059. _checkOcclusionQuery(): boolean;
  85060. /**
  85061. * Disables the mesh edge rendering mode
  85062. * @returns the currentAbstractMesh
  85063. */
  85064. disableEdgesRendering(): AbstractMesh;
  85065. /**
  85066. * Enables the edge rendering mode on the mesh.
  85067. * This mode makes the mesh edges visible
  85068. * @param epsilon defines the maximal distance between two angles to detect a face
  85069. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85070. * @returns the currentAbstractMesh
  85071. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85072. */
  85073. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  85074. }
  85075. }
  85076. declare module BABYLON {
  85077. /**
  85078. * Interface used to define ActionEvent
  85079. */
  85080. export interface IActionEvent {
  85081. /** The mesh or sprite that triggered the action */
  85082. source: any;
  85083. /** The X mouse cursor position at the time of the event */
  85084. pointerX: number;
  85085. /** The Y mouse cursor position at the time of the event */
  85086. pointerY: number;
  85087. /** The mesh that is currently pointed at (can be null) */
  85088. meshUnderPointer: Nullable<AbstractMesh>;
  85089. /** the original (browser) event that triggered the ActionEvent */
  85090. sourceEvent?: any;
  85091. /** additional data for the event */
  85092. additionalData?: any;
  85093. }
  85094. /**
  85095. * ActionEvent is the event being sent when an action is triggered.
  85096. */
  85097. export class ActionEvent implements IActionEvent {
  85098. /** The mesh or sprite that triggered the action */
  85099. source: any;
  85100. /** The X mouse cursor position at the time of the event */
  85101. pointerX: number;
  85102. /** The Y mouse cursor position at the time of the event */
  85103. pointerY: number;
  85104. /** The mesh that is currently pointed at (can be null) */
  85105. meshUnderPointer: Nullable<AbstractMesh>;
  85106. /** the original (browser) event that triggered the ActionEvent */
  85107. sourceEvent?: any;
  85108. /** additional data for the event */
  85109. additionalData?: any;
  85110. /**
  85111. * Creates a new ActionEvent
  85112. * @param source The mesh or sprite that triggered the action
  85113. * @param pointerX The X mouse cursor position at the time of the event
  85114. * @param pointerY The Y mouse cursor position at the time of the event
  85115. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  85116. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  85117. * @param additionalData additional data for the event
  85118. */
  85119. constructor(
  85120. /** The mesh or sprite that triggered the action */
  85121. source: any,
  85122. /** The X mouse cursor position at the time of the event */
  85123. pointerX: number,
  85124. /** The Y mouse cursor position at the time of the event */
  85125. pointerY: number,
  85126. /** The mesh that is currently pointed at (can be null) */
  85127. meshUnderPointer: Nullable<AbstractMesh>,
  85128. /** the original (browser) event that triggered the ActionEvent */
  85129. sourceEvent?: any,
  85130. /** additional data for the event */
  85131. additionalData?: any);
  85132. /**
  85133. * Helper function to auto-create an ActionEvent from a source mesh.
  85134. * @param source The source mesh that triggered the event
  85135. * @param evt The original (browser) event
  85136. * @param additionalData additional data for the event
  85137. * @returns the new ActionEvent
  85138. */
  85139. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  85140. /**
  85141. * Helper function to auto-create an ActionEvent from a source sprite
  85142. * @param source The source sprite that triggered the event
  85143. * @param scene Scene associated with the sprite
  85144. * @param evt The original (browser) event
  85145. * @param additionalData additional data for the event
  85146. * @returns the new ActionEvent
  85147. */
  85148. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  85149. /**
  85150. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  85151. * @param scene the scene where the event occurred
  85152. * @param evt The original (browser) event
  85153. * @returns the new ActionEvent
  85154. */
  85155. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  85156. /**
  85157. * Helper function to auto-create an ActionEvent from a primitive
  85158. * @param prim defines the target primitive
  85159. * @param pointerPos defines the pointer position
  85160. * @param evt The original (browser) event
  85161. * @param additionalData additional data for the event
  85162. * @returns the new ActionEvent
  85163. */
  85164. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  85165. }
  85166. }
  85167. declare module BABYLON {
  85168. /**
  85169. * Abstract class used to decouple action Manager from scene and meshes.
  85170. * Do not instantiate.
  85171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  85172. */
  85173. export abstract class AbstractActionManager implements IDisposable {
  85174. /** Gets the list of active triggers */
  85175. static Triggers: {
  85176. [key: string]: number;
  85177. };
  85178. /** Gets the cursor to use when hovering items */
  85179. hoverCursor: string;
  85180. /** Gets the list of actions */
  85181. actions: IAction[];
  85182. /**
  85183. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  85184. */
  85185. isRecursive: boolean;
  85186. /**
  85187. * Releases all associated resources
  85188. */
  85189. abstract dispose(): void;
  85190. /**
  85191. * Does this action manager has pointer triggers
  85192. */
  85193. abstract readonly hasPointerTriggers: boolean;
  85194. /**
  85195. * Does this action manager has pick triggers
  85196. */
  85197. abstract readonly hasPickTriggers: boolean;
  85198. /**
  85199. * Process a specific trigger
  85200. * @param trigger defines the trigger to process
  85201. * @param evt defines the event details to be processed
  85202. */
  85203. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  85204. /**
  85205. * Does this action manager handles actions of any of the given triggers
  85206. * @param triggers defines the triggers to be tested
  85207. * @return a boolean indicating whether one (or more) of the triggers is handled
  85208. */
  85209. abstract hasSpecificTriggers(triggers: number[]): boolean;
  85210. /**
  85211. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  85212. * speed.
  85213. * @param triggerA defines the trigger to be tested
  85214. * @param triggerB defines the trigger to be tested
  85215. * @return a boolean indicating whether one (or more) of the triggers is handled
  85216. */
  85217. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  85218. /**
  85219. * Does this action manager handles actions of a given trigger
  85220. * @param trigger defines the trigger to be tested
  85221. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  85222. * @return whether the trigger is handled
  85223. */
  85224. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  85225. /**
  85226. * Serialize this manager to a JSON object
  85227. * @param name defines the property name to store this manager
  85228. * @returns a JSON representation of this manager
  85229. */
  85230. abstract serialize(name: string): any;
  85231. /**
  85232. * Registers an action to this action manager
  85233. * @param action defines the action to be registered
  85234. * @return the action amended (prepared) after registration
  85235. */
  85236. abstract registerAction(action: IAction): Nullable<IAction>;
  85237. /**
  85238. * Unregisters an action to this action manager
  85239. * @param action defines the action to be unregistered
  85240. * @return a boolean indicating whether the action has been unregistered
  85241. */
  85242. abstract unregisterAction(action: IAction): Boolean;
  85243. /**
  85244. * Does exist one action manager with at least one trigger
  85245. **/
  85246. static readonly HasTriggers: boolean;
  85247. /**
  85248. * Does exist one action manager with at least one pick trigger
  85249. **/
  85250. static readonly HasPickTriggers: boolean;
  85251. /**
  85252. * Does exist one action manager that handles actions of a given trigger
  85253. * @param trigger defines the trigger to be tested
  85254. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  85255. **/
  85256. static HasSpecificTrigger(trigger: number): boolean;
  85257. }
  85258. }
  85259. declare module BABYLON {
  85260. /**
  85261. * Defines how a node can be built from a string name.
  85262. */
  85263. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  85264. /**
  85265. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  85266. */
  85267. export class Node implements IBehaviorAware<Node> {
  85268. /** @hidden */
  85269. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  85270. private static _NodeConstructors;
  85271. /**
  85272. * Add a new node constructor
  85273. * @param type defines the type name of the node to construct
  85274. * @param constructorFunc defines the constructor function
  85275. */
  85276. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  85277. /**
  85278. * Returns a node constructor based on type name
  85279. * @param type defines the type name
  85280. * @param name defines the new node name
  85281. * @param scene defines the hosting scene
  85282. * @param options defines optional options to transmit to constructors
  85283. * @returns the new constructor or null
  85284. */
  85285. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  85286. /**
  85287. * Gets or sets the name of the node
  85288. */
  85289. name: string;
  85290. /**
  85291. * Gets or sets the id of the node
  85292. */
  85293. id: string;
  85294. /**
  85295. * Gets or sets the unique id of the node
  85296. */
  85297. uniqueId: number;
  85298. /**
  85299. * Gets or sets a string used to store user defined state for the node
  85300. */
  85301. state: string;
  85302. /**
  85303. * Gets or sets an object used to store user defined information for the node
  85304. */
  85305. metadata: any;
  85306. /**
  85307. * For internal use only. Please do not use.
  85308. */
  85309. reservedDataStore: any;
  85310. /**
  85311. * List of inspectable custom properties (used by the Inspector)
  85312. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85313. */
  85314. inspectableCustomProperties: IInspectable[];
  85315. /**
  85316. * Gets or sets a boolean used to define if the node must be serialized
  85317. */
  85318. doNotSerialize: boolean;
  85319. /** @hidden */
  85320. _isDisposed: boolean;
  85321. /**
  85322. * Gets a list of Animations associated with the node
  85323. */
  85324. animations: Animation[];
  85325. protected _ranges: {
  85326. [name: string]: Nullable<AnimationRange>;
  85327. };
  85328. /**
  85329. * Callback raised when the node is ready to be used
  85330. */
  85331. onReady: Nullable<(node: Node) => void>;
  85332. private _isEnabled;
  85333. private _isParentEnabled;
  85334. private _isReady;
  85335. /** @hidden */
  85336. _currentRenderId: number;
  85337. private _parentUpdateId;
  85338. /** @hidden */
  85339. _childUpdateId: number;
  85340. /** @hidden */
  85341. _waitingParentId: Nullable<string>;
  85342. /** @hidden */
  85343. _scene: Scene;
  85344. /** @hidden */
  85345. _cache: any;
  85346. private _parentNode;
  85347. private _children;
  85348. /** @hidden */
  85349. _worldMatrix: Matrix;
  85350. /** @hidden */
  85351. _worldMatrixDeterminant: number;
  85352. /** @hidden */
  85353. _worldMatrixDeterminantIsDirty: boolean;
  85354. /** @hidden */
  85355. private _sceneRootNodesIndex;
  85356. /**
  85357. * Gets a boolean indicating if the node has been disposed
  85358. * @returns true if the node was disposed
  85359. */
  85360. isDisposed(): boolean;
  85361. /**
  85362. * Gets or sets the parent of the node (without keeping the current position in the scene)
  85363. * @see https://doc.babylonjs.com/how_to/parenting
  85364. */
  85365. parent: Nullable<Node>;
  85366. private addToSceneRootNodes;
  85367. private removeFromSceneRootNodes;
  85368. private _animationPropertiesOverride;
  85369. /**
  85370. * Gets or sets the animation properties override
  85371. */
  85372. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85373. /**
  85374. * Gets a string idenfifying the name of the class
  85375. * @returns "Node" string
  85376. */
  85377. getClassName(): string;
  85378. /** @hidden */
  85379. readonly _isNode: boolean;
  85380. /**
  85381. * An event triggered when the mesh is disposed
  85382. */
  85383. onDisposeObservable: Observable<Node>;
  85384. private _onDisposeObserver;
  85385. /**
  85386. * Sets a callback that will be raised when the node will be disposed
  85387. */
  85388. onDispose: () => void;
  85389. /**
  85390. * Creates a new Node
  85391. * @param name the name and id to be given to this node
  85392. * @param scene the scene this node will be added to
  85393. * @param addToRootNodes the node will be added to scene.rootNodes
  85394. */
  85395. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  85396. /**
  85397. * Gets the scene of the node
  85398. * @returns a scene
  85399. */
  85400. getScene(): Scene;
  85401. /**
  85402. * Gets the engine of the node
  85403. * @returns a Engine
  85404. */
  85405. getEngine(): Engine;
  85406. private _behaviors;
  85407. /**
  85408. * Attach a behavior to the node
  85409. * @see http://doc.babylonjs.com/features/behaviour
  85410. * @param behavior defines the behavior to attach
  85411. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  85412. * @returns the current Node
  85413. */
  85414. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  85415. /**
  85416. * Remove an attached behavior
  85417. * @see http://doc.babylonjs.com/features/behaviour
  85418. * @param behavior defines the behavior to attach
  85419. * @returns the current Node
  85420. */
  85421. removeBehavior(behavior: Behavior<Node>): Node;
  85422. /**
  85423. * Gets the list of attached behaviors
  85424. * @see http://doc.babylonjs.com/features/behaviour
  85425. */
  85426. readonly behaviors: Behavior<Node>[];
  85427. /**
  85428. * Gets an attached behavior by name
  85429. * @param name defines the name of the behavior to look for
  85430. * @see http://doc.babylonjs.com/features/behaviour
  85431. * @returns null if behavior was not found else the requested behavior
  85432. */
  85433. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  85434. /**
  85435. * Returns the latest update of the World matrix
  85436. * @returns a Matrix
  85437. */
  85438. getWorldMatrix(): Matrix;
  85439. /** @hidden */
  85440. _getWorldMatrixDeterminant(): number;
  85441. /**
  85442. * Returns directly the latest state of the mesh World matrix.
  85443. * A Matrix is returned.
  85444. */
  85445. readonly worldMatrixFromCache: Matrix;
  85446. /** @hidden */
  85447. _initCache(): void;
  85448. /** @hidden */
  85449. updateCache(force?: boolean): void;
  85450. /** @hidden */
  85451. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  85452. /** @hidden */
  85453. _updateCache(ignoreParentClass?: boolean): void;
  85454. /** @hidden */
  85455. _isSynchronized(): boolean;
  85456. /** @hidden */
  85457. _markSyncedWithParent(): void;
  85458. /** @hidden */
  85459. isSynchronizedWithParent(): boolean;
  85460. /** @hidden */
  85461. isSynchronized(): boolean;
  85462. /**
  85463. * Is this node ready to be used/rendered
  85464. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85465. * @return true if the node is ready
  85466. */
  85467. isReady(completeCheck?: boolean): boolean;
  85468. /**
  85469. * Is this node enabled?
  85470. * 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
  85471. * @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
  85472. * @return whether this node (and its parent) is enabled
  85473. */
  85474. isEnabled(checkAncestors?: boolean): boolean;
  85475. /** @hidden */
  85476. protected _syncParentEnabledState(): void;
  85477. /**
  85478. * Set the enabled state of this node
  85479. * @param value defines the new enabled state
  85480. */
  85481. setEnabled(value: boolean): void;
  85482. /**
  85483. * Is this node a descendant of the given node?
  85484. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  85485. * @param ancestor defines the parent node to inspect
  85486. * @returns a boolean indicating if this node is a descendant of the given node
  85487. */
  85488. isDescendantOf(ancestor: Node): boolean;
  85489. /** @hidden */
  85490. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  85491. /**
  85492. * Will return all nodes that have this node as ascendant
  85493. * @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
  85494. * @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
  85495. * @return all children nodes of all types
  85496. */
  85497. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  85498. /**
  85499. * Get all child-meshes of this node
  85500. * @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)
  85501. * @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
  85502. * @returns an array of AbstractMesh
  85503. */
  85504. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  85505. /**
  85506. * Get all direct children of this node
  85507. * @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
  85508. * @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)
  85509. * @returns an array of Node
  85510. */
  85511. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  85512. /** @hidden */
  85513. _setReady(state: boolean): void;
  85514. /**
  85515. * Get an animation by name
  85516. * @param name defines the name of the animation to look for
  85517. * @returns null if not found else the requested animation
  85518. */
  85519. getAnimationByName(name: string): Nullable<Animation>;
  85520. /**
  85521. * Creates an animation range for this node
  85522. * @param name defines the name of the range
  85523. * @param from defines the starting key
  85524. * @param to defines the end key
  85525. */
  85526. createAnimationRange(name: string, from: number, to: number): void;
  85527. /**
  85528. * Delete a specific animation range
  85529. * @param name defines the name of the range to delete
  85530. * @param deleteFrames defines if animation frames from the range must be deleted as well
  85531. */
  85532. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  85533. /**
  85534. * Get an animation range by name
  85535. * @param name defines the name of the animation range to look for
  85536. * @returns null if not found else the requested animation range
  85537. */
  85538. getAnimationRange(name: string): Nullable<AnimationRange>;
  85539. /**
  85540. * Gets the list of all animation ranges defined on this node
  85541. * @returns an array
  85542. */
  85543. getAnimationRanges(): Nullable<AnimationRange>[];
  85544. /**
  85545. * Will start the animation sequence
  85546. * @param name defines the range frames for animation sequence
  85547. * @param loop defines if the animation should loop (false by default)
  85548. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  85549. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  85550. * @returns the object created for this animation. If range does not exist, it will return null
  85551. */
  85552. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  85553. /**
  85554. * Serialize animation ranges into a JSON compatible object
  85555. * @returns serialization object
  85556. */
  85557. serializeAnimationRanges(): any;
  85558. /**
  85559. * Computes the world matrix of the node
  85560. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85561. * @returns the world matrix
  85562. */
  85563. computeWorldMatrix(force?: boolean): Matrix;
  85564. /**
  85565. * Releases resources associated with this node.
  85566. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85567. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85568. */
  85569. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85570. /**
  85571. * Parse animation range data from a serialization object and store them into a given node
  85572. * @param node defines where to store the animation ranges
  85573. * @param parsedNode defines the serialization object to read data from
  85574. * @param scene defines the hosting scene
  85575. */
  85576. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  85577. /**
  85578. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  85579. * @param includeDescendants Include bounding info from descendants as well (true by default)
  85580. * @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
  85581. * @returns the new bounding vectors
  85582. */
  85583. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  85584. min: Vector3;
  85585. max: Vector3;
  85586. };
  85587. }
  85588. }
  85589. declare module BABYLON {
  85590. /**
  85591. * @hidden
  85592. */
  85593. export class _IAnimationState {
  85594. key: number;
  85595. repeatCount: number;
  85596. workValue?: any;
  85597. loopMode?: number;
  85598. offsetValue?: any;
  85599. highLimitValue?: any;
  85600. }
  85601. /**
  85602. * Class used to store any kind of animation
  85603. */
  85604. export class Animation {
  85605. /**Name of the animation */
  85606. name: string;
  85607. /**Property to animate */
  85608. targetProperty: string;
  85609. /**The frames per second of the animation */
  85610. framePerSecond: number;
  85611. /**The data type of the animation */
  85612. dataType: number;
  85613. /**The loop mode of the animation */
  85614. loopMode?: number | undefined;
  85615. /**Specifies if blending should be enabled */
  85616. enableBlending?: boolean | undefined;
  85617. /**
  85618. * Use matrix interpolation instead of using direct key value when animating matrices
  85619. */
  85620. static AllowMatricesInterpolation: boolean;
  85621. /**
  85622. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  85623. */
  85624. static AllowMatrixDecomposeForInterpolation: boolean;
  85625. /**
  85626. * Stores the key frames of the animation
  85627. */
  85628. private _keys;
  85629. /**
  85630. * Stores the easing function of the animation
  85631. */
  85632. private _easingFunction;
  85633. /**
  85634. * @hidden Internal use only
  85635. */
  85636. _runtimeAnimations: RuntimeAnimation[];
  85637. /**
  85638. * The set of event that will be linked to this animation
  85639. */
  85640. private _events;
  85641. /**
  85642. * Stores an array of target property paths
  85643. */
  85644. targetPropertyPath: string[];
  85645. /**
  85646. * Stores the blending speed of the animation
  85647. */
  85648. blendingSpeed: number;
  85649. /**
  85650. * Stores the animation ranges for the animation
  85651. */
  85652. private _ranges;
  85653. /**
  85654. * @hidden Internal use
  85655. */
  85656. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  85657. /**
  85658. * Sets up an animation
  85659. * @param property The property to animate
  85660. * @param animationType The animation type to apply
  85661. * @param framePerSecond The frames per second of the animation
  85662. * @param easingFunction The easing function used in the animation
  85663. * @returns The created animation
  85664. */
  85665. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  85666. /**
  85667. * Create and start an animation on a node
  85668. * @param name defines the name of the global animation that will be run on all nodes
  85669. * @param node defines the root node where the animation will take place
  85670. * @param targetProperty defines property to animate
  85671. * @param framePerSecond defines the number of frame per second yo use
  85672. * @param totalFrame defines the number of frames in total
  85673. * @param from defines the initial value
  85674. * @param to defines the final value
  85675. * @param loopMode defines which loop mode you want to use (off by default)
  85676. * @param easingFunction defines the easing function to use (linear by default)
  85677. * @param onAnimationEnd defines the callback to call when animation end
  85678. * @returns the animatable created for this animation
  85679. */
  85680. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85681. /**
  85682. * Create and start an animation on a node and its descendants
  85683. * @param name defines the name of the global animation that will be run on all nodes
  85684. * @param node defines the root node where the animation will take place
  85685. * @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
  85686. * @param targetProperty defines property to animate
  85687. * @param framePerSecond defines the number of frame per second to use
  85688. * @param totalFrame defines the number of frames in total
  85689. * @param from defines the initial value
  85690. * @param to defines the final value
  85691. * @param loopMode defines which loop mode you want to use (off by default)
  85692. * @param easingFunction defines the easing function to use (linear by default)
  85693. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85694. * @returns the list of animatables created for all nodes
  85695. * @example https://www.babylonjs-playground.com/#MH0VLI
  85696. */
  85697. 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[]>;
  85698. /**
  85699. * Creates a new animation, merges it with the existing animations and starts it
  85700. * @param name Name of the animation
  85701. * @param node Node which contains the scene that begins the animations
  85702. * @param targetProperty Specifies which property to animate
  85703. * @param framePerSecond The frames per second of the animation
  85704. * @param totalFrame The total number of frames
  85705. * @param from The frame at the beginning of the animation
  85706. * @param to The frame at the end of the animation
  85707. * @param loopMode Specifies the loop mode of the animation
  85708. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  85709. * @param onAnimationEnd Callback to run once the animation is complete
  85710. * @returns Nullable animation
  85711. */
  85712. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85713. /**
  85714. * Transition property of an host to the target Value
  85715. * @param property The property to transition
  85716. * @param targetValue The target Value of the property
  85717. * @param host The object where the property to animate belongs
  85718. * @param scene Scene used to run the animation
  85719. * @param frameRate Framerate (in frame/s) to use
  85720. * @param transition The transition type we want to use
  85721. * @param duration The duration of the animation, in milliseconds
  85722. * @param onAnimationEnd Callback trigger at the end of the animation
  85723. * @returns Nullable animation
  85724. */
  85725. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  85726. /**
  85727. * Return the array of runtime animations currently using this animation
  85728. */
  85729. readonly runtimeAnimations: RuntimeAnimation[];
  85730. /**
  85731. * Specifies if any of the runtime animations are currently running
  85732. */
  85733. readonly hasRunningRuntimeAnimations: boolean;
  85734. /**
  85735. * Initializes the animation
  85736. * @param name Name of the animation
  85737. * @param targetProperty Property to animate
  85738. * @param framePerSecond The frames per second of the animation
  85739. * @param dataType The data type of the animation
  85740. * @param loopMode The loop mode of the animation
  85741. * @param enableBlending Specifies if blending should be enabled
  85742. */
  85743. constructor(
  85744. /**Name of the animation */
  85745. name: string,
  85746. /**Property to animate */
  85747. targetProperty: string,
  85748. /**The frames per second of the animation */
  85749. framePerSecond: number,
  85750. /**The data type of the animation */
  85751. dataType: number,
  85752. /**The loop mode of the animation */
  85753. loopMode?: number | undefined,
  85754. /**Specifies if blending should be enabled */
  85755. enableBlending?: boolean | undefined);
  85756. /**
  85757. * Converts the animation to a string
  85758. * @param fullDetails support for multiple levels of logging within scene loading
  85759. * @returns String form of the animation
  85760. */
  85761. toString(fullDetails?: boolean): string;
  85762. /**
  85763. * Add an event to this animation
  85764. * @param event Event to add
  85765. */
  85766. addEvent(event: AnimationEvent): void;
  85767. /**
  85768. * Remove all events found at the given frame
  85769. * @param frame The frame to remove events from
  85770. */
  85771. removeEvents(frame: number): void;
  85772. /**
  85773. * Retrieves all the events from the animation
  85774. * @returns Events from the animation
  85775. */
  85776. getEvents(): AnimationEvent[];
  85777. /**
  85778. * Creates an animation range
  85779. * @param name Name of the animation range
  85780. * @param from Starting frame of the animation range
  85781. * @param to Ending frame of the animation
  85782. */
  85783. createRange(name: string, from: number, to: number): void;
  85784. /**
  85785. * Deletes an animation range by name
  85786. * @param name Name of the animation range to delete
  85787. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  85788. */
  85789. deleteRange(name: string, deleteFrames?: boolean): void;
  85790. /**
  85791. * Gets the animation range by name, or null if not defined
  85792. * @param name Name of the animation range
  85793. * @returns Nullable animation range
  85794. */
  85795. getRange(name: string): Nullable<AnimationRange>;
  85796. /**
  85797. * Gets the key frames from the animation
  85798. * @returns The key frames of the animation
  85799. */
  85800. getKeys(): Array<IAnimationKey>;
  85801. /**
  85802. * Gets the highest frame rate of the animation
  85803. * @returns Highest frame rate of the animation
  85804. */
  85805. getHighestFrame(): number;
  85806. /**
  85807. * Gets the easing function of the animation
  85808. * @returns Easing function of the animation
  85809. */
  85810. getEasingFunction(): IEasingFunction;
  85811. /**
  85812. * Sets the easing function of the animation
  85813. * @param easingFunction A custom mathematical formula for animation
  85814. */
  85815. setEasingFunction(easingFunction: EasingFunction): void;
  85816. /**
  85817. * Interpolates a scalar linearly
  85818. * @param startValue Start value of the animation curve
  85819. * @param endValue End value of the animation curve
  85820. * @param gradient Scalar amount to interpolate
  85821. * @returns Interpolated scalar value
  85822. */
  85823. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  85824. /**
  85825. * Interpolates a scalar cubically
  85826. * @param startValue Start value of the animation curve
  85827. * @param outTangent End tangent of the animation
  85828. * @param endValue End value of the animation curve
  85829. * @param inTangent Start tangent of the animation curve
  85830. * @param gradient Scalar amount to interpolate
  85831. * @returns Interpolated scalar value
  85832. */
  85833. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  85834. /**
  85835. * Interpolates a quaternion using a spherical linear interpolation
  85836. * @param startValue Start value of the animation curve
  85837. * @param endValue End value of the animation curve
  85838. * @param gradient Scalar amount to interpolate
  85839. * @returns Interpolated quaternion value
  85840. */
  85841. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  85842. /**
  85843. * Interpolates a quaternion cubically
  85844. * @param startValue Start value of the animation curve
  85845. * @param outTangent End tangent of the animation curve
  85846. * @param endValue End value of the animation curve
  85847. * @param inTangent Start tangent of the animation curve
  85848. * @param gradient Scalar amount to interpolate
  85849. * @returns Interpolated quaternion value
  85850. */
  85851. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  85852. /**
  85853. * Interpolates a Vector3 linearl
  85854. * @param startValue Start value of the animation curve
  85855. * @param endValue End value of the animation curve
  85856. * @param gradient Scalar amount to interpolate
  85857. * @returns Interpolated scalar value
  85858. */
  85859. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  85860. /**
  85861. * Interpolates a Vector3 cubically
  85862. * @param startValue Start value of the animation curve
  85863. * @param outTangent End tangent of the animation
  85864. * @param endValue End value of the animation curve
  85865. * @param inTangent Start tangent of the animation curve
  85866. * @param gradient Scalar amount to interpolate
  85867. * @returns InterpolatedVector3 value
  85868. */
  85869. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  85870. /**
  85871. * Interpolates a Vector2 linearly
  85872. * @param startValue Start value of the animation curve
  85873. * @param endValue End value of the animation curve
  85874. * @param gradient Scalar amount to interpolate
  85875. * @returns Interpolated Vector2 value
  85876. */
  85877. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  85878. /**
  85879. * Interpolates a Vector2 cubically
  85880. * @param startValue Start value of the animation curve
  85881. * @param outTangent End tangent of the animation
  85882. * @param endValue End value of the animation curve
  85883. * @param inTangent Start tangent of the animation curve
  85884. * @param gradient Scalar amount to interpolate
  85885. * @returns Interpolated Vector2 value
  85886. */
  85887. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  85888. /**
  85889. * Interpolates a size linearly
  85890. * @param startValue Start value of the animation curve
  85891. * @param endValue End value of the animation curve
  85892. * @param gradient Scalar amount to interpolate
  85893. * @returns Interpolated Size value
  85894. */
  85895. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  85896. /**
  85897. * Interpolates a Color3 linearly
  85898. * @param startValue Start value of the animation curve
  85899. * @param endValue End value of the animation curve
  85900. * @param gradient Scalar amount to interpolate
  85901. * @returns Interpolated Color3 value
  85902. */
  85903. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  85904. /**
  85905. * @hidden Internal use only
  85906. */
  85907. _getKeyValue(value: any): any;
  85908. /**
  85909. * @hidden Internal use only
  85910. */
  85911. _interpolate(currentFrame: number, state: _IAnimationState): any;
  85912. /**
  85913. * Defines the function to use to interpolate matrices
  85914. * @param startValue defines the start matrix
  85915. * @param endValue defines the end matrix
  85916. * @param gradient defines the gradient between both matrices
  85917. * @param result defines an optional target matrix where to store the interpolation
  85918. * @returns the interpolated matrix
  85919. */
  85920. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  85921. /**
  85922. * Makes a copy of the animation
  85923. * @returns Cloned animation
  85924. */
  85925. clone(): Animation;
  85926. /**
  85927. * Sets the key frames of the animation
  85928. * @param values The animation key frames to set
  85929. */
  85930. setKeys(values: Array<IAnimationKey>): void;
  85931. /**
  85932. * Serializes the animation to an object
  85933. * @returns Serialized object
  85934. */
  85935. serialize(): any;
  85936. /**
  85937. * Float animation type
  85938. */
  85939. private static _ANIMATIONTYPE_FLOAT;
  85940. /**
  85941. * Vector3 animation type
  85942. */
  85943. private static _ANIMATIONTYPE_VECTOR3;
  85944. /**
  85945. * Quaternion animation type
  85946. */
  85947. private static _ANIMATIONTYPE_QUATERNION;
  85948. /**
  85949. * Matrix animation type
  85950. */
  85951. private static _ANIMATIONTYPE_MATRIX;
  85952. /**
  85953. * Color3 animation type
  85954. */
  85955. private static _ANIMATIONTYPE_COLOR3;
  85956. /**
  85957. * Vector2 animation type
  85958. */
  85959. private static _ANIMATIONTYPE_VECTOR2;
  85960. /**
  85961. * Size animation type
  85962. */
  85963. private static _ANIMATIONTYPE_SIZE;
  85964. /**
  85965. * Relative Loop Mode
  85966. */
  85967. private static _ANIMATIONLOOPMODE_RELATIVE;
  85968. /**
  85969. * Cycle Loop Mode
  85970. */
  85971. private static _ANIMATIONLOOPMODE_CYCLE;
  85972. /**
  85973. * Constant Loop Mode
  85974. */
  85975. private static _ANIMATIONLOOPMODE_CONSTANT;
  85976. /**
  85977. * Get the float animation type
  85978. */
  85979. static readonly ANIMATIONTYPE_FLOAT: number;
  85980. /**
  85981. * Get the Vector3 animation type
  85982. */
  85983. static readonly ANIMATIONTYPE_VECTOR3: number;
  85984. /**
  85985. * Get the Vector2 animation type
  85986. */
  85987. static readonly ANIMATIONTYPE_VECTOR2: number;
  85988. /**
  85989. * Get the Size animation type
  85990. */
  85991. static readonly ANIMATIONTYPE_SIZE: number;
  85992. /**
  85993. * Get the Quaternion animation type
  85994. */
  85995. static readonly ANIMATIONTYPE_QUATERNION: number;
  85996. /**
  85997. * Get the Matrix animation type
  85998. */
  85999. static readonly ANIMATIONTYPE_MATRIX: number;
  86000. /**
  86001. * Get the Color3 animation type
  86002. */
  86003. static readonly ANIMATIONTYPE_COLOR3: number;
  86004. /**
  86005. * Get the Relative Loop Mode
  86006. */
  86007. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  86008. /**
  86009. * Get the Cycle Loop Mode
  86010. */
  86011. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  86012. /**
  86013. * Get the Constant Loop Mode
  86014. */
  86015. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  86016. /** @hidden */
  86017. static _UniversalLerp(left: any, right: any, amount: number): any;
  86018. /**
  86019. * Parses an animation object and creates an animation
  86020. * @param parsedAnimation Parsed animation object
  86021. * @returns Animation object
  86022. */
  86023. static Parse(parsedAnimation: any): Animation;
  86024. /**
  86025. * Appends the serialized animations from the source animations
  86026. * @param source Source containing the animations
  86027. * @param destination Target to store the animations
  86028. */
  86029. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  86030. }
  86031. }
  86032. declare module BABYLON {
  86033. /**
  86034. * Base class of all the textures in babylon.
  86035. * It groups all the common properties the materials, post process, lights... might need
  86036. * in order to make a correct use of the texture.
  86037. */
  86038. export class BaseTexture implements IAnimatable {
  86039. /**
  86040. * Default anisotropic filtering level for the application.
  86041. * It is set to 4 as a good tradeoff between perf and quality.
  86042. */
  86043. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  86044. /**
  86045. * Gets or sets the unique id of the texture
  86046. */
  86047. uniqueId: number;
  86048. /**
  86049. * Define the name of the texture.
  86050. */
  86051. name: string;
  86052. /**
  86053. * Gets or sets an object used to store user defined information.
  86054. */
  86055. metadata: any;
  86056. /**
  86057. * For internal use only. Please do not use.
  86058. */
  86059. reservedDataStore: any;
  86060. private _hasAlpha;
  86061. /**
  86062. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  86063. */
  86064. hasAlpha: boolean;
  86065. /**
  86066. * Defines if the alpha value should be determined via the rgb values.
  86067. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  86068. */
  86069. getAlphaFromRGB: boolean;
  86070. /**
  86071. * Intensity or strength of the texture.
  86072. * It is commonly used by materials to fine tune the intensity of the texture
  86073. */
  86074. level: number;
  86075. /**
  86076. * Define the UV chanel to use starting from 0 and defaulting to 0.
  86077. * This is part of the texture as textures usually maps to one uv set.
  86078. */
  86079. coordinatesIndex: number;
  86080. private _coordinatesMode;
  86081. /**
  86082. * How a texture is mapped.
  86083. *
  86084. * | Value | Type | Description |
  86085. * | ----- | ----------------------------------- | ----------- |
  86086. * | 0 | EXPLICIT_MODE | |
  86087. * | 1 | SPHERICAL_MODE | |
  86088. * | 2 | PLANAR_MODE | |
  86089. * | 3 | CUBIC_MODE | |
  86090. * | 4 | PROJECTION_MODE | |
  86091. * | 5 | SKYBOX_MODE | |
  86092. * | 6 | INVCUBIC_MODE | |
  86093. * | 7 | EQUIRECTANGULAR_MODE | |
  86094. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  86095. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  86096. */
  86097. coordinatesMode: number;
  86098. /**
  86099. * | Value | Type | Description |
  86100. * | ----- | ------------------ | ----------- |
  86101. * | 0 | CLAMP_ADDRESSMODE | |
  86102. * | 1 | WRAP_ADDRESSMODE | |
  86103. * | 2 | MIRROR_ADDRESSMODE | |
  86104. */
  86105. wrapU: number;
  86106. /**
  86107. * | Value | Type | Description |
  86108. * | ----- | ------------------ | ----------- |
  86109. * | 0 | CLAMP_ADDRESSMODE | |
  86110. * | 1 | WRAP_ADDRESSMODE | |
  86111. * | 2 | MIRROR_ADDRESSMODE | |
  86112. */
  86113. wrapV: number;
  86114. /**
  86115. * | Value | Type | Description |
  86116. * | ----- | ------------------ | ----------- |
  86117. * | 0 | CLAMP_ADDRESSMODE | |
  86118. * | 1 | WRAP_ADDRESSMODE | |
  86119. * | 2 | MIRROR_ADDRESSMODE | |
  86120. */
  86121. wrapR: number;
  86122. /**
  86123. * With compliant hardware and browser (supporting anisotropic filtering)
  86124. * this defines the level of anisotropic filtering in the texture.
  86125. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  86126. */
  86127. anisotropicFilteringLevel: number;
  86128. /**
  86129. * Define if the texture is a cube texture or if false a 2d texture.
  86130. */
  86131. isCube: boolean;
  86132. /**
  86133. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  86134. */
  86135. is3D: boolean;
  86136. /**
  86137. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  86138. * HDR texture are usually stored in linear space.
  86139. * This only impacts the PBR and Background materials
  86140. */
  86141. gammaSpace: boolean;
  86142. /**
  86143. * Gets whether or not the texture contains RGBD data.
  86144. */
  86145. readonly isRGBD: boolean;
  86146. /**
  86147. * Is Z inverted in the texture (useful in a cube texture).
  86148. */
  86149. invertZ: boolean;
  86150. /**
  86151. * Are mip maps generated for this texture or not.
  86152. */
  86153. readonly noMipmap: boolean;
  86154. /**
  86155. * @hidden
  86156. */
  86157. lodLevelInAlpha: boolean;
  86158. /**
  86159. * With prefiltered texture, defined the offset used during the prefiltering steps.
  86160. */
  86161. lodGenerationOffset: number;
  86162. /**
  86163. * With prefiltered texture, defined the scale used during the prefiltering steps.
  86164. */
  86165. lodGenerationScale: number;
  86166. /**
  86167. * Define if the texture is a render target.
  86168. */
  86169. isRenderTarget: boolean;
  86170. /**
  86171. * Define the unique id of the texture in the scene.
  86172. */
  86173. readonly uid: string;
  86174. /**
  86175. * Return a string representation of the texture.
  86176. * @returns the texture as a string
  86177. */
  86178. toString(): string;
  86179. /**
  86180. * Get the class name of the texture.
  86181. * @returns "BaseTexture"
  86182. */
  86183. getClassName(): string;
  86184. /**
  86185. * Define the list of animation attached to the texture.
  86186. */
  86187. animations: Animation[];
  86188. /**
  86189. * An event triggered when the texture is disposed.
  86190. */
  86191. onDisposeObservable: Observable<BaseTexture>;
  86192. private _onDisposeObserver;
  86193. /**
  86194. * Callback triggered when the texture has been disposed.
  86195. * Kept for back compatibility, you can use the onDisposeObservable instead.
  86196. */
  86197. onDispose: () => void;
  86198. /**
  86199. * Define the current state of the loading sequence when in delayed load mode.
  86200. */
  86201. delayLoadState: number;
  86202. private _scene;
  86203. /** @hidden */
  86204. _texture: Nullable<InternalTexture>;
  86205. private _uid;
  86206. /**
  86207. * Define if the texture is preventinga material to render or not.
  86208. * If not and the texture is not ready, the engine will use a default black texture instead.
  86209. */
  86210. readonly isBlocking: boolean;
  86211. /**
  86212. * Instantiates a new BaseTexture.
  86213. * Base class of all the textures in babylon.
  86214. * It groups all the common properties the materials, post process, lights... might need
  86215. * in order to make a correct use of the texture.
  86216. * @param scene Define the scene the texture blongs to
  86217. */
  86218. constructor(scene: Nullable<Scene>);
  86219. /**
  86220. * Get the scene the texture belongs to.
  86221. * @returns the scene or null if undefined
  86222. */
  86223. getScene(): Nullable<Scene>;
  86224. /**
  86225. * Get the texture transform matrix used to offset tile the texture for istance.
  86226. * @returns the transformation matrix
  86227. */
  86228. getTextureMatrix(): Matrix;
  86229. /**
  86230. * Get the texture reflection matrix used to rotate/transform the reflection.
  86231. * @returns the reflection matrix
  86232. */
  86233. getReflectionTextureMatrix(): Matrix;
  86234. /**
  86235. * Get the underlying lower level texture from Babylon.
  86236. * @returns the insternal texture
  86237. */
  86238. getInternalTexture(): Nullable<InternalTexture>;
  86239. /**
  86240. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  86241. * @returns true if ready or not blocking
  86242. */
  86243. isReadyOrNotBlocking(): boolean;
  86244. /**
  86245. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  86246. * @returns true if fully ready
  86247. */
  86248. isReady(): boolean;
  86249. private _cachedSize;
  86250. /**
  86251. * Get the size of the texture.
  86252. * @returns the texture size.
  86253. */
  86254. getSize(): ISize;
  86255. /**
  86256. * Get the base size of the texture.
  86257. * It can be different from the size if the texture has been resized for POT for instance
  86258. * @returns the base size
  86259. */
  86260. getBaseSize(): ISize;
  86261. /**
  86262. * Update the sampling mode of the texture.
  86263. * Default is Trilinear mode.
  86264. *
  86265. * | Value | Type | Description |
  86266. * | ----- | ------------------ | ----------- |
  86267. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  86268. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  86269. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  86270. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  86271. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  86272. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  86273. * | 7 | NEAREST_LINEAR | |
  86274. * | 8 | NEAREST_NEAREST | |
  86275. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  86276. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  86277. * | 11 | LINEAR_LINEAR | |
  86278. * | 12 | LINEAR_NEAREST | |
  86279. *
  86280. * > _mag_: magnification filter (close to the viewer)
  86281. * > _min_: minification filter (far from the viewer)
  86282. * > _mip_: filter used between mip map levels
  86283. *@param samplingMode Define the new sampling mode of the texture
  86284. */
  86285. updateSamplingMode(samplingMode: number): void;
  86286. /**
  86287. * Scales the texture if is `canRescale()`
  86288. * @param ratio the resize factor we want to use to rescale
  86289. */
  86290. scale(ratio: number): void;
  86291. /**
  86292. * Get if the texture can rescale.
  86293. */
  86294. readonly canRescale: boolean;
  86295. /** @hidden */
  86296. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  86297. /** @hidden */
  86298. _rebuild(): void;
  86299. /**
  86300. * Triggers the load sequence in delayed load mode.
  86301. */
  86302. delayLoad(): void;
  86303. /**
  86304. * Clones the texture.
  86305. * @returns the cloned texture
  86306. */
  86307. clone(): Nullable<BaseTexture>;
  86308. /**
  86309. * Get the texture underlying type (INT, FLOAT...)
  86310. */
  86311. readonly textureType: number;
  86312. /**
  86313. * Get the texture underlying format (RGB, RGBA...)
  86314. */
  86315. readonly textureFormat: number;
  86316. /**
  86317. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  86318. * This will returns an RGBA array buffer containing either in values (0-255) or
  86319. * float values (0-1) depending of the underlying buffer type.
  86320. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  86321. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  86322. * @param buffer defines a user defined buffer to fill with data (can be null)
  86323. * @returns The Array buffer containing the pixels data.
  86324. */
  86325. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  86326. /**
  86327. * Release and destroy the underlying lower level texture aka internalTexture.
  86328. */
  86329. releaseInternalTexture(): void;
  86330. /**
  86331. * Get the polynomial representation of the texture data.
  86332. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  86333. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  86334. */
  86335. sphericalPolynomial: Nullable<SphericalPolynomial>;
  86336. /** @hidden */
  86337. readonly _lodTextureHigh: Nullable<BaseTexture>;
  86338. /** @hidden */
  86339. readonly _lodTextureMid: Nullable<BaseTexture>;
  86340. /** @hidden */
  86341. readonly _lodTextureLow: Nullable<BaseTexture>;
  86342. /**
  86343. * Dispose the texture and release its associated resources.
  86344. */
  86345. dispose(): void;
  86346. /**
  86347. * Serialize the texture into a JSON representation that can be parsed later on.
  86348. * @returns the JSON representation of the texture
  86349. */
  86350. serialize(): any;
  86351. /**
  86352. * Helper function to be called back once a list of texture contains only ready textures.
  86353. * @param textures Define the list of textures to wait for
  86354. * @param callback Define the callback triggered once the entire list will be ready
  86355. */
  86356. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  86357. }
  86358. }
  86359. declare module BABYLON {
  86360. /**
  86361. * Uniform buffer objects.
  86362. *
  86363. * Handles blocks of uniform on the GPU.
  86364. *
  86365. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86366. *
  86367. * For more information, please refer to :
  86368. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86369. */
  86370. export class UniformBuffer {
  86371. private _engine;
  86372. private _buffer;
  86373. private _data;
  86374. private _bufferData;
  86375. private _dynamic?;
  86376. private _uniformLocations;
  86377. private _uniformSizes;
  86378. private _uniformLocationPointer;
  86379. private _needSync;
  86380. private _noUBO;
  86381. private _currentEffect;
  86382. private static _MAX_UNIFORM_SIZE;
  86383. private static _tempBuffer;
  86384. /**
  86385. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86386. * This is dynamic to allow compat with webgl 1 and 2.
  86387. * You will need to pass the name of the uniform as well as the value.
  86388. */
  86389. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86390. /**
  86391. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86392. * This is dynamic to allow compat with webgl 1 and 2.
  86393. * You will need to pass the name of the uniform as well as the value.
  86394. */
  86395. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86396. /**
  86397. * Lambda to Update a single float in a uniform buffer.
  86398. * This is dynamic to allow compat with webgl 1 and 2.
  86399. * You will need to pass the name of the uniform as well as the value.
  86400. */
  86401. updateFloat: (name: string, x: number) => void;
  86402. /**
  86403. * Lambda to Update a vec2 of float in a uniform buffer.
  86404. * This is dynamic to allow compat with webgl 1 and 2.
  86405. * You will need to pass the name of the uniform as well as the value.
  86406. */
  86407. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86408. /**
  86409. * Lambda to Update a vec3 of float in a uniform buffer.
  86410. * This is dynamic to allow compat with webgl 1 and 2.
  86411. * You will need to pass the name of the uniform as well as the value.
  86412. */
  86413. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86414. /**
  86415. * Lambda to Update a vec4 of float in a uniform buffer.
  86416. * This is dynamic to allow compat with webgl 1 and 2.
  86417. * You will need to pass the name of the uniform as well as the value.
  86418. */
  86419. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86420. /**
  86421. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86422. * This is dynamic to allow compat with webgl 1 and 2.
  86423. * You will need to pass the name of the uniform as well as the value.
  86424. */
  86425. updateMatrix: (name: string, mat: Matrix) => void;
  86426. /**
  86427. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86428. * This is dynamic to allow compat with webgl 1 and 2.
  86429. * You will need to pass the name of the uniform as well as the value.
  86430. */
  86431. updateVector3: (name: string, vector: Vector3) => void;
  86432. /**
  86433. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86434. * This is dynamic to allow compat with webgl 1 and 2.
  86435. * You will need to pass the name of the uniform as well as the value.
  86436. */
  86437. updateVector4: (name: string, vector: Vector4) => void;
  86438. /**
  86439. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86440. * This is dynamic to allow compat with webgl 1 and 2.
  86441. * You will need to pass the name of the uniform as well as the value.
  86442. */
  86443. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86444. /**
  86445. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86446. * This is dynamic to allow compat with webgl 1 and 2.
  86447. * You will need to pass the name of the uniform as well as the value.
  86448. */
  86449. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86450. /**
  86451. * Instantiates a new Uniform buffer objects.
  86452. *
  86453. * Handles blocks of uniform on the GPU.
  86454. *
  86455. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86456. *
  86457. * For more information, please refer to :
  86458. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86459. * @param engine Define the engine the buffer is associated with
  86460. * @param data Define the data contained in the buffer
  86461. * @param dynamic Define if the buffer is updatable
  86462. */
  86463. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86464. /**
  86465. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86466. * or just falling back on setUniformXXX calls.
  86467. */
  86468. readonly useUbo: boolean;
  86469. /**
  86470. * Indicates if the WebGL underlying uniform buffer is in sync
  86471. * with the javascript cache data.
  86472. */
  86473. readonly isSync: boolean;
  86474. /**
  86475. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86476. * Also, a dynamic UniformBuffer will disable cache verification and always
  86477. * update the underlying WebGL uniform buffer to the GPU.
  86478. * @returns if Dynamic, otherwise false
  86479. */
  86480. isDynamic(): boolean;
  86481. /**
  86482. * The data cache on JS side.
  86483. * @returns the underlying data as a float array
  86484. */
  86485. getData(): Float32Array;
  86486. /**
  86487. * The underlying WebGL Uniform buffer.
  86488. * @returns the webgl buffer
  86489. */
  86490. getBuffer(): Nullable<DataBuffer>;
  86491. /**
  86492. * std140 layout specifies how to align data within an UBO structure.
  86493. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86494. * for specs.
  86495. */
  86496. private _fillAlignment;
  86497. /**
  86498. * Adds an uniform in the buffer.
  86499. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86500. * for the layout to be correct !
  86501. * @param name Name of the uniform, as used in the uniform block in the shader.
  86502. * @param size Data size, or data directly.
  86503. */
  86504. addUniform(name: string, size: number | number[]): void;
  86505. /**
  86506. * Adds a Matrix 4x4 to the uniform buffer.
  86507. * @param name Name of the uniform, as used in the uniform block in the shader.
  86508. * @param mat A 4x4 matrix.
  86509. */
  86510. addMatrix(name: string, mat: Matrix): void;
  86511. /**
  86512. * Adds a vec2 to the uniform buffer.
  86513. * @param name Name of the uniform, as used in the uniform block in the shader.
  86514. * @param x Define the x component value of the vec2
  86515. * @param y Define the y component value of the vec2
  86516. */
  86517. addFloat2(name: string, x: number, y: number): void;
  86518. /**
  86519. * Adds a vec3 to the uniform buffer.
  86520. * @param name Name of the uniform, as used in the uniform block in the shader.
  86521. * @param x Define the x component value of the vec3
  86522. * @param y Define the y component value of the vec3
  86523. * @param z Define the z component value of the vec3
  86524. */
  86525. addFloat3(name: string, x: number, y: number, z: number): void;
  86526. /**
  86527. * Adds a vec3 to the uniform buffer.
  86528. * @param name Name of the uniform, as used in the uniform block in the shader.
  86529. * @param color Define the vec3 from a Color
  86530. */
  86531. addColor3(name: string, color: Color3): void;
  86532. /**
  86533. * Adds a vec4 to the uniform buffer.
  86534. * @param name Name of the uniform, as used in the uniform block in the shader.
  86535. * @param color Define the rgb components from a Color
  86536. * @param alpha Define the a component of the vec4
  86537. */
  86538. addColor4(name: string, color: Color3, alpha: number): void;
  86539. /**
  86540. * Adds a vec3 to the uniform buffer.
  86541. * @param name Name of the uniform, as used in the uniform block in the shader.
  86542. * @param vector Define the vec3 components from a Vector
  86543. */
  86544. addVector3(name: string, vector: Vector3): void;
  86545. /**
  86546. * Adds a Matrix 3x3 to the uniform buffer.
  86547. * @param name Name of the uniform, as used in the uniform block in the shader.
  86548. */
  86549. addMatrix3x3(name: string): void;
  86550. /**
  86551. * Adds a Matrix 2x2 to the uniform buffer.
  86552. * @param name Name of the uniform, as used in the uniform block in the shader.
  86553. */
  86554. addMatrix2x2(name: string): void;
  86555. /**
  86556. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86557. */
  86558. create(): void;
  86559. /** @hidden */
  86560. _rebuild(): void;
  86561. /**
  86562. * Updates the WebGL Uniform Buffer on the GPU.
  86563. * If the `dynamic` flag is set to true, no cache comparison is done.
  86564. * Otherwise, the buffer will be updated only if the cache differs.
  86565. */
  86566. update(): void;
  86567. /**
  86568. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86569. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86570. * @param data Define the flattened data
  86571. * @param size Define the size of the data.
  86572. */
  86573. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86574. private _updateMatrix3x3ForUniform;
  86575. private _updateMatrix3x3ForEffect;
  86576. private _updateMatrix2x2ForEffect;
  86577. private _updateMatrix2x2ForUniform;
  86578. private _updateFloatForEffect;
  86579. private _updateFloatForUniform;
  86580. private _updateFloat2ForEffect;
  86581. private _updateFloat2ForUniform;
  86582. private _updateFloat3ForEffect;
  86583. private _updateFloat3ForUniform;
  86584. private _updateFloat4ForEffect;
  86585. private _updateFloat4ForUniform;
  86586. private _updateMatrixForEffect;
  86587. private _updateMatrixForUniform;
  86588. private _updateVector3ForEffect;
  86589. private _updateVector3ForUniform;
  86590. private _updateVector4ForEffect;
  86591. private _updateVector4ForUniform;
  86592. private _updateColor3ForEffect;
  86593. private _updateColor3ForUniform;
  86594. private _updateColor4ForEffect;
  86595. private _updateColor4ForUniform;
  86596. /**
  86597. * Sets a sampler uniform on the effect.
  86598. * @param name Define the name of the sampler.
  86599. * @param texture Define the texture to set in the sampler
  86600. */
  86601. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86602. /**
  86603. * Directly updates the value of the uniform in the cache AND on the GPU.
  86604. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86605. * @param data Define the flattened data
  86606. */
  86607. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86608. /**
  86609. * Binds this uniform buffer to an effect.
  86610. * @param effect Define the effect to bind the buffer to
  86611. * @param name Name of the uniform block in the shader.
  86612. */
  86613. bindToEffect(effect: Effect, name: string): void;
  86614. /**
  86615. * Disposes the uniform buffer.
  86616. */
  86617. dispose(): void;
  86618. }
  86619. }
  86620. declare module BABYLON {
  86621. /**
  86622. * Class used to work with sound analyzer using fast fourier transform (FFT)
  86623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86624. */
  86625. export class Analyser {
  86626. /**
  86627. * Gets or sets the smoothing
  86628. * @ignorenaming
  86629. */
  86630. SMOOTHING: number;
  86631. /**
  86632. * Gets or sets the FFT table size
  86633. * @ignorenaming
  86634. */
  86635. FFT_SIZE: number;
  86636. /**
  86637. * Gets or sets the bar graph amplitude
  86638. * @ignorenaming
  86639. */
  86640. BARGRAPHAMPLITUDE: number;
  86641. /**
  86642. * Gets or sets the position of the debug canvas
  86643. * @ignorenaming
  86644. */
  86645. DEBUGCANVASPOS: {
  86646. x: number;
  86647. y: number;
  86648. };
  86649. /**
  86650. * Gets or sets the debug canvas size
  86651. * @ignorenaming
  86652. */
  86653. DEBUGCANVASSIZE: {
  86654. width: number;
  86655. height: number;
  86656. };
  86657. private _byteFreqs;
  86658. private _byteTime;
  86659. private _floatFreqs;
  86660. private _webAudioAnalyser;
  86661. private _debugCanvas;
  86662. private _debugCanvasContext;
  86663. private _scene;
  86664. private _registerFunc;
  86665. private _audioEngine;
  86666. /**
  86667. * Creates a new analyser
  86668. * @param scene defines hosting scene
  86669. */
  86670. constructor(scene: Scene);
  86671. /**
  86672. * Get the number of data values you will have to play with for the visualization
  86673. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  86674. * @returns a number
  86675. */
  86676. getFrequencyBinCount(): number;
  86677. /**
  86678. * Gets the current frequency data as a byte array
  86679. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86680. * @returns a Uint8Array
  86681. */
  86682. getByteFrequencyData(): Uint8Array;
  86683. /**
  86684. * Gets the current waveform as a byte array
  86685. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  86686. * @returns a Uint8Array
  86687. */
  86688. getByteTimeDomainData(): Uint8Array;
  86689. /**
  86690. * Gets the current frequency data as a float array
  86691. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86692. * @returns a Float32Array
  86693. */
  86694. getFloatFrequencyData(): Float32Array;
  86695. /**
  86696. * Renders the debug canvas
  86697. */
  86698. drawDebugCanvas(): void;
  86699. /**
  86700. * Stops rendering the debug canvas and removes it
  86701. */
  86702. stopDebugCanvas(): void;
  86703. /**
  86704. * Connects two audio nodes
  86705. * @param inputAudioNode defines first node to connect
  86706. * @param outputAudioNode defines second node to connect
  86707. */
  86708. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  86709. /**
  86710. * Releases all associated resources
  86711. */
  86712. dispose(): void;
  86713. }
  86714. }
  86715. declare module BABYLON {
  86716. /**
  86717. * This represents an audio engine and it is responsible
  86718. * to play, synchronize and analyse sounds throughout the application.
  86719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86720. */
  86721. export interface IAudioEngine extends IDisposable {
  86722. /**
  86723. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86724. */
  86725. readonly canUseWebAudio: boolean;
  86726. /**
  86727. * Gets the current AudioContext if available.
  86728. */
  86729. readonly audioContext: Nullable<AudioContext>;
  86730. /**
  86731. * The master gain node defines the global audio volume of your audio engine.
  86732. */
  86733. readonly masterGain: GainNode;
  86734. /**
  86735. * Gets whether or not mp3 are supported by your browser.
  86736. */
  86737. readonly isMP3supported: boolean;
  86738. /**
  86739. * Gets whether or not ogg are supported by your browser.
  86740. */
  86741. readonly isOGGsupported: boolean;
  86742. /**
  86743. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86744. * @ignoreNaming
  86745. */
  86746. WarnedWebAudioUnsupported: boolean;
  86747. /**
  86748. * Defines if the audio engine relies on a custom unlocked button.
  86749. * In this case, the embedded button will not be displayed.
  86750. */
  86751. useCustomUnlockedButton: boolean;
  86752. /**
  86753. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  86754. */
  86755. readonly unlocked: boolean;
  86756. /**
  86757. * Event raised when audio has been unlocked on the browser.
  86758. */
  86759. onAudioUnlockedObservable: Observable<AudioEngine>;
  86760. /**
  86761. * Event raised when audio has been locked on the browser.
  86762. */
  86763. onAudioLockedObservable: Observable<AudioEngine>;
  86764. /**
  86765. * Flags the audio engine in Locked state.
  86766. * This happens due to new browser policies preventing audio to autoplay.
  86767. */
  86768. lock(): void;
  86769. /**
  86770. * Unlocks the audio engine once a user action has been done on the dom.
  86771. * This is helpful to resume play once browser policies have been satisfied.
  86772. */
  86773. unlock(): void;
  86774. }
  86775. /**
  86776. * This represents the default audio engine used in babylon.
  86777. * It is responsible to play, synchronize and analyse sounds throughout the application.
  86778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86779. */
  86780. export class AudioEngine implements IAudioEngine {
  86781. private _audioContext;
  86782. private _audioContextInitialized;
  86783. private _muteButton;
  86784. private _hostElement;
  86785. /**
  86786. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86787. */
  86788. canUseWebAudio: boolean;
  86789. /**
  86790. * The master gain node defines the global audio volume of your audio engine.
  86791. */
  86792. masterGain: GainNode;
  86793. /**
  86794. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86795. * @ignoreNaming
  86796. */
  86797. WarnedWebAudioUnsupported: boolean;
  86798. /**
  86799. * Gets whether or not mp3 are supported by your browser.
  86800. */
  86801. isMP3supported: boolean;
  86802. /**
  86803. * Gets whether or not ogg are supported by your browser.
  86804. */
  86805. isOGGsupported: boolean;
  86806. /**
  86807. * Gets whether audio has been unlocked on the device.
  86808. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  86809. * a user interaction has happened.
  86810. */
  86811. unlocked: boolean;
  86812. /**
  86813. * Defines if the audio engine relies on a custom unlocked button.
  86814. * In this case, the embedded button will not be displayed.
  86815. */
  86816. useCustomUnlockedButton: boolean;
  86817. /**
  86818. * Event raised when audio has been unlocked on the browser.
  86819. */
  86820. onAudioUnlockedObservable: Observable<AudioEngine>;
  86821. /**
  86822. * Event raised when audio has been locked on the browser.
  86823. */
  86824. onAudioLockedObservable: Observable<AudioEngine>;
  86825. /**
  86826. * Gets the current AudioContext if available.
  86827. */
  86828. readonly audioContext: Nullable<AudioContext>;
  86829. private _connectedAnalyser;
  86830. /**
  86831. * Instantiates a new audio engine.
  86832. *
  86833. * There should be only one per page as some browsers restrict the number
  86834. * of audio contexts you can create.
  86835. * @param hostElement defines the host element where to display the mute icon if necessary
  86836. */
  86837. constructor(hostElement?: Nullable<HTMLElement>);
  86838. /**
  86839. * Flags the audio engine in Locked state.
  86840. * This happens due to new browser policies preventing audio to autoplay.
  86841. */
  86842. lock(): void;
  86843. /**
  86844. * Unlocks the audio engine once a user action has been done on the dom.
  86845. * This is helpful to resume play once browser policies have been satisfied.
  86846. */
  86847. unlock(): void;
  86848. private _resumeAudioContext;
  86849. private _initializeAudioContext;
  86850. private _tryToRun;
  86851. private _triggerRunningState;
  86852. private _triggerSuspendedState;
  86853. private _displayMuteButton;
  86854. private _moveButtonToTopLeft;
  86855. private _onResize;
  86856. private _hideMuteButton;
  86857. /**
  86858. * Destroy and release the resources associated with the audio ccontext.
  86859. */
  86860. dispose(): void;
  86861. /**
  86862. * Gets the global volume sets on the master gain.
  86863. * @returns the global volume if set or -1 otherwise
  86864. */
  86865. getGlobalVolume(): number;
  86866. /**
  86867. * Sets the global volume of your experience (sets on the master gain).
  86868. * @param newVolume Defines the new global volume of the application
  86869. */
  86870. setGlobalVolume(newVolume: number): void;
  86871. /**
  86872. * Connect the audio engine to an audio analyser allowing some amazing
  86873. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  86874. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  86875. * @param analyser The analyser to connect to the engine
  86876. */
  86877. connectToAnalyser(analyser: Analyser): void;
  86878. }
  86879. }
  86880. declare module BABYLON {
  86881. /**
  86882. * Interface used to present a loading screen while loading a scene
  86883. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86884. */
  86885. export interface ILoadingScreen {
  86886. /**
  86887. * Function called to display the loading screen
  86888. */
  86889. displayLoadingUI: () => void;
  86890. /**
  86891. * Function called to hide the loading screen
  86892. */
  86893. hideLoadingUI: () => void;
  86894. /**
  86895. * Gets or sets the color to use for the background
  86896. */
  86897. loadingUIBackgroundColor: string;
  86898. /**
  86899. * Gets or sets the text to display while loading
  86900. */
  86901. loadingUIText: string;
  86902. }
  86903. /**
  86904. * Class used for the default loading screen
  86905. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86906. */
  86907. export class DefaultLoadingScreen implements ILoadingScreen {
  86908. private _renderingCanvas;
  86909. private _loadingText;
  86910. private _loadingDivBackgroundColor;
  86911. private _loadingDiv;
  86912. private _loadingTextDiv;
  86913. /** Gets or sets the logo url to use for the default loading screen */
  86914. static DefaultLogoUrl: string;
  86915. /** Gets or sets the spinner url to use for the default loading screen */
  86916. static DefaultSpinnerUrl: string;
  86917. /**
  86918. * Creates a new default loading screen
  86919. * @param _renderingCanvas defines the canvas used to render the scene
  86920. * @param _loadingText defines the default text to display
  86921. * @param _loadingDivBackgroundColor defines the default background color
  86922. */
  86923. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  86924. /**
  86925. * Function called to display the loading screen
  86926. */
  86927. displayLoadingUI(): void;
  86928. /**
  86929. * Function called to hide the loading screen
  86930. */
  86931. hideLoadingUI(): void;
  86932. /**
  86933. * Gets or sets the text to display while loading
  86934. */
  86935. loadingUIText: string;
  86936. /**
  86937. * Gets or sets the color to use for the background
  86938. */
  86939. loadingUIBackgroundColor: string;
  86940. private _resizeLoadingUI;
  86941. }
  86942. }
  86943. declare module BABYLON {
  86944. /** @hidden */
  86945. export class WebGLPipelineContext implements IPipelineContext {
  86946. engine: Engine;
  86947. program: Nullable<WebGLProgram>;
  86948. context?: WebGLRenderingContext;
  86949. vertexShader?: WebGLShader;
  86950. fragmentShader?: WebGLShader;
  86951. isParallelCompiled: boolean;
  86952. onCompiled?: () => void;
  86953. transformFeedback?: WebGLTransformFeedback | null;
  86954. readonly isAsync: boolean;
  86955. readonly isReady: boolean;
  86956. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86957. }
  86958. }
  86959. declare module BABYLON {
  86960. /** @hidden */
  86961. export class WebGLDataBuffer extends DataBuffer {
  86962. private _buffer;
  86963. constructor(resource: WebGLBuffer);
  86964. readonly underlyingResource: any;
  86965. }
  86966. }
  86967. declare module BABYLON {
  86968. /**
  86969. * Settings for finer control over video usage
  86970. */
  86971. export interface VideoTextureSettings {
  86972. /**
  86973. * Applies `autoplay` to video, if specified
  86974. */
  86975. autoPlay?: boolean;
  86976. /**
  86977. * Applies `loop` to video, if specified
  86978. */
  86979. loop?: boolean;
  86980. /**
  86981. * Automatically updates internal texture from video at every frame in the render loop
  86982. */
  86983. autoUpdateTexture: boolean;
  86984. /**
  86985. * Image src displayed during the video loading or until the user interacts with the video.
  86986. */
  86987. poster?: string;
  86988. }
  86989. /**
  86990. * If you want to display a video in your scene, this is the special texture for that.
  86991. * This special texture works similar to other textures, with the exception of a few parameters.
  86992. * @see https://doc.babylonjs.com/how_to/video_texture
  86993. */
  86994. export class VideoTexture extends Texture {
  86995. /**
  86996. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  86997. */
  86998. readonly autoUpdateTexture: boolean;
  86999. /**
  87000. * The video instance used by the texture internally
  87001. */
  87002. readonly video: HTMLVideoElement;
  87003. private _onUserActionRequestedObservable;
  87004. /**
  87005. * Event triggerd when a dom action is required by the user to play the video.
  87006. * This happens due to recent changes in browser policies preventing video to auto start.
  87007. */
  87008. readonly onUserActionRequestedObservable: Observable<Texture>;
  87009. private _generateMipMaps;
  87010. private _engine;
  87011. private _stillImageCaptured;
  87012. private _displayingPosterTexture;
  87013. private _settings;
  87014. private _createInternalTextureOnEvent;
  87015. /**
  87016. * Creates a video texture.
  87017. * If you want to display a video in your scene, this is the special texture for that.
  87018. * This special texture works similar to other textures, with the exception of a few parameters.
  87019. * @see https://doc.babylonjs.com/how_to/video_texture
  87020. * @param name optional name, will detect from video source, if not defined
  87021. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  87022. * @param scene is obviously the current scene.
  87023. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  87024. * @param invertY is false by default but can be used to invert video on Y axis
  87025. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  87026. * @param settings allows finer control over video usage
  87027. */
  87028. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  87029. private _getName;
  87030. private _getVideo;
  87031. private _createInternalTexture;
  87032. private reset;
  87033. /**
  87034. * @hidden Internal method to initiate `update`.
  87035. */
  87036. _rebuild(): void;
  87037. /**
  87038. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  87039. */
  87040. update(): void;
  87041. /**
  87042. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  87043. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  87044. */
  87045. updateTexture(isVisible: boolean): void;
  87046. protected _updateInternalTexture: () => void;
  87047. /**
  87048. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  87049. * @param url New url.
  87050. */
  87051. updateURL(url: string): void;
  87052. /**
  87053. * Dispose the texture and release its associated resources.
  87054. */
  87055. dispose(): void;
  87056. /**
  87057. * Creates a video texture straight from a stream.
  87058. * @param scene Define the scene the texture should be created in
  87059. * @param stream Define the stream the texture should be created from
  87060. * @returns The created video texture as a promise
  87061. */
  87062. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  87063. /**
  87064. * Creates a video texture straight from your WebCam video feed.
  87065. * @param scene Define the scene the texture should be created in
  87066. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  87067. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  87068. * @returns The created video texture as a promise
  87069. */
  87070. static CreateFromWebCamAsync(scene: Scene, constraints: {
  87071. minWidth: number;
  87072. maxWidth: number;
  87073. minHeight: number;
  87074. maxHeight: number;
  87075. deviceId: string;
  87076. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  87077. /**
  87078. * Creates a video texture straight from your WebCam video feed.
  87079. * @param scene Define the scene the texture should be created in
  87080. * @param onReady Define a callback to triggered once the texture will be ready
  87081. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  87082. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  87083. */
  87084. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  87085. minWidth: number;
  87086. maxWidth: number;
  87087. minHeight: number;
  87088. maxHeight: number;
  87089. deviceId: string;
  87090. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  87091. }
  87092. }
  87093. declare module BABYLON {
  87094. /**
  87095. * Interface for attribute information associated with buffer instanciation
  87096. */
  87097. export class InstancingAttributeInfo {
  87098. /**
  87099. * Index/offset of the attribute in the vertex shader
  87100. */
  87101. index: number;
  87102. /**
  87103. * size of the attribute, 1, 2, 3 or 4
  87104. */
  87105. attributeSize: number;
  87106. /**
  87107. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  87108. * default is FLOAT
  87109. */
  87110. attribyteType: number;
  87111. /**
  87112. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  87113. */
  87114. normalized: boolean;
  87115. /**
  87116. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  87117. */
  87118. offset: number;
  87119. /**
  87120. * Name of the GLSL attribute, for debugging purpose only
  87121. */
  87122. attributeName: string;
  87123. }
  87124. /**
  87125. * Define options used to create a depth texture
  87126. */
  87127. export class DepthTextureCreationOptions {
  87128. /** Specifies whether or not a stencil should be allocated in the texture */
  87129. generateStencil?: boolean;
  87130. /** Specifies whether or not bilinear filtering is enable on the texture */
  87131. bilinearFiltering?: boolean;
  87132. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  87133. comparisonFunction?: number;
  87134. /** Specifies if the created texture is a cube texture */
  87135. isCube?: boolean;
  87136. }
  87137. /**
  87138. * Class used to describe the capabilities of the engine relatively to the current browser
  87139. */
  87140. export class EngineCapabilities {
  87141. /** Maximum textures units per fragment shader */
  87142. maxTexturesImageUnits: number;
  87143. /** Maximum texture units per vertex shader */
  87144. maxVertexTextureImageUnits: number;
  87145. /** Maximum textures units in the entire pipeline */
  87146. maxCombinedTexturesImageUnits: number;
  87147. /** Maximum texture size */
  87148. maxTextureSize: number;
  87149. /** Maximum cube texture size */
  87150. maxCubemapTextureSize: number;
  87151. /** Maximum render texture size */
  87152. maxRenderTextureSize: number;
  87153. /** Maximum number of vertex attributes */
  87154. maxVertexAttribs: number;
  87155. /** Maximum number of varyings */
  87156. maxVaryingVectors: number;
  87157. /** Maximum number of uniforms per vertex shader */
  87158. maxVertexUniformVectors: number;
  87159. /** Maximum number of uniforms per fragment shader */
  87160. maxFragmentUniformVectors: number;
  87161. /** Defines if standard derivates (dx/dy) are supported */
  87162. standardDerivatives: boolean;
  87163. /** Defines if s3tc texture compression is supported */
  87164. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  87165. /** Defines if pvrtc texture compression is supported */
  87166. pvrtc: any;
  87167. /** Defines if etc1 texture compression is supported */
  87168. etc1: any;
  87169. /** Defines if etc2 texture compression is supported */
  87170. etc2: any;
  87171. /** Defines if astc texture compression is supported */
  87172. astc: any;
  87173. /** Defines if float textures are supported */
  87174. textureFloat: boolean;
  87175. /** Defines if vertex array objects are supported */
  87176. vertexArrayObject: boolean;
  87177. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  87178. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  87179. /** Gets the maximum level of anisotropy supported */
  87180. maxAnisotropy: number;
  87181. /** Defines if instancing is supported */
  87182. instancedArrays: boolean;
  87183. /** Defines if 32 bits indices are supported */
  87184. uintIndices: boolean;
  87185. /** Defines if high precision shaders are supported */
  87186. highPrecisionShaderSupported: boolean;
  87187. /** Defines if depth reading in the fragment shader is supported */
  87188. fragmentDepthSupported: boolean;
  87189. /** Defines if float texture linear filtering is supported*/
  87190. textureFloatLinearFiltering: boolean;
  87191. /** Defines if rendering to float textures is supported */
  87192. textureFloatRender: boolean;
  87193. /** Defines if half float textures are supported*/
  87194. textureHalfFloat: boolean;
  87195. /** Defines if half float texture linear filtering is supported*/
  87196. textureHalfFloatLinearFiltering: boolean;
  87197. /** Defines if rendering to half float textures is supported */
  87198. textureHalfFloatRender: boolean;
  87199. /** Defines if textureLOD shader command is supported */
  87200. textureLOD: boolean;
  87201. /** Defines if draw buffers extension is supported */
  87202. drawBuffersExtension: boolean;
  87203. /** Defines if depth textures are supported */
  87204. depthTextureExtension: boolean;
  87205. /** Defines if float color buffer are supported */
  87206. colorBufferFloat: boolean;
  87207. /** Gets disjoint timer query extension (null if not supported) */
  87208. timerQuery: EXT_disjoint_timer_query;
  87209. /** Defines if timestamp can be used with timer query */
  87210. canUseTimestampForTimerQuery: boolean;
  87211. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  87212. multiview: any;
  87213. /** Function used to let the system compiles shaders in background */
  87214. parallelShaderCompile: {
  87215. COMPLETION_STATUS_KHR: number;
  87216. };
  87217. }
  87218. /** Interface defining initialization parameters for Engine class */
  87219. export interface EngineOptions extends WebGLContextAttributes {
  87220. /**
  87221. * Defines if the engine should no exceed a specified device ratio
  87222. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  87223. */
  87224. limitDeviceRatio?: number;
  87225. /**
  87226. * Defines if webvr should be enabled automatically
  87227. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87228. */
  87229. autoEnableWebVR?: boolean;
  87230. /**
  87231. * Defines if webgl2 should be turned off even if supported
  87232. * @see http://doc.babylonjs.com/features/webgl2
  87233. */
  87234. disableWebGL2Support?: boolean;
  87235. /**
  87236. * Defines if webaudio should be initialized as well
  87237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87238. */
  87239. audioEngine?: boolean;
  87240. /**
  87241. * Defines if animations should run using a deterministic lock step
  87242. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87243. */
  87244. deterministicLockstep?: boolean;
  87245. /** Defines the maximum steps to use with deterministic lock step mode */
  87246. lockstepMaxSteps?: number;
  87247. /**
  87248. * Defines that engine should ignore context lost events
  87249. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  87250. */
  87251. doNotHandleContextLost?: boolean;
  87252. /**
  87253. * Defines that engine should ignore modifying touch action attribute and style
  87254. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  87255. */
  87256. doNotHandleTouchAction?: boolean;
  87257. /**
  87258. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  87259. */
  87260. useHighPrecisionFloats?: boolean;
  87261. }
  87262. /**
  87263. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  87264. */
  87265. export class Engine {
  87266. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  87267. static ExceptionList: ({
  87268. key: string;
  87269. capture: string;
  87270. captureConstraint: number;
  87271. targets: string[];
  87272. } | {
  87273. key: string;
  87274. capture: null;
  87275. captureConstraint: null;
  87276. targets: string[];
  87277. })[];
  87278. /** Gets the list of created engines */
  87279. static readonly Instances: Engine[];
  87280. /**
  87281. * Gets the latest created engine
  87282. */
  87283. static readonly LastCreatedEngine: Nullable<Engine>;
  87284. /**
  87285. * Gets the latest created scene
  87286. */
  87287. static readonly LastCreatedScene: Nullable<Scene>;
  87288. /**
  87289. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  87290. * @param flag defines which part of the materials must be marked as dirty
  87291. * @param predicate defines a predicate used to filter which materials should be affected
  87292. */
  87293. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  87294. /**
  87295. * Hidden
  87296. */
  87297. static _TextureLoaders: IInternalTextureLoader[];
  87298. /** Defines that alpha blending is disabled */
  87299. static readonly ALPHA_DISABLE: number;
  87300. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  87301. static readonly ALPHA_ADD: number;
  87302. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  87303. static readonly ALPHA_COMBINE: number;
  87304. /** Defines that alpha blending to DEST - SRC * DEST */
  87305. static readonly ALPHA_SUBTRACT: number;
  87306. /** Defines that alpha blending to SRC * DEST */
  87307. static readonly ALPHA_MULTIPLY: number;
  87308. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  87309. static readonly ALPHA_MAXIMIZED: number;
  87310. /** Defines that alpha blending to SRC + DEST */
  87311. static readonly ALPHA_ONEONE: number;
  87312. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  87313. static readonly ALPHA_PREMULTIPLIED: number;
  87314. /**
  87315. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  87316. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  87317. */
  87318. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  87319. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  87320. static readonly ALPHA_INTERPOLATE: number;
  87321. /**
  87322. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  87323. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  87324. */
  87325. static readonly ALPHA_SCREENMODE: number;
  87326. /** Defines that the ressource is not delayed*/
  87327. static readonly DELAYLOADSTATE_NONE: number;
  87328. /** Defines that the ressource was successfully delay loaded */
  87329. static readonly DELAYLOADSTATE_LOADED: number;
  87330. /** Defines that the ressource is currently delay loading */
  87331. static readonly DELAYLOADSTATE_LOADING: number;
  87332. /** Defines that the ressource is delayed and has not started loading */
  87333. static readonly DELAYLOADSTATE_NOTLOADED: number;
  87334. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  87335. static readonly NEVER: number;
  87336. /** 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 */
  87337. static readonly ALWAYS: number;
  87338. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  87339. static readonly LESS: number;
  87340. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  87341. static readonly EQUAL: number;
  87342. /** 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 */
  87343. static readonly LEQUAL: number;
  87344. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  87345. static readonly GREATER: number;
  87346. /** 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 */
  87347. static readonly GEQUAL: number;
  87348. /** 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 */
  87349. static readonly NOTEQUAL: number;
  87350. /** Passed to stencilOperation to specify that stencil value must be kept */
  87351. static readonly KEEP: number;
  87352. /** Passed to stencilOperation to specify that stencil value must be replaced */
  87353. static readonly REPLACE: number;
  87354. /** Passed to stencilOperation to specify that stencil value must be incremented */
  87355. static readonly INCR: number;
  87356. /** Passed to stencilOperation to specify that stencil value must be decremented */
  87357. static readonly DECR: number;
  87358. /** Passed to stencilOperation to specify that stencil value must be inverted */
  87359. static readonly INVERT: number;
  87360. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  87361. static readonly INCR_WRAP: number;
  87362. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  87363. static readonly DECR_WRAP: number;
  87364. /** Texture is not repeating outside of 0..1 UVs */
  87365. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  87366. /** Texture is repeating outside of 0..1 UVs */
  87367. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  87368. /** Texture is repeating and mirrored */
  87369. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  87370. /** ALPHA */
  87371. static readonly TEXTUREFORMAT_ALPHA: number;
  87372. /** LUMINANCE */
  87373. static readonly TEXTUREFORMAT_LUMINANCE: number;
  87374. /** LUMINANCE_ALPHA */
  87375. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  87376. /** RGB */
  87377. static readonly TEXTUREFORMAT_RGB: number;
  87378. /** RGBA */
  87379. static readonly TEXTUREFORMAT_RGBA: number;
  87380. /** RED */
  87381. static readonly TEXTUREFORMAT_RED: number;
  87382. /** RED (2nd reference) */
  87383. static readonly TEXTUREFORMAT_R: number;
  87384. /** RG */
  87385. static readonly TEXTUREFORMAT_RG: number;
  87386. /** RED_INTEGER */
  87387. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  87388. /** RED_INTEGER (2nd reference) */
  87389. static readonly TEXTUREFORMAT_R_INTEGER: number;
  87390. /** RG_INTEGER */
  87391. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  87392. /** RGB_INTEGER */
  87393. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  87394. /** RGBA_INTEGER */
  87395. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  87396. /** UNSIGNED_BYTE */
  87397. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  87398. /** UNSIGNED_BYTE (2nd reference) */
  87399. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  87400. /** FLOAT */
  87401. static readonly TEXTURETYPE_FLOAT: number;
  87402. /** HALF_FLOAT */
  87403. static readonly TEXTURETYPE_HALF_FLOAT: number;
  87404. /** BYTE */
  87405. static readonly TEXTURETYPE_BYTE: number;
  87406. /** SHORT */
  87407. static readonly TEXTURETYPE_SHORT: number;
  87408. /** UNSIGNED_SHORT */
  87409. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  87410. /** INT */
  87411. static readonly TEXTURETYPE_INT: number;
  87412. /** UNSIGNED_INT */
  87413. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  87414. /** UNSIGNED_SHORT_4_4_4_4 */
  87415. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  87416. /** UNSIGNED_SHORT_5_5_5_1 */
  87417. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  87418. /** UNSIGNED_SHORT_5_6_5 */
  87419. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  87420. /** UNSIGNED_INT_2_10_10_10_REV */
  87421. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  87422. /** UNSIGNED_INT_24_8 */
  87423. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  87424. /** UNSIGNED_INT_10F_11F_11F_REV */
  87425. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  87426. /** UNSIGNED_INT_5_9_9_9_REV */
  87427. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  87428. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  87429. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  87430. /** nearest is mag = nearest and min = nearest and mip = linear */
  87431. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  87432. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87433. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  87434. /** Trilinear is mag = linear and min = linear and mip = linear */
  87435. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  87436. /** nearest is mag = nearest and min = nearest and mip = linear */
  87437. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  87438. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87439. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  87440. /** Trilinear is mag = linear and min = linear and mip = linear */
  87441. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  87442. /** mag = nearest and min = nearest and mip = nearest */
  87443. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  87444. /** mag = nearest and min = linear and mip = nearest */
  87445. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  87446. /** mag = nearest and min = linear and mip = linear */
  87447. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  87448. /** mag = nearest and min = linear and mip = none */
  87449. static readonly TEXTURE_NEAREST_LINEAR: number;
  87450. /** mag = nearest and min = nearest and mip = none */
  87451. static readonly TEXTURE_NEAREST_NEAREST: number;
  87452. /** mag = linear and min = nearest and mip = nearest */
  87453. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  87454. /** mag = linear and min = nearest and mip = linear */
  87455. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  87456. /** mag = linear and min = linear and mip = none */
  87457. static readonly TEXTURE_LINEAR_LINEAR: number;
  87458. /** mag = linear and min = nearest and mip = none */
  87459. static readonly TEXTURE_LINEAR_NEAREST: number;
  87460. /** Explicit coordinates mode */
  87461. static readonly TEXTURE_EXPLICIT_MODE: number;
  87462. /** Spherical coordinates mode */
  87463. static readonly TEXTURE_SPHERICAL_MODE: number;
  87464. /** Planar coordinates mode */
  87465. static readonly TEXTURE_PLANAR_MODE: number;
  87466. /** Cubic coordinates mode */
  87467. static readonly TEXTURE_CUBIC_MODE: number;
  87468. /** Projection coordinates mode */
  87469. static readonly TEXTURE_PROJECTION_MODE: number;
  87470. /** Skybox coordinates mode */
  87471. static readonly TEXTURE_SKYBOX_MODE: number;
  87472. /** Inverse Cubic coordinates mode */
  87473. static readonly TEXTURE_INVCUBIC_MODE: number;
  87474. /** Equirectangular coordinates mode */
  87475. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  87476. /** Equirectangular Fixed coordinates mode */
  87477. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  87478. /** Equirectangular Fixed Mirrored coordinates mode */
  87479. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  87480. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  87481. static readonly SCALEMODE_FLOOR: number;
  87482. /** Defines that texture rescaling will look for the nearest power of 2 size */
  87483. static readonly SCALEMODE_NEAREST: number;
  87484. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  87485. static readonly SCALEMODE_CEILING: number;
  87486. /**
  87487. * Returns the current npm package of the sdk
  87488. */
  87489. static readonly NpmPackage: string;
  87490. /**
  87491. * Returns the current version of the framework
  87492. */
  87493. static readonly Version: string;
  87494. /**
  87495. * Returns a string describing the current engine
  87496. */
  87497. readonly description: string;
  87498. /**
  87499. * Gets or sets the epsilon value used by collision engine
  87500. */
  87501. static CollisionsEpsilon: number;
  87502. /**
  87503. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87504. */
  87505. static ShadersRepository: string;
  87506. /**
  87507. * Method called to create the default loading screen.
  87508. * This can be overriden in your own app.
  87509. * @param canvas The rendering canvas element
  87510. * @returns The loading screen
  87511. */
  87512. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  87513. /**
  87514. * Method called to create the default rescale post process on each engine.
  87515. */
  87516. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  87517. /**
  87518. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  87519. */
  87520. forcePOTTextures: boolean;
  87521. /**
  87522. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  87523. */
  87524. isFullscreen: boolean;
  87525. /**
  87526. * Gets a boolean indicating if the pointer is currently locked
  87527. */
  87528. isPointerLock: boolean;
  87529. /**
  87530. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  87531. */
  87532. cullBackFaces: boolean;
  87533. /**
  87534. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  87535. */
  87536. renderEvenInBackground: boolean;
  87537. /**
  87538. * Gets or sets a boolean indicating that cache can be kept between frames
  87539. */
  87540. preventCacheWipeBetweenFrames: boolean;
  87541. /**
  87542. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  87543. **/
  87544. enableOfflineSupport: boolean;
  87545. /**
  87546. * 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)
  87547. **/
  87548. disableManifestCheck: boolean;
  87549. /**
  87550. * Gets the list of created scenes
  87551. */
  87552. scenes: Scene[];
  87553. /**
  87554. * Event raised when a new scene is created
  87555. */
  87556. onNewSceneAddedObservable: Observable<Scene>;
  87557. /**
  87558. * Gets the list of created postprocesses
  87559. */
  87560. postProcesses: PostProcess[];
  87561. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  87562. validateShaderPrograms: boolean;
  87563. /**
  87564. * Observable event triggered each time the rendering canvas is resized
  87565. */
  87566. onResizeObservable: Observable<Engine>;
  87567. /**
  87568. * Observable event triggered each time the canvas loses focus
  87569. */
  87570. onCanvasBlurObservable: Observable<Engine>;
  87571. /**
  87572. * Observable event triggered each time the canvas gains focus
  87573. */
  87574. onCanvasFocusObservable: Observable<Engine>;
  87575. /**
  87576. * Observable event triggered each time the canvas receives pointerout event
  87577. */
  87578. onCanvasPointerOutObservable: Observable<PointerEvent>;
  87579. /**
  87580. * Observable event triggered before each texture is initialized
  87581. */
  87582. onBeforeTextureInitObservable: Observable<Texture>;
  87583. /**
  87584. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  87585. */
  87586. disableUniformBuffers: boolean;
  87587. /** @hidden */
  87588. _uniformBuffers: UniformBuffer[];
  87589. /**
  87590. * Gets a boolean indicating that the engine supports uniform buffers
  87591. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87592. */
  87593. readonly supportsUniformBuffers: boolean;
  87594. /**
  87595. * Observable raised when the engine begins a new frame
  87596. */
  87597. onBeginFrameObservable: Observable<Engine>;
  87598. /**
  87599. * If set, will be used to request the next animation frame for the render loop
  87600. */
  87601. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  87602. /**
  87603. * Observable raised when the engine ends the current frame
  87604. */
  87605. onEndFrameObservable: Observable<Engine>;
  87606. /**
  87607. * Observable raised when the engine is about to compile a shader
  87608. */
  87609. onBeforeShaderCompilationObservable: Observable<Engine>;
  87610. /**
  87611. * Observable raised when the engine has jsut compiled a shader
  87612. */
  87613. onAfterShaderCompilationObservable: Observable<Engine>;
  87614. /** @hidden */
  87615. _gl: WebGLRenderingContext;
  87616. private _renderingCanvas;
  87617. private _windowIsBackground;
  87618. private _webGLVersion;
  87619. protected _highPrecisionShadersAllowed: boolean;
  87620. /** @hidden */
  87621. readonly _shouldUseHighPrecisionShader: boolean;
  87622. /**
  87623. * Gets a boolean indicating that only power of 2 textures are supported
  87624. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  87625. */
  87626. readonly needPOTTextures: boolean;
  87627. /** @hidden */
  87628. _badOS: boolean;
  87629. /** @hidden */
  87630. _badDesktopOS: boolean;
  87631. /**
  87632. * Gets the audio engine
  87633. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87634. * @ignorenaming
  87635. */
  87636. static audioEngine: IAudioEngine;
  87637. /**
  87638. * Default AudioEngine factory responsible of creating the Audio Engine.
  87639. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  87640. */
  87641. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  87642. /**
  87643. * Default offline support factory responsible of creating a tool used to store data locally.
  87644. * By default, this will create a Database object if the workload has been embedded.
  87645. */
  87646. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  87647. private _onFocus;
  87648. private _onBlur;
  87649. private _onCanvasPointerOut;
  87650. private _onCanvasBlur;
  87651. private _onCanvasFocus;
  87652. private _onFullscreenChange;
  87653. private _onPointerLockChange;
  87654. private _hardwareScalingLevel;
  87655. /** @hidden */
  87656. _caps: EngineCapabilities;
  87657. private _pointerLockRequested;
  87658. private _isStencilEnable;
  87659. private _colorWrite;
  87660. private _loadingScreen;
  87661. /** @hidden */
  87662. _drawCalls: PerfCounter;
  87663. private _glVersion;
  87664. private _glRenderer;
  87665. private _glVendor;
  87666. private _videoTextureSupported;
  87667. private _renderingQueueLaunched;
  87668. private _activeRenderLoops;
  87669. private _deterministicLockstep;
  87670. private _lockstepMaxSteps;
  87671. /**
  87672. * Observable signaled when a context lost event is raised
  87673. */
  87674. onContextLostObservable: Observable<Engine>;
  87675. /**
  87676. * Observable signaled when a context restored event is raised
  87677. */
  87678. onContextRestoredObservable: Observable<Engine>;
  87679. private _onContextLost;
  87680. private _onContextRestored;
  87681. private _contextWasLost;
  87682. /** @hidden */
  87683. _doNotHandleContextLost: boolean;
  87684. /**
  87685. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  87686. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  87687. */
  87688. doNotHandleContextLost: boolean;
  87689. private _performanceMonitor;
  87690. private _fps;
  87691. private _deltaTime;
  87692. /**
  87693. * Turn this value on if you want to pause FPS computation when in background
  87694. */
  87695. disablePerformanceMonitorInBackground: boolean;
  87696. /**
  87697. * Gets the performance monitor attached to this engine
  87698. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  87699. */
  87700. readonly performanceMonitor: PerformanceMonitor;
  87701. /**
  87702. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  87703. */
  87704. disableVertexArrayObjects: boolean;
  87705. /** @hidden */
  87706. protected _depthCullingState: _DepthCullingState;
  87707. /** @hidden */
  87708. protected _stencilState: _StencilState;
  87709. /** @hidden */
  87710. protected _alphaState: _AlphaState;
  87711. /** @hidden */
  87712. protected _alphaMode: number;
  87713. /** @hidden */
  87714. _internalTexturesCache: InternalTexture[];
  87715. /** @hidden */
  87716. protected _activeChannel: number;
  87717. private _currentTextureChannel;
  87718. /** @hidden */
  87719. protected _boundTexturesCache: {
  87720. [key: string]: Nullable<InternalTexture>;
  87721. };
  87722. /** @hidden */
  87723. protected _currentEffect: Nullable<Effect>;
  87724. /** @hidden */
  87725. protected _currentProgram: Nullable<WebGLProgram>;
  87726. private _compiledEffects;
  87727. private _vertexAttribArraysEnabled;
  87728. /** @hidden */
  87729. protected _cachedViewport: Nullable<Viewport>;
  87730. private _cachedVertexArrayObject;
  87731. /** @hidden */
  87732. protected _cachedVertexBuffers: any;
  87733. /** @hidden */
  87734. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  87735. /** @hidden */
  87736. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  87737. /** @hidden */
  87738. _currentRenderTarget: Nullable<InternalTexture>;
  87739. private _uintIndicesCurrentlySet;
  87740. private _currentBoundBuffer;
  87741. /** @hidden */
  87742. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  87743. private _currentBufferPointers;
  87744. private _currentInstanceLocations;
  87745. private _currentInstanceBuffers;
  87746. private _textureUnits;
  87747. /** @hidden */
  87748. _workingCanvas: Nullable<HTMLCanvasElement>;
  87749. /** @hidden */
  87750. _workingContext: Nullable<CanvasRenderingContext2D>;
  87751. private _rescalePostProcess;
  87752. private _dummyFramebuffer;
  87753. private _externalData;
  87754. /** @hidden */
  87755. _bindedRenderFunction: any;
  87756. private _vaoRecordInProgress;
  87757. private _mustWipeVertexAttributes;
  87758. private _emptyTexture;
  87759. private _emptyCubeTexture;
  87760. private _emptyTexture3D;
  87761. /** @hidden */
  87762. _frameHandler: number;
  87763. private _nextFreeTextureSlots;
  87764. private _maxSimultaneousTextures;
  87765. private _activeRequests;
  87766. private _texturesSupported;
  87767. /** @hidden */
  87768. _textureFormatInUse: Nullable<string>;
  87769. /**
  87770. * Gets the list of texture formats supported
  87771. */
  87772. readonly texturesSupported: Array<string>;
  87773. /**
  87774. * Gets the list of texture formats in use
  87775. */
  87776. readonly textureFormatInUse: Nullable<string>;
  87777. /**
  87778. * Gets the current viewport
  87779. */
  87780. readonly currentViewport: Nullable<Viewport>;
  87781. /**
  87782. * Gets the default empty texture
  87783. */
  87784. readonly emptyTexture: InternalTexture;
  87785. /**
  87786. * Gets the default empty 3D texture
  87787. */
  87788. readonly emptyTexture3D: InternalTexture;
  87789. /**
  87790. * Gets the default empty cube texture
  87791. */
  87792. readonly emptyCubeTexture: InternalTexture;
  87793. /**
  87794. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  87795. */
  87796. readonly premultipliedAlpha: boolean;
  87797. /**
  87798. * Creates a new engine
  87799. * @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
  87800. * @param antialias defines enable antialiasing (default: false)
  87801. * @param options defines further options to be sent to the getContext() function
  87802. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  87803. */
  87804. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  87805. /**
  87806. * Initializes a webVR display and starts listening to display change events
  87807. * The onVRDisplayChangedObservable will be notified upon these changes
  87808. * @returns The onVRDisplayChangedObservable
  87809. */
  87810. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87811. /** @hidden */
  87812. _prepareVRComponent(): void;
  87813. /** @hidden */
  87814. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  87815. /** @hidden */
  87816. _submitVRFrame(): void;
  87817. /**
  87818. * Call this function to leave webVR mode
  87819. * Will do nothing if webVR is not supported or if there is no webVR device
  87820. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87821. */
  87822. disableVR(): void;
  87823. /**
  87824. * Gets a boolean indicating that the system is in VR mode and is presenting
  87825. * @returns true if VR mode is engaged
  87826. */
  87827. isVRPresenting(): boolean;
  87828. /** @hidden */
  87829. _requestVRFrame(): void;
  87830. private _disableTouchAction;
  87831. private _rebuildInternalTextures;
  87832. private _rebuildEffects;
  87833. /**
  87834. * Gets a boolean indicating if all created effects are ready
  87835. * @returns true if all effects are ready
  87836. */
  87837. areAllEffectsReady(): boolean;
  87838. private _rebuildBuffers;
  87839. private _initGLContext;
  87840. /**
  87841. * Gets version of the current webGL context
  87842. */
  87843. readonly webGLVersion: number;
  87844. /**
  87845. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  87846. */
  87847. readonly isStencilEnable: boolean;
  87848. /** @hidden */
  87849. _prepareWorkingCanvas(): void;
  87850. /**
  87851. * Reset the texture cache to empty state
  87852. */
  87853. resetTextureCache(): void;
  87854. /**
  87855. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  87856. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87857. * @returns true if engine is in deterministic lock step mode
  87858. */
  87859. isDeterministicLockStep(): boolean;
  87860. /**
  87861. * Gets the max steps when engine is running in deterministic lock step
  87862. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87863. * @returns the max steps
  87864. */
  87865. getLockstepMaxSteps(): number;
  87866. /**
  87867. * Gets an object containing information about the current webGL context
  87868. * @returns an object containing the vender, the renderer and the version of the current webGL context
  87869. */
  87870. getGlInfo(): {
  87871. vendor: string;
  87872. renderer: string;
  87873. version: string;
  87874. };
  87875. /**
  87876. * Gets current aspect ratio
  87877. * @param camera defines the camera to use to get the aspect ratio
  87878. * @param useScreen defines if screen size must be used (or the current render target if any)
  87879. * @returns a number defining the aspect ratio
  87880. */
  87881. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  87882. /**
  87883. * Gets current screen aspect ratio
  87884. * @returns a number defining the aspect ratio
  87885. */
  87886. getScreenAspectRatio(): number;
  87887. /**
  87888. * Gets the current render width
  87889. * @param useScreen defines if screen size must be used (or the current render target if any)
  87890. * @returns a number defining the current render width
  87891. */
  87892. getRenderWidth(useScreen?: boolean): number;
  87893. /**
  87894. * Gets the current render height
  87895. * @param useScreen defines if screen size must be used (or the current render target if any)
  87896. * @returns a number defining the current render height
  87897. */
  87898. getRenderHeight(useScreen?: boolean): number;
  87899. /**
  87900. * Gets the HTML canvas attached with the current webGL context
  87901. * @returns a HTML canvas
  87902. */
  87903. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  87904. /**
  87905. * Gets the client rect of the HTML canvas attached with the current webGL context
  87906. * @returns a client rectanglee
  87907. */
  87908. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  87909. /**
  87910. * Defines the hardware scaling level.
  87911. * By default the hardware scaling level is computed from the window device ratio.
  87912. * 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.
  87913. * @param level defines the level to use
  87914. */
  87915. setHardwareScalingLevel(level: number): void;
  87916. /**
  87917. * Gets the current hardware scaling level.
  87918. * By default the hardware scaling level is computed from the window device ratio.
  87919. * 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.
  87920. * @returns a number indicating the current hardware scaling level
  87921. */
  87922. getHardwareScalingLevel(): number;
  87923. /**
  87924. * Gets the list of loaded textures
  87925. * @returns an array containing all loaded textures
  87926. */
  87927. getLoadedTexturesCache(): InternalTexture[];
  87928. /**
  87929. * Gets the object containing all engine capabilities
  87930. * @returns the EngineCapabilities object
  87931. */
  87932. getCaps(): EngineCapabilities;
  87933. /**
  87934. * Gets the current depth function
  87935. * @returns a number defining the depth function
  87936. */
  87937. getDepthFunction(): Nullable<number>;
  87938. /**
  87939. * Sets the current depth function
  87940. * @param depthFunc defines the function to use
  87941. */
  87942. setDepthFunction(depthFunc: number): void;
  87943. /**
  87944. * Sets the current depth function to GREATER
  87945. */
  87946. setDepthFunctionToGreater(): void;
  87947. /**
  87948. * Sets the current depth function to GEQUAL
  87949. */
  87950. setDepthFunctionToGreaterOrEqual(): void;
  87951. /**
  87952. * Sets the current depth function to LESS
  87953. */
  87954. setDepthFunctionToLess(): void;
  87955. private _cachedStencilBuffer;
  87956. private _cachedStencilFunction;
  87957. private _cachedStencilMask;
  87958. private _cachedStencilOperationPass;
  87959. private _cachedStencilOperationFail;
  87960. private _cachedStencilOperationDepthFail;
  87961. private _cachedStencilReference;
  87962. /**
  87963. * Caches the the state of the stencil buffer
  87964. */
  87965. cacheStencilState(): void;
  87966. /**
  87967. * Restores the state of the stencil buffer
  87968. */
  87969. restoreStencilState(): void;
  87970. /**
  87971. * Sets the current depth function to LEQUAL
  87972. */
  87973. setDepthFunctionToLessOrEqual(): void;
  87974. /**
  87975. * Gets a boolean indicating if stencil buffer is enabled
  87976. * @returns the current stencil buffer state
  87977. */
  87978. getStencilBuffer(): boolean;
  87979. /**
  87980. * Enable or disable the stencil buffer
  87981. * @param enable defines if the stencil buffer must be enabled or disabled
  87982. */
  87983. setStencilBuffer(enable: boolean): void;
  87984. /**
  87985. * Gets the current stencil mask
  87986. * @returns a number defining the new stencil mask to use
  87987. */
  87988. getStencilMask(): number;
  87989. /**
  87990. * Sets the current stencil mask
  87991. * @param mask defines the new stencil mask to use
  87992. */
  87993. setStencilMask(mask: number): void;
  87994. /**
  87995. * Gets the current stencil function
  87996. * @returns a number defining the stencil function to use
  87997. */
  87998. getStencilFunction(): number;
  87999. /**
  88000. * Gets the current stencil reference value
  88001. * @returns a number defining the stencil reference value to use
  88002. */
  88003. getStencilFunctionReference(): number;
  88004. /**
  88005. * Gets the current stencil mask
  88006. * @returns a number defining the stencil mask to use
  88007. */
  88008. getStencilFunctionMask(): number;
  88009. /**
  88010. * Sets the current stencil function
  88011. * @param stencilFunc defines the new stencil function to use
  88012. */
  88013. setStencilFunction(stencilFunc: number): void;
  88014. /**
  88015. * Sets the current stencil reference
  88016. * @param reference defines the new stencil reference to use
  88017. */
  88018. setStencilFunctionReference(reference: number): void;
  88019. /**
  88020. * Sets the current stencil mask
  88021. * @param mask defines the new stencil mask to use
  88022. */
  88023. setStencilFunctionMask(mask: number): void;
  88024. /**
  88025. * Gets the current stencil operation when stencil fails
  88026. * @returns a number defining stencil operation to use when stencil fails
  88027. */
  88028. getStencilOperationFail(): number;
  88029. /**
  88030. * Gets the current stencil operation when depth fails
  88031. * @returns a number defining stencil operation to use when depth fails
  88032. */
  88033. getStencilOperationDepthFail(): number;
  88034. /**
  88035. * Gets the current stencil operation when stencil passes
  88036. * @returns a number defining stencil operation to use when stencil passes
  88037. */
  88038. getStencilOperationPass(): number;
  88039. /**
  88040. * Sets the stencil operation to use when stencil fails
  88041. * @param operation defines the stencil operation to use when stencil fails
  88042. */
  88043. setStencilOperationFail(operation: number): void;
  88044. /**
  88045. * Sets the stencil operation to use when depth fails
  88046. * @param operation defines the stencil operation to use when depth fails
  88047. */
  88048. setStencilOperationDepthFail(operation: number): void;
  88049. /**
  88050. * Sets the stencil operation to use when stencil passes
  88051. * @param operation defines the stencil operation to use when stencil passes
  88052. */
  88053. setStencilOperationPass(operation: number): void;
  88054. /**
  88055. * Sets a boolean indicating if the dithering state is enabled or disabled
  88056. * @param value defines the dithering state
  88057. */
  88058. setDitheringState(value: boolean): void;
  88059. /**
  88060. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  88061. * @param value defines the rasterizer state
  88062. */
  88063. setRasterizerState(value: boolean): void;
  88064. /**
  88065. * stop executing a render loop function and remove it from the execution array
  88066. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  88067. */
  88068. stopRenderLoop(renderFunction?: () => void): void;
  88069. /** @hidden */
  88070. _renderLoop(): void;
  88071. /**
  88072. * Register and execute a render loop. The engine can have more than one render function
  88073. * @param renderFunction defines the function to continuously execute
  88074. */
  88075. runRenderLoop(renderFunction: () => void): void;
  88076. /**
  88077. * Toggle full screen mode
  88078. * @param requestPointerLock defines if a pointer lock should be requested from the user
  88079. */
  88080. switchFullscreen(requestPointerLock: boolean): void;
  88081. /**
  88082. * Enters full screen mode
  88083. * @param requestPointerLock defines if a pointer lock should be requested from the user
  88084. */
  88085. enterFullscreen(requestPointerLock: boolean): void;
  88086. /**
  88087. * Exits full screen mode
  88088. */
  88089. exitFullscreen(): void;
  88090. /**
  88091. * Clear the current render buffer or the current render target (if any is set up)
  88092. * @param color defines the color to use
  88093. * @param backBuffer defines if the back buffer must be cleared
  88094. * @param depth defines if the depth buffer must be cleared
  88095. * @param stencil defines if the stencil buffer must be cleared
  88096. */
  88097. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  88098. /**
  88099. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  88100. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  88101. * @param y defines the y-coordinate of the corner of the clear rectangle
  88102. * @param width defines the width of the clear rectangle
  88103. * @param height defines the height of the clear rectangle
  88104. * @param clearColor defines the clear color
  88105. */
  88106. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  88107. /**
  88108. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  88109. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  88110. * @param y defines the y-coordinate of the corner of the clear rectangle
  88111. * @param width defines the width of the clear rectangle
  88112. * @param height defines the height of the clear rectangle
  88113. */
  88114. enableScissor(x: number, y: number, width: number, height: number): void;
  88115. /**
  88116. * Disable previously set scissor test rectangle
  88117. */
  88118. disableScissor(): void;
  88119. private _viewportCached;
  88120. /** @hidden */
  88121. _viewport(x: number, y: number, width: number, height: number): void;
  88122. /**
  88123. * Set the WebGL's viewport
  88124. * @param viewport defines the viewport element to be used
  88125. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  88126. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  88127. */
  88128. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  88129. /**
  88130. * Directly set the WebGL Viewport
  88131. * @param x defines the x coordinate of the viewport (in screen space)
  88132. * @param y defines the y coordinate of the viewport (in screen space)
  88133. * @param width defines the width of the viewport (in screen space)
  88134. * @param height defines the height of the viewport (in screen space)
  88135. * @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
  88136. */
  88137. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  88138. /**
  88139. * Begin a new frame
  88140. */
  88141. beginFrame(): void;
  88142. /**
  88143. * Enf the current frame
  88144. */
  88145. endFrame(): void;
  88146. /**
  88147. * Resize the view according to the canvas' size
  88148. */
  88149. resize(): void;
  88150. /**
  88151. * Force a specific size of the canvas
  88152. * @param width defines the new canvas' width
  88153. * @param height defines the new canvas' height
  88154. */
  88155. setSize(width: number, height: number): void;
  88156. /**
  88157. * Binds the frame buffer to the specified texture.
  88158. * @param texture The texture to render to or null for the default canvas
  88159. * @param faceIndex The face of the texture to render to in case of cube texture
  88160. * @param requiredWidth The width of the target to render to
  88161. * @param requiredHeight The height of the target to render to
  88162. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  88163. * @param depthStencilTexture The depth stencil texture to use to render
  88164. * @param lodLevel defines le lod level to bind to the frame buffer
  88165. */
  88166. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  88167. /** @hidden */
  88168. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  88169. /**
  88170. * Unbind the current render target texture from the webGL context
  88171. * @param texture defines the render target texture to unbind
  88172. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  88173. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  88174. */
  88175. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  88176. /**
  88177. * Force the mipmap generation for the given render target texture
  88178. * @param texture defines the render target texture to use
  88179. */
  88180. generateMipMapsForCubemap(texture: InternalTexture): void;
  88181. /**
  88182. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  88183. */
  88184. flushFramebuffer(): void;
  88185. /**
  88186. * Unbind the current render target and bind the default framebuffer
  88187. */
  88188. restoreDefaultFramebuffer(): void;
  88189. /**
  88190. * Create an uniform buffer
  88191. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88192. * @param elements defines the content of the uniform buffer
  88193. * @returns the webGL uniform buffer
  88194. */
  88195. createUniformBuffer(elements: FloatArray): DataBuffer;
  88196. /**
  88197. * Create a dynamic uniform buffer
  88198. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88199. * @param elements defines the content of the uniform buffer
  88200. * @returns the webGL uniform buffer
  88201. */
  88202. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88203. /**
  88204. * Update an existing uniform buffer
  88205. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88206. * @param uniformBuffer defines the target uniform buffer
  88207. * @param elements defines the content to update
  88208. * @param offset defines the offset in the uniform buffer where update should start
  88209. * @param count defines the size of the data to update
  88210. */
  88211. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88212. private _resetVertexBufferBinding;
  88213. /**
  88214. * Creates a vertex buffer
  88215. * @param data the data for the vertex buffer
  88216. * @returns the new WebGL static buffer
  88217. */
  88218. createVertexBuffer(data: DataArray): DataBuffer;
  88219. /**
  88220. * Creates a dynamic vertex buffer
  88221. * @param data the data for the dynamic vertex buffer
  88222. * @returns the new WebGL dynamic buffer
  88223. */
  88224. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  88225. /**
  88226. * Update a dynamic index buffer
  88227. * @param indexBuffer defines the target index buffer
  88228. * @param indices defines the data to update
  88229. * @param offset defines the offset in the target index buffer where update should start
  88230. */
  88231. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  88232. /**
  88233. * Updates a dynamic vertex buffer.
  88234. * @param vertexBuffer the vertex buffer to update
  88235. * @param data the data used to update the vertex buffer
  88236. * @param byteOffset the byte offset of the data
  88237. * @param byteLength the byte length of the data
  88238. */
  88239. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  88240. private _resetIndexBufferBinding;
  88241. /**
  88242. * Creates a new index buffer
  88243. * @param indices defines the content of the index buffer
  88244. * @param updatable defines if the index buffer must be updatable
  88245. * @returns a new webGL buffer
  88246. */
  88247. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  88248. /**
  88249. * Bind a webGL buffer to the webGL context
  88250. * @param buffer defines the buffer to bind
  88251. */
  88252. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  88253. /**
  88254. * Bind an uniform buffer to the current webGL context
  88255. * @param buffer defines the buffer to bind
  88256. */
  88257. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88258. /**
  88259. * Bind a buffer to the current webGL context at a given location
  88260. * @param buffer defines the buffer to bind
  88261. * @param location defines the index where to bind the buffer
  88262. */
  88263. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88264. /**
  88265. * Bind a specific block at a given index in a specific shader program
  88266. * @param pipelineContext defines the pipeline context to use
  88267. * @param blockName defines the block name
  88268. * @param index defines the index where to bind the block
  88269. */
  88270. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88271. private bindIndexBuffer;
  88272. private bindBuffer;
  88273. /**
  88274. * update the bound buffer with the given data
  88275. * @param data defines the data to update
  88276. */
  88277. updateArrayBuffer(data: Float32Array): void;
  88278. private _vertexAttribPointer;
  88279. private _bindIndexBufferWithCache;
  88280. private _bindVertexBuffersAttributes;
  88281. /**
  88282. * Records a vertex array object
  88283. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88284. * @param vertexBuffers defines the list of vertex buffers to store
  88285. * @param indexBuffer defines the index buffer to store
  88286. * @param effect defines the effect to store
  88287. * @returns the new vertex array object
  88288. */
  88289. recordVertexArrayObject(vertexBuffers: {
  88290. [key: string]: VertexBuffer;
  88291. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  88292. /**
  88293. * Bind a specific vertex array object
  88294. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88295. * @param vertexArrayObject defines the vertex array object to bind
  88296. * @param indexBuffer defines the index buffer to bind
  88297. */
  88298. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  88299. /**
  88300. * Bind webGl buffers directly to the webGL context
  88301. * @param vertexBuffer defines the vertex buffer to bind
  88302. * @param indexBuffer defines the index buffer to bind
  88303. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  88304. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  88305. * @param effect defines the effect associated with the vertex buffer
  88306. */
  88307. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  88308. private _unbindVertexArrayObject;
  88309. /**
  88310. * Bind a list of vertex buffers to the webGL context
  88311. * @param vertexBuffers defines the list of vertex buffers to bind
  88312. * @param indexBuffer defines the index buffer to bind
  88313. * @param effect defines the effect associated with the vertex buffers
  88314. */
  88315. bindBuffers(vertexBuffers: {
  88316. [key: string]: Nullable<VertexBuffer>;
  88317. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  88318. /**
  88319. * Unbind all instance attributes
  88320. */
  88321. unbindInstanceAttributes(): void;
  88322. /**
  88323. * Release and free the memory of a vertex array object
  88324. * @param vao defines the vertex array object to delete
  88325. */
  88326. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  88327. /** @hidden */
  88328. _releaseBuffer(buffer: DataBuffer): boolean;
  88329. /**
  88330. * Creates a webGL buffer to use with instanciation
  88331. * @param capacity defines the size of the buffer
  88332. * @returns the webGL buffer
  88333. */
  88334. createInstancesBuffer(capacity: number): DataBuffer;
  88335. /**
  88336. * Delete a webGL buffer used with instanciation
  88337. * @param buffer defines the webGL buffer to delete
  88338. */
  88339. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  88340. /**
  88341. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  88342. * @param instancesBuffer defines the webGL buffer to update and bind
  88343. * @param data defines the data to store in the buffer
  88344. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  88345. */
  88346. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  88347. /**
  88348. * Apply all cached states (depth, culling, stencil and alpha)
  88349. */
  88350. applyStates(): void;
  88351. /**
  88352. * Send a draw order
  88353. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88354. * @param indexStart defines the starting index
  88355. * @param indexCount defines the number of index to draw
  88356. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88357. */
  88358. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  88359. /**
  88360. * Draw a list of points
  88361. * @param verticesStart defines the index of first vertex to draw
  88362. * @param verticesCount defines the count of vertices to draw
  88363. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88364. */
  88365. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88366. /**
  88367. * Draw a list of unindexed primitives
  88368. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88369. * @param verticesStart defines the index of first vertex to draw
  88370. * @param verticesCount defines the count of vertices to draw
  88371. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88372. */
  88373. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88374. /**
  88375. * Draw a list of indexed primitives
  88376. * @param fillMode defines the primitive to use
  88377. * @param indexStart defines the starting index
  88378. * @param indexCount defines the number of index to draw
  88379. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88380. */
  88381. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  88382. /**
  88383. * Draw a list of unindexed primitives
  88384. * @param fillMode defines the primitive to use
  88385. * @param verticesStart defines the index of first vertex to draw
  88386. * @param verticesCount defines the count of vertices to draw
  88387. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88388. */
  88389. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88390. private _drawMode;
  88391. /** @hidden */
  88392. _releaseEffect(effect: Effect): void;
  88393. /** @hidden */
  88394. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  88395. /**
  88396. * Create a new effect (used to store vertex/fragment shaders)
  88397. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  88398. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  88399. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  88400. * @param samplers defines an array of string used to represent textures
  88401. * @param defines defines the string containing the defines to use to compile the shaders
  88402. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  88403. * @param onCompiled defines a function to call when the effect creation is successful
  88404. * @param onError defines a function to call when the effect creation has failed
  88405. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  88406. * @returns the new Effect
  88407. */
  88408. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  88409. private _compileShader;
  88410. private _compileRawShader;
  88411. /**
  88412. * Directly creates a webGL program
  88413. * @param pipelineContext defines the pipeline context to attach to
  88414. * @param vertexCode defines the vertex shader code to use
  88415. * @param fragmentCode defines the fragment shader code to use
  88416. * @param context defines the webGL context to use (if not set, the current one will be used)
  88417. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88418. * @returns the new webGL program
  88419. */
  88420. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88421. /**
  88422. * Creates a webGL program
  88423. * @param pipelineContext defines the pipeline context to attach to
  88424. * @param vertexCode defines the vertex shader code to use
  88425. * @param fragmentCode defines the fragment shader code to use
  88426. * @param defines defines the string containing the defines to use to compile the shaders
  88427. * @param context defines the webGL context to use (if not set, the current one will be used)
  88428. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88429. * @returns the new webGL program
  88430. */
  88431. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88432. /**
  88433. * Creates a new pipeline context
  88434. * @returns the new pipeline
  88435. */
  88436. createPipelineContext(): WebGLPipelineContext;
  88437. private _createShaderProgram;
  88438. private _finalizePipelineContext;
  88439. /** @hidden */
  88440. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  88441. /** @hidden */
  88442. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  88443. /** @hidden */
  88444. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  88445. /**
  88446. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  88447. * @param pipelineContext defines the pipeline context to use
  88448. * @param uniformsNames defines the list of uniform names
  88449. * @returns an array of webGL uniform locations
  88450. */
  88451. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  88452. /**
  88453. * Gets the lsit of active attributes for a given webGL program
  88454. * @param pipelineContext defines the pipeline context to use
  88455. * @param attributesNames defines the list of attribute names to get
  88456. * @returns an array of indices indicating the offset of each attribute
  88457. */
  88458. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  88459. /**
  88460. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  88461. * @param effect defines the effect to activate
  88462. */
  88463. enableEffect(effect: Nullable<Effect>): void;
  88464. /**
  88465. * Set the value of an uniform to an array of int32
  88466. * @param uniform defines the webGL uniform location where to store the value
  88467. * @param array defines the array of int32 to store
  88468. */
  88469. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88470. /**
  88471. * Set the value of an uniform to an array of int32 (stored as vec2)
  88472. * @param uniform defines the webGL uniform location where to store the value
  88473. * @param array defines the array of int32 to store
  88474. */
  88475. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88476. /**
  88477. * Set the value of an uniform to an array of int32 (stored as vec3)
  88478. * @param uniform defines the webGL uniform location where to store the value
  88479. * @param array defines the array of int32 to store
  88480. */
  88481. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88482. /**
  88483. * Set the value of an uniform to an array of int32 (stored as vec4)
  88484. * @param uniform defines the webGL uniform location where to store the value
  88485. * @param array defines the array of int32 to store
  88486. */
  88487. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88488. /**
  88489. * Set the value of an uniform to an array of float32
  88490. * @param uniform defines the webGL uniform location where to store the value
  88491. * @param array defines the array of float32 to store
  88492. */
  88493. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88494. /**
  88495. * Set the value of an uniform to an array of float32 (stored as vec2)
  88496. * @param uniform defines the webGL uniform location where to store the value
  88497. * @param array defines the array of float32 to store
  88498. */
  88499. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88500. /**
  88501. * Set the value of an uniform to an array of float32 (stored as vec3)
  88502. * @param uniform defines the webGL uniform location where to store the value
  88503. * @param array defines the array of float32 to store
  88504. */
  88505. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88506. /**
  88507. * Set the value of an uniform to an array of float32 (stored as vec4)
  88508. * @param uniform defines the webGL uniform location where to store the value
  88509. * @param array defines the array of float32 to store
  88510. */
  88511. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88512. /**
  88513. * Set the value of an uniform to an array of number
  88514. * @param uniform defines the webGL uniform location where to store the value
  88515. * @param array defines the array of number to store
  88516. */
  88517. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88518. /**
  88519. * Set the value of an uniform to an array of number (stored as vec2)
  88520. * @param uniform defines the webGL uniform location where to store the value
  88521. * @param array defines the array of number to store
  88522. */
  88523. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88524. /**
  88525. * Set the value of an uniform to an array of number (stored as vec3)
  88526. * @param uniform defines the webGL uniform location where to store the value
  88527. * @param array defines the array of number to store
  88528. */
  88529. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88530. /**
  88531. * Set the value of an uniform to an array of number (stored as vec4)
  88532. * @param uniform defines the webGL uniform location where to store the value
  88533. * @param array defines the array of number to store
  88534. */
  88535. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88536. /**
  88537. * Set the value of an uniform to an array of float32 (stored as matrices)
  88538. * @param uniform defines the webGL uniform location where to store the value
  88539. * @param matrices defines the array of float32 to store
  88540. */
  88541. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  88542. /**
  88543. * Set the value of an uniform to a matrix
  88544. * @param uniform defines the webGL uniform location where to store the value
  88545. * @param matrix defines the matrix to store
  88546. */
  88547. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  88548. /**
  88549. * Set the value of an uniform to a matrix (3x3)
  88550. * @param uniform defines the webGL uniform location where to store the value
  88551. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  88552. */
  88553. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88554. /**
  88555. * Set the value of an uniform to a matrix (2x2)
  88556. * @param uniform defines the webGL uniform location where to store the value
  88557. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  88558. */
  88559. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88560. /**
  88561. * Set the value of an uniform to a number (int)
  88562. * @param uniform defines the webGL uniform location where to store the value
  88563. * @param value defines the int number to store
  88564. */
  88565. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88566. /**
  88567. * Set the value of an uniform to a number (float)
  88568. * @param uniform defines the webGL uniform location where to store the value
  88569. * @param value defines the float number to store
  88570. */
  88571. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88572. /**
  88573. * Set the value of an uniform to a vec2
  88574. * @param uniform defines the webGL uniform location where to store the value
  88575. * @param x defines the 1st component of the value
  88576. * @param y defines the 2nd component of the value
  88577. */
  88578. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  88579. /**
  88580. * Set the value of an uniform to a vec3
  88581. * @param uniform defines the webGL uniform location where to store the value
  88582. * @param x defines the 1st component of the value
  88583. * @param y defines the 2nd component of the value
  88584. * @param z defines the 3rd component of the value
  88585. */
  88586. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  88587. /**
  88588. * Set the value of an uniform to a boolean
  88589. * @param uniform defines the webGL uniform location where to store the value
  88590. * @param bool defines the boolean to store
  88591. */
  88592. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  88593. /**
  88594. * Set the value of an uniform to a vec4
  88595. * @param uniform defines the webGL uniform location where to store the value
  88596. * @param x defines the 1st component of the value
  88597. * @param y defines the 2nd component of the value
  88598. * @param z defines the 3rd component of the value
  88599. * @param w defines the 4th component of the value
  88600. */
  88601. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  88602. /**
  88603. * Set the value of an uniform to a Color3
  88604. * @param uniform defines the webGL uniform location where to store the value
  88605. * @param color3 defines the color to store
  88606. */
  88607. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  88608. /**
  88609. * Set the value of an uniform to a Color3 and an alpha value
  88610. * @param uniform defines the webGL uniform location where to store the value
  88611. * @param color3 defines the color to store
  88612. * @param alpha defines the alpha component to store
  88613. */
  88614. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  88615. /**
  88616. * Sets a Color4 on a uniform variable
  88617. * @param uniform defines the uniform location
  88618. * @param color4 defines the value to be set
  88619. */
  88620. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  88621. /**
  88622. * Set various states to the webGL context
  88623. * @param culling defines backface culling state
  88624. * @param zOffset defines the value to apply to zOffset (0 by default)
  88625. * @param force defines if states must be applied even if cache is up to date
  88626. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  88627. */
  88628. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  88629. /**
  88630. * Set the z offset to apply to current rendering
  88631. * @param value defines the offset to apply
  88632. */
  88633. setZOffset(value: number): void;
  88634. /**
  88635. * Gets the current value of the zOffset
  88636. * @returns the current zOffset state
  88637. */
  88638. getZOffset(): number;
  88639. /**
  88640. * Enable or disable depth buffering
  88641. * @param enable defines the state to set
  88642. */
  88643. setDepthBuffer(enable: boolean): void;
  88644. /**
  88645. * Gets a boolean indicating if depth writing is enabled
  88646. * @returns the current depth writing state
  88647. */
  88648. getDepthWrite(): boolean;
  88649. /**
  88650. * Enable or disable depth writing
  88651. * @param enable defines the state to set
  88652. */
  88653. setDepthWrite(enable: boolean): void;
  88654. /**
  88655. * Enable or disable color writing
  88656. * @param enable defines the state to set
  88657. */
  88658. setColorWrite(enable: boolean): void;
  88659. /**
  88660. * Gets a boolean indicating if color writing is enabled
  88661. * @returns the current color writing state
  88662. */
  88663. getColorWrite(): boolean;
  88664. /**
  88665. * Sets alpha constants used by some alpha blending modes
  88666. * @param r defines the red component
  88667. * @param g defines the green component
  88668. * @param b defines the blue component
  88669. * @param a defines the alpha component
  88670. */
  88671. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  88672. /**
  88673. * Sets the current alpha mode
  88674. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  88675. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  88676. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88677. */
  88678. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  88679. /**
  88680. * Gets the current alpha mode
  88681. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88682. * @returns the current alpha mode
  88683. */
  88684. getAlphaMode(): number;
  88685. /**
  88686. * Clears the list of texture accessible through engine.
  88687. * This can help preventing texture load conflict due to name collision.
  88688. */
  88689. clearInternalTexturesCache(): void;
  88690. /**
  88691. * Force the entire cache to be cleared
  88692. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  88693. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  88694. */
  88695. wipeCaches(bruteForce?: boolean): void;
  88696. /**
  88697. * Set the compressed texture format to use, based on the formats you have, and the formats
  88698. * supported by the hardware / browser.
  88699. *
  88700. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  88701. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  88702. * to API arguments needed to compressed textures. This puts the burden on the container
  88703. * generator to house the arcane code for determining these for current & future formats.
  88704. *
  88705. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  88706. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  88707. *
  88708. * Note: The result of this call is not taken into account when a texture is base64.
  88709. *
  88710. * @param formatsAvailable defines the list of those format families you have created
  88711. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  88712. *
  88713. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  88714. * @returns The extension selected.
  88715. */
  88716. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  88717. /** @hidden */
  88718. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  88719. min: number;
  88720. mag: number;
  88721. };
  88722. /** @hidden */
  88723. _createTexture(): WebGLTexture;
  88724. /**
  88725. * Usually called from Texture.ts.
  88726. * Passed information to create a WebGLTexture
  88727. * @param urlArg defines a value which contains one of the following:
  88728. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  88729. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  88730. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  88731. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  88732. * @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)
  88733. * @param scene needed for loading to the correct scene
  88734. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  88735. * @param onLoad optional callback to be called upon successful completion
  88736. * @param onError optional callback to be called upon failure
  88737. * @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
  88738. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  88739. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  88740. * @param forcedExtension defines the extension to use to pick the right loader
  88741. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  88742. * @returns a InternalTexture for assignment back into BABYLON.Texture
  88743. */
  88744. 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;
  88745. private _rescaleTexture;
  88746. private _unpackFlipYCached;
  88747. /**
  88748. * In case you are sharing the context with other applications, it might
  88749. * be interested to not cache the unpack flip y state to ensure a consistent
  88750. * value would be set.
  88751. */
  88752. enableUnpackFlipYCached: boolean;
  88753. /** @hidden */
  88754. _unpackFlipY(value: boolean): void;
  88755. /** @hidden */
  88756. _getUnpackAlignement(): number;
  88757. /**
  88758. * Creates a dynamic texture
  88759. * @param width defines the width of the texture
  88760. * @param height defines the height of the texture
  88761. * @param generateMipMaps defines if the engine should generate the mip levels
  88762. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88763. * @returns the dynamic texture inside an InternalTexture
  88764. */
  88765. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88766. /**
  88767. * Update the sampling mode of a given texture
  88768. * @param samplingMode defines the required sampling mode
  88769. * @param texture defines the texture to update
  88770. */
  88771. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  88772. /**
  88773. * Update the content of a dynamic texture
  88774. * @param texture defines the texture to update
  88775. * @param canvas defines the canvas containing the source
  88776. * @param invertY defines if data must be stored with Y axis inverted
  88777. * @param premulAlpha defines if alpha is stored as premultiplied
  88778. * @param format defines the format of the data
  88779. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88780. */
  88781. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88782. /**
  88783. * Update a video texture
  88784. * @param texture defines the texture to update
  88785. * @param video defines the video element to use
  88786. * @param invertY defines if data must be stored with Y axis inverted
  88787. */
  88788. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  88789. /**
  88790. * Updates a depth texture Comparison Mode and Function.
  88791. * If the comparison Function is equal to 0, the mode will be set to none.
  88792. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  88793. * @param texture The texture to set the comparison function for
  88794. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  88795. */
  88796. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  88797. /** @hidden */
  88798. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  88799. width: number;
  88800. height: number;
  88801. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  88802. /**
  88803. * Creates a depth stencil texture.
  88804. * This is only available in WebGL 2 or with the depth texture extension available.
  88805. * @param size The size of face edge in the texture.
  88806. * @param options The options defining the texture.
  88807. * @returns The texture
  88808. */
  88809. createDepthStencilTexture(size: number | {
  88810. width: number;
  88811. height: number;
  88812. }, options: DepthTextureCreationOptions): InternalTexture;
  88813. /**
  88814. * Creates a depth stencil texture.
  88815. * This is only available in WebGL 2 or with the depth texture extension available.
  88816. * @param size The size of face edge in the texture.
  88817. * @param options The options defining the texture.
  88818. * @returns The texture
  88819. */
  88820. private _createDepthStencilTexture;
  88821. /**
  88822. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  88823. * @param renderTarget The render target to set the frame buffer for
  88824. */
  88825. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  88826. /**
  88827. * Creates a new render target texture
  88828. * @param size defines the size of the texture
  88829. * @param options defines the options used to create the texture
  88830. * @returns a new render target texture stored in an InternalTexture
  88831. */
  88832. createRenderTargetTexture(size: number | {
  88833. width: number;
  88834. height: number;
  88835. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88836. /** @hidden */
  88837. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  88838. /**
  88839. * Updates the sample count of a render target texture
  88840. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  88841. * @param texture defines the texture to update
  88842. * @param samples defines the sample count to set
  88843. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  88844. */
  88845. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  88846. /** @hidden */
  88847. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88848. /** @hidden */
  88849. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88850. /** @hidden */
  88851. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88852. /** @hidden */
  88853. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  88854. /**
  88855. * @hidden
  88856. */
  88857. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88858. private _prepareWebGLTextureContinuation;
  88859. private _prepareWebGLTexture;
  88860. /** @hidden */
  88861. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  88862. /** @hidden */
  88863. _releaseFramebufferObjects(texture: InternalTexture): void;
  88864. /** @hidden */
  88865. _releaseTexture(texture: InternalTexture): void;
  88866. private setProgram;
  88867. private _boundUniforms;
  88868. /**
  88869. * Binds an effect to the webGL context
  88870. * @param effect defines the effect to bind
  88871. */
  88872. bindSamplers(effect: Effect): void;
  88873. private _activateCurrentTexture;
  88874. /** @hidden */
  88875. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88876. /** @hidden */
  88877. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88878. /**
  88879. * Sets a texture to the webGL context from a postprocess
  88880. * @param channel defines the channel to use
  88881. * @param postProcess defines the source postprocess
  88882. */
  88883. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88884. /**
  88885. * Binds the output of the passed in post process to the texture channel specified
  88886. * @param channel The channel the texture should be bound to
  88887. * @param postProcess The post process which's output should be bound
  88888. */
  88889. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88890. /**
  88891. * Unbind all textures from the webGL context
  88892. */
  88893. unbindAllTextures(): void;
  88894. /**
  88895. * Sets a texture to the according uniform.
  88896. * @param channel The texture channel
  88897. * @param uniform The uniform to set
  88898. * @param texture The texture to apply
  88899. */
  88900. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88901. /**
  88902. * Sets a depth stencil texture from a render target to the according uniform.
  88903. * @param channel The texture channel
  88904. * @param uniform The uniform to set
  88905. * @param texture The render target texture containing the depth stencil texture to apply
  88906. */
  88907. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88908. private _bindSamplerUniformToChannel;
  88909. private _getTextureWrapMode;
  88910. private _setTexture;
  88911. /**
  88912. * Sets an array of texture to the webGL context
  88913. * @param channel defines the channel where the texture array must be set
  88914. * @param uniform defines the associated uniform location
  88915. * @param textures defines the array of textures to bind
  88916. */
  88917. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88918. /** @hidden */
  88919. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88920. private _setTextureParameterFloat;
  88921. private _setTextureParameterInteger;
  88922. /**
  88923. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88924. * @param x defines the x coordinate of the rectangle where pixels must be read
  88925. * @param y defines the y coordinate of the rectangle where pixels must be read
  88926. * @param width defines the width of the rectangle where pixels must be read
  88927. * @param height defines the height of the rectangle where pixels must be read
  88928. * @returns a Uint8Array containing RGBA colors
  88929. */
  88930. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88931. /**
  88932. * Add an externaly attached data from its key.
  88933. * This method call will fail and return false, if such key already exists.
  88934. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88935. * @param key the unique key that identifies the data
  88936. * @param data the data object to associate to the key for this Engine instance
  88937. * @return true if no such key were already present and the data was added successfully, false otherwise
  88938. */
  88939. addExternalData<T>(key: string, data: T): boolean;
  88940. /**
  88941. * Get an externaly attached data from its key
  88942. * @param key the unique key that identifies the data
  88943. * @return the associated data, if present (can be null), or undefined if not present
  88944. */
  88945. getExternalData<T>(key: string): T;
  88946. /**
  88947. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88948. * @param key the unique key that identifies the data
  88949. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88950. * @return the associated data, can be null if the factory returned null.
  88951. */
  88952. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88953. /**
  88954. * Remove an externaly attached data from the Engine instance
  88955. * @param key the unique key that identifies the data
  88956. * @return true if the data was successfully removed, false if it doesn't exist
  88957. */
  88958. removeExternalData(key: string): boolean;
  88959. /**
  88960. * Unbind all vertex attributes from the webGL context
  88961. */
  88962. unbindAllAttributes(): void;
  88963. /**
  88964. * 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
  88965. */
  88966. releaseEffects(): void;
  88967. /**
  88968. * Dispose and release all associated resources
  88969. */
  88970. dispose(): void;
  88971. /**
  88972. * Display the loading screen
  88973. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88974. */
  88975. displayLoadingUI(): void;
  88976. /**
  88977. * Hide the loading screen
  88978. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88979. */
  88980. hideLoadingUI(): void;
  88981. /**
  88982. * Gets the current loading screen object
  88983. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88984. */
  88985. /**
  88986. * Sets the current loading screen object
  88987. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88988. */
  88989. loadingScreen: ILoadingScreen;
  88990. /**
  88991. * Sets the current loading screen text
  88992. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88993. */
  88994. loadingUIText: string;
  88995. /**
  88996. * Sets the current loading screen background color
  88997. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88998. */
  88999. loadingUIBackgroundColor: string;
  89000. /**
  89001. * Attach a new callback raised when context lost event is fired
  89002. * @param callback defines the callback to call
  89003. */
  89004. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  89005. /**
  89006. * Attach a new callback raised when context restored event is fired
  89007. * @param callback defines the callback to call
  89008. */
  89009. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  89010. /**
  89011. * Gets the source code of the vertex shader associated with a specific webGL program
  89012. * @param program defines the program to use
  89013. * @returns a string containing the source code of the vertex shader associated with the program
  89014. */
  89015. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  89016. /**
  89017. * Gets the source code of the fragment shader associated with a specific webGL program
  89018. * @param program defines the program to use
  89019. * @returns a string containing the source code of the fragment shader associated with the program
  89020. */
  89021. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  89022. /**
  89023. * Get the current error code of the webGL context
  89024. * @returns the error code
  89025. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  89026. */
  89027. getError(): number;
  89028. /**
  89029. * Gets the current framerate
  89030. * @returns a number representing the framerate
  89031. */
  89032. getFps(): number;
  89033. /**
  89034. * Gets the time spent between current and previous frame
  89035. * @returns a number representing the delta time in ms
  89036. */
  89037. getDeltaTime(): number;
  89038. private _measureFps;
  89039. /** @hidden */
  89040. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  89041. private _canRenderToFloatFramebuffer;
  89042. private _canRenderToHalfFloatFramebuffer;
  89043. private _canRenderToFramebuffer;
  89044. /** @hidden */
  89045. _getWebGLTextureType(type: number): number;
  89046. /** @hidden */
  89047. _getInternalFormat(format: number): number;
  89048. /** @hidden */
  89049. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  89050. /** @hidden */
  89051. _getRGBAMultiSampleBufferFormat(type: number): number;
  89052. /** @hidden */
  89053. _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;
  89054. /** @hidden */
  89055. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  89056. /**
  89057. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  89058. * @returns true if the engine can be created
  89059. * @ignorenaming
  89060. */
  89061. static isSupported(): boolean;
  89062. }
  89063. }
  89064. declare module BABYLON {
  89065. /**
  89066. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  89067. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  89068. */
  89069. export class EffectFallbacks {
  89070. private _defines;
  89071. private _currentRank;
  89072. private _maxRank;
  89073. private _mesh;
  89074. /**
  89075. * Removes the fallback from the bound mesh.
  89076. */
  89077. unBindMesh(): void;
  89078. /**
  89079. * Adds a fallback on the specified property.
  89080. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89081. * @param define The name of the define in the shader
  89082. */
  89083. addFallback(rank: number, define: string): void;
  89084. /**
  89085. * Sets the mesh to use CPU skinning when needing to fallback.
  89086. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89087. * @param mesh The mesh to use the fallbacks.
  89088. */
  89089. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  89090. /**
  89091. * Checks to see if more fallbacks are still availible.
  89092. */
  89093. readonly isMoreFallbacks: boolean;
  89094. /**
  89095. * Removes the defines that shoould be removed when falling back.
  89096. * @param currentDefines defines the current define statements for the shader.
  89097. * @param effect defines the current effect we try to compile
  89098. * @returns The resulting defines with defines of the current rank removed.
  89099. */
  89100. reduce(currentDefines: string, effect: Effect): string;
  89101. }
  89102. /**
  89103. * Options to be used when creating an effect.
  89104. */
  89105. export class EffectCreationOptions {
  89106. /**
  89107. * Atrributes that will be used in the shader.
  89108. */
  89109. attributes: string[];
  89110. /**
  89111. * Uniform varible names that will be set in the shader.
  89112. */
  89113. uniformsNames: string[];
  89114. /**
  89115. * Uniform buffer varible names that will be set in the shader.
  89116. */
  89117. uniformBuffersNames: string[];
  89118. /**
  89119. * Sampler texture variable names that will be set in the shader.
  89120. */
  89121. samplers: string[];
  89122. /**
  89123. * Define statements that will be set in the shader.
  89124. */
  89125. defines: any;
  89126. /**
  89127. * Possible fallbacks for this effect to improve performance when needed.
  89128. */
  89129. fallbacks: Nullable<EffectFallbacks>;
  89130. /**
  89131. * Callback that will be called when the shader is compiled.
  89132. */
  89133. onCompiled: Nullable<(effect: Effect) => void>;
  89134. /**
  89135. * Callback that will be called if an error occurs during shader compilation.
  89136. */
  89137. onError: Nullable<(effect: Effect, errors: string) => void>;
  89138. /**
  89139. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  89140. */
  89141. indexParameters: any;
  89142. /**
  89143. * Max number of lights that can be used in the shader.
  89144. */
  89145. maxSimultaneousLights: number;
  89146. /**
  89147. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  89148. */
  89149. transformFeedbackVaryings: Nullable<string[]>;
  89150. }
  89151. /**
  89152. * Effect containing vertex and fragment shader that can be executed on an object.
  89153. */
  89154. export class Effect implements IDisposable {
  89155. /**
  89156. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  89157. */
  89158. static ShadersRepository: string;
  89159. /**
  89160. * Name of the effect.
  89161. */
  89162. name: any;
  89163. /**
  89164. * String container all the define statements that should be set on the shader.
  89165. */
  89166. defines: string;
  89167. /**
  89168. * Callback that will be called when the shader is compiled.
  89169. */
  89170. onCompiled: Nullable<(effect: Effect) => void>;
  89171. /**
  89172. * Callback that will be called if an error occurs during shader compilation.
  89173. */
  89174. onError: Nullable<(effect: Effect, errors: string) => void>;
  89175. /**
  89176. * Callback that will be called when effect is bound.
  89177. */
  89178. onBind: Nullable<(effect: Effect) => void>;
  89179. /**
  89180. * Unique ID of the effect.
  89181. */
  89182. uniqueId: number;
  89183. /**
  89184. * Observable that will be called when the shader is compiled.
  89185. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  89186. */
  89187. onCompileObservable: Observable<Effect>;
  89188. /**
  89189. * Observable that will be called if an error occurs during shader compilation.
  89190. */
  89191. onErrorObservable: Observable<Effect>;
  89192. /** @hidden */
  89193. _onBindObservable: Nullable<Observable<Effect>>;
  89194. /**
  89195. * Observable that will be called when effect is bound.
  89196. */
  89197. readonly onBindObservable: Observable<Effect>;
  89198. /** @hidden */
  89199. _bonesComputationForcedToCPU: boolean;
  89200. private static _uniqueIdSeed;
  89201. private _engine;
  89202. private _uniformBuffersNames;
  89203. private _uniformsNames;
  89204. private _samplerList;
  89205. private _samplers;
  89206. private _isReady;
  89207. private _compilationError;
  89208. private _attributesNames;
  89209. private _attributes;
  89210. private _uniforms;
  89211. /**
  89212. * Key for the effect.
  89213. * @hidden
  89214. */
  89215. _key: string;
  89216. private _indexParameters;
  89217. private _fallbacks;
  89218. private _vertexSourceCode;
  89219. private _fragmentSourceCode;
  89220. private _vertexSourceCodeOverride;
  89221. private _fragmentSourceCodeOverride;
  89222. private _transformFeedbackVaryings;
  89223. /**
  89224. * Compiled shader to webGL program.
  89225. * @hidden
  89226. */
  89227. _pipelineContext: Nullable<IPipelineContext>;
  89228. private _valueCache;
  89229. private static _baseCache;
  89230. /**
  89231. * Instantiates an effect.
  89232. * An effect can be used to create/manage/execute vertex and fragment shaders.
  89233. * @param baseName Name of the effect.
  89234. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  89235. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  89236. * @param samplers List of sampler variables that will be passed to the shader.
  89237. * @param engine Engine to be used to render the effect
  89238. * @param defines Define statements to be added to the shader.
  89239. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  89240. * @param onCompiled Callback that will be called when the shader is compiled.
  89241. * @param onError Callback that will be called if an error occurs during shader compilation.
  89242. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  89243. */
  89244. 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);
  89245. /**
  89246. * Unique key for this effect
  89247. */
  89248. readonly key: string;
  89249. /**
  89250. * If the effect has been compiled and prepared.
  89251. * @returns if the effect is compiled and prepared.
  89252. */
  89253. isReady(): boolean;
  89254. /**
  89255. * The engine the effect was initialized with.
  89256. * @returns the engine.
  89257. */
  89258. getEngine(): Engine;
  89259. /**
  89260. * The pipeline context for this effect
  89261. * @returns the associated pipeline context
  89262. */
  89263. getPipelineContext(): Nullable<IPipelineContext>;
  89264. /**
  89265. * The set of names of attribute variables for the shader.
  89266. * @returns An array of attribute names.
  89267. */
  89268. getAttributesNames(): string[];
  89269. /**
  89270. * Returns the attribute at the given index.
  89271. * @param index The index of the attribute.
  89272. * @returns The location of the attribute.
  89273. */
  89274. getAttributeLocation(index: number): number;
  89275. /**
  89276. * Returns the attribute based on the name of the variable.
  89277. * @param name of the attribute to look up.
  89278. * @returns the attribute location.
  89279. */
  89280. getAttributeLocationByName(name: string): number;
  89281. /**
  89282. * The number of attributes.
  89283. * @returns the numnber of attributes.
  89284. */
  89285. getAttributesCount(): number;
  89286. /**
  89287. * Gets the index of a uniform variable.
  89288. * @param uniformName of the uniform to look up.
  89289. * @returns the index.
  89290. */
  89291. getUniformIndex(uniformName: string): number;
  89292. /**
  89293. * Returns the attribute based on the name of the variable.
  89294. * @param uniformName of the uniform to look up.
  89295. * @returns the location of the uniform.
  89296. */
  89297. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  89298. /**
  89299. * Returns an array of sampler variable names
  89300. * @returns The array of sampler variable neames.
  89301. */
  89302. getSamplers(): string[];
  89303. /**
  89304. * The error from the last compilation.
  89305. * @returns the error string.
  89306. */
  89307. getCompilationError(): string;
  89308. /**
  89309. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  89310. * @param func The callback to be used.
  89311. */
  89312. executeWhenCompiled(func: (effect: Effect) => void): void;
  89313. private _checkIsReady;
  89314. /** @hidden */
  89315. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  89316. /** @hidden */
  89317. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  89318. /** @hidden */
  89319. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  89320. private _processShaderConversion;
  89321. private _processIncludes;
  89322. private _processPrecision;
  89323. /**
  89324. * Recompiles the webGL program
  89325. * @param vertexSourceCode The source code for the vertex shader.
  89326. * @param fragmentSourceCode The source code for the fragment shader.
  89327. * @param onCompiled Callback called when completed.
  89328. * @param onError Callback called on error.
  89329. * @hidden
  89330. */
  89331. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  89332. /**
  89333. * Prepares the effect
  89334. * @hidden
  89335. */
  89336. _prepareEffect(): void;
  89337. /**
  89338. * Checks if the effect is supported. (Must be called after compilation)
  89339. */
  89340. readonly isSupported: boolean;
  89341. /**
  89342. * Binds a texture to the engine to be used as output of the shader.
  89343. * @param channel Name of the output variable.
  89344. * @param texture Texture to bind.
  89345. * @hidden
  89346. */
  89347. _bindTexture(channel: string, texture: InternalTexture): void;
  89348. /**
  89349. * Sets a texture on the engine to be used in the shader.
  89350. * @param channel Name of the sampler variable.
  89351. * @param texture Texture to set.
  89352. */
  89353. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  89354. /**
  89355. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  89356. * @param channel Name of the sampler variable.
  89357. * @param texture Texture to set.
  89358. */
  89359. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  89360. /**
  89361. * Sets an array of textures on the engine to be used in the shader.
  89362. * @param channel Name of the variable.
  89363. * @param textures Textures to set.
  89364. */
  89365. setTextureArray(channel: string, textures: BaseTexture[]): void;
  89366. /**
  89367. * 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)
  89368. * @param channel Name of the sampler variable.
  89369. * @param postProcess Post process to get the input texture from.
  89370. */
  89371. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  89372. /**
  89373. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  89374. * 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)
  89375. * @param channel Name of the sampler variable.
  89376. * @param postProcess Post process to get the output texture from.
  89377. */
  89378. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  89379. /** @hidden */
  89380. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  89381. /** @hidden */
  89382. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  89383. /** @hidden */
  89384. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  89385. /** @hidden */
  89386. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  89387. /**
  89388. * Binds a buffer to a uniform.
  89389. * @param buffer Buffer to bind.
  89390. * @param name Name of the uniform variable to bind to.
  89391. */
  89392. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  89393. /**
  89394. * Binds block to a uniform.
  89395. * @param blockName Name of the block to bind.
  89396. * @param index Index to bind.
  89397. */
  89398. bindUniformBlock(blockName: string, index: number): void;
  89399. /**
  89400. * Sets an interger value on a uniform variable.
  89401. * @param uniformName Name of the variable.
  89402. * @param value Value to be set.
  89403. * @returns this effect.
  89404. */
  89405. setInt(uniformName: string, value: number): Effect;
  89406. /**
  89407. * Sets an int array on a uniform variable.
  89408. * @param uniformName Name of the variable.
  89409. * @param array array to be set.
  89410. * @returns this effect.
  89411. */
  89412. setIntArray(uniformName: string, array: Int32Array): Effect;
  89413. /**
  89414. * 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)
  89415. * @param uniformName Name of the variable.
  89416. * @param array array to be set.
  89417. * @returns this effect.
  89418. */
  89419. setIntArray2(uniformName: string, array: Int32Array): Effect;
  89420. /**
  89421. * 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)
  89422. * @param uniformName Name of the variable.
  89423. * @param array array to be set.
  89424. * @returns this effect.
  89425. */
  89426. setIntArray3(uniformName: string, array: Int32Array): Effect;
  89427. /**
  89428. * 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)
  89429. * @param uniformName Name of the variable.
  89430. * @param array array to be set.
  89431. * @returns this effect.
  89432. */
  89433. setIntArray4(uniformName: string, array: Int32Array): Effect;
  89434. /**
  89435. * Sets an float array on a uniform variable.
  89436. * @param uniformName Name of the variable.
  89437. * @param array array to be set.
  89438. * @returns this effect.
  89439. */
  89440. setFloatArray(uniformName: string, array: Float32Array): Effect;
  89441. /**
  89442. * 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)
  89443. * @param uniformName Name of the variable.
  89444. * @param array array to be set.
  89445. * @returns this effect.
  89446. */
  89447. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  89448. /**
  89449. * 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)
  89450. * @param uniformName Name of the variable.
  89451. * @param array array to be set.
  89452. * @returns this effect.
  89453. */
  89454. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  89455. /**
  89456. * 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)
  89457. * @param uniformName Name of the variable.
  89458. * @param array array to be set.
  89459. * @returns this effect.
  89460. */
  89461. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  89462. /**
  89463. * Sets an array on a uniform variable.
  89464. * @param uniformName Name of the variable.
  89465. * @param array array to be set.
  89466. * @returns this effect.
  89467. */
  89468. setArray(uniformName: string, array: number[]): Effect;
  89469. /**
  89470. * 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)
  89471. * @param uniformName Name of the variable.
  89472. * @param array array to be set.
  89473. * @returns this effect.
  89474. */
  89475. setArray2(uniformName: string, array: number[]): Effect;
  89476. /**
  89477. * 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)
  89478. * @param uniformName Name of the variable.
  89479. * @param array array to be set.
  89480. * @returns this effect.
  89481. */
  89482. setArray3(uniformName: string, array: number[]): Effect;
  89483. /**
  89484. * 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)
  89485. * @param uniformName Name of the variable.
  89486. * @param array array to be set.
  89487. * @returns this effect.
  89488. */
  89489. setArray4(uniformName: string, array: number[]): Effect;
  89490. /**
  89491. * Sets matrices on a uniform variable.
  89492. * @param uniformName Name of the variable.
  89493. * @param matrices matrices to be set.
  89494. * @returns this effect.
  89495. */
  89496. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  89497. /**
  89498. * Sets matrix on a uniform variable.
  89499. * @param uniformName Name of the variable.
  89500. * @param matrix matrix to be set.
  89501. * @returns this effect.
  89502. */
  89503. setMatrix(uniformName: string, matrix: Matrix): Effect;
  89504. /**
  89505. * 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)
  89506. * @param uniformName Name of the variable.
  89507. * @param matrix matrix to be set.
  89508. * @returns this effect.
  89509. */
  89510. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  89511. /**
  89512. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  89513. * @param uniformName Name of the variable.
  89514. * @param matrix matrix to be set.
  89515. * @returns this effect.
  89516. */
  89517. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  89518. /**
  89519. * Sets a float on a uniform variable.
  89520. * @param uniformName Name of the variable.
  89521. * @param value value to be set.
  89522. * @returns this effect.
  89523. */
  89524. setFloat(uniformName: string, value: number): Effect;
  89525. /**
  89526. * Sets a boolean on a uniform variable.
  89527. * @param uniformName Name of the variable.
  89528. * @param bool value to be set.
  89529. * @returns this effect.
  89530. */
  89531. setBool(uniformName: string, bool: boolean): Effect;
  89532. /**
  89533. * Sets a Vector2 on a uniform variable.
  89534. * @param uniformName Name of the variable.
  89535. * @param vector2 vector2 to be set.
  89536. * @returns this effect.
  89537. */
  89538. setVector2(uniformName: string, vector2: Vector2): Effect;
  89539. /**
  89540. * Sets a float2 on a uniform variable.
  89541. * @param uniformName Name of the variable.
  89542. * @param x First float in float2.
  89543. * @param y Second float in float2.
  89544. * @returns this effect.
  89545. */
  89546. setFloat2(uniformName: string, x: number, y: number): Effect;
  89547. /**
  89548. * Sets a Vector3 on a uniform variable.
  89549. * @param uniformName Name of the variable.
  89550. * @param vector3 Value to be set.
  89551. * @returns this effect.
  89552. */
  89553. setVector3(uniformName: string, vector3: Vector3): Effect;
  89554. /**
  89555. * Sets a float3 on a uniform variable.
  89556. * @param uniformName Name of the variable.
  89557. * @param x First float in float3.
  89558. * @param y Second float in float3.
  89559. * @param z Third float in float3.
  89560. * @returns this effect.
  89561. */
  89562. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  89563. /**
  89564. * Sets a Vector4 on a uniform variable.
  89565. * @param uniformName Name of the variable.
  89566. * @param vector4 Value to be set.
  89567. * @returns this effect.
  89568. */
  89569. setVector4(uniformName: string, vector4: Vector4): Effect;
  89570. /**
  89571. * Sets a float4 on a uniform variable.
  89572. * @param uniformName Name of the variable.
  89573. * @param x First float in float4.
  89574. * @param y Second float in float4.
  89575. * @param z Third float in float4.
  89576. * @param w Fourth float in float4.
  89577. * @returns this effect.
  89578. */
  89579. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  89580. /**
  89581. * Sets a Color3 on a uniform variable.
  89582. * @param uniformName Name of the variable.
  89583. * @param color3 Value to be set.
  89584. * @returns this effect.
  89585. */
  89586. setColor3(uniformName: string, color3: Color3): Effect;
  89587. /**
  89588. * Sets a Color4 on a uniform variable.
  89589. * @param uniformName Name of the variable.
  89590. * @param color3 Value to be set.
  89591. * @param alpha Alpha value to be set.
  89592. * @returns this effect.
  89593. */
  89594. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  89595. /**
  89596. * Sets a Color4 on a uniform variable
  89597. * @param uniformName defines the name of the variable
  89598. * @param color4 defines the value to be set
  89599. * @returns this effect.
  89600. */
  89601. setDirectColor4(uniformName: string, color4: Color4): Effect;
  89602. /** Release all associated resources */
  89603. dispose(): void;
  89604. /**
  89605. * This function will add a new shader to the shader store
  89606. * @param name the name of the shader
  89607. * @param pixelShader optional pixel shader content
  89608. * @param vertexShader optional vertex shader content
  89609. */
  89610. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  89611. /**
  89612. * Store of each shader (The can be looked up using effect.key)
  89613. */
  89614. static ShadersStore: {
  89615. [key: string]: string;
  89616. };
  89617. /**
  89618. * Store of each included file for a shader (The can be looked up using effect.key)
  89619. */
  89620. static IncludesShadersStore: {
  89621. [key: string]: string;
  89622. };
  89623. /**
  89624. * Resets the cache of effects.
  89625. */
  89626. static ResetCache(): void;
  89627. }
  89628. }
  89629. declare module BABYLON {
  89630. /**
  89631. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  89632. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  89633. * 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;
  89634. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  89635. */
  89636. export class ColorCurves {
  89637. private _dirty;
  89638. private _tempColor;
  89639. private _globalCurve;
  89640. private _highlightsCurve;
  89641. private _midtonesCurve;
  89642. private _shadowsCurve;
  89643. private _positiveCurve;
  89644. private _negativeCurve;
  89645. private _globalHue;
  89646. private _globalDensity;
  89647. private _globalSaturation;
  89648. private _globalExposure;
  89649. /**
  89650. * Gets the global Hue value.
  89651. * 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).
  89652. */
  89653. /**
  89654. * Sets the global Hue value.
  89655. * 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).
  89656. */
  89657. globalHue: number;
  89658. /**
  89659. * Gets the global Density value.
  89660. * 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.
  89661. * Values less than zero provide a filter of opposite hue.
  89662. */
  89663. /**
  89664. * Sets the global Density value.
  89665. * 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.
  89666. * Values less than zero provide a filter of opposite hue.
  89667. */
  89668. globalDensity: number;
  89669. /**
  89670. * Gets the global Saturation value.
  89671. * 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.
  89672. */
  89673. /**
  89674. * Sets the global Saturation value.
  89675. * 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.
  89676. */
  89677. globalSaturation: number;
  89678. /**
  89679. * Gets the global Exposure value.
  89680. * 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.
  89681. */
  89682. /**
  89683. * Sets the global Exposure value.
  89684. * 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.
  89685. */
  89686. globalExposure: number;
  89687. private _highlightsHue;
  89688. private _highlightsDensity;
  89689. private _highlightsSaturation;
  89690. private _highlightsExposure;
  89691. /**
  89692. * Gets the highlights Hue value.
  89693. * 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).
  89694. */
  89695. /**
  89696. * Sets the highlights Hue value.
  89697. * 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).
  89698. */
  89699. highlightsHue: number;
  89700. /**
  89701. * Gets the highlights Density value.
  89702. * 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.
  89703. * Values less than zero provide a filter of opposite hue.
  89704. */
  89705. /**
  89706. * Sets the highlights Density value.
  89707. * 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.
  89708. * Values less than zero provide a filter of opposite hue.
  89709. */
  89710. highlightsDensity: number;
  89711. /**
  89712. * Gets the highlights Saturation value.
  89713. * 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.
  89714. */
  89715. /**
  89716. * Sets the highlights Saturation value.
  89717. * 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.
  89718. */
  89719. highlightsSaturation: number;
  89720. /**
  89721. * Gets the highlights Exposure value.
  89722. * 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.
  89723. */
  89724. /**
  89725. * Sets the highlights Exposure value.
  89726. * 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.
  89727. */
  89728. highlightsExposure: number;
  89729. private _midtonesHue;
  89730. private _midtonesDensity;
  89731. private _midtonesSaturation;
  89732. private _midtonesExposure;
  89733. /**
  89734. * Gets the midtones Hue value.
  89735. * 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).
  89736. */
  89737. /**
  89738. * Sets the midtones Hue value.
  89739. * 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).
  89740. */
  89741. midtonesHue: number;
  89742. /**
  89743. * Gets the midtones Density value.
  89744. * 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.
  89745. * Values less than zero provide a filter of opposite hue.
  89746. */
  89747. /**
  89748. * Sets the midtones Density value.
  89749. * 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.
  89750. * Values less than zero provide a filter of opposite hue.
  89751. */
  89752. midtonesDensity: number;
  89753. /**
  89754. * Gets the midtones Saturation value.
  89755. * 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.
  89756. */
  89757. /**
  89758. * Sets the midtones Saturation value.
  89759. * 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.
  89760. */
  89761. midtonesSaturation: number;
  89762. /**
  89763. * Gets the midtones Exposure value.
  89764. * 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.
  89765. */
  89766. /**
  89767. * Sets the midtones Exposure value.
  89768. * 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.
  89769. */
  89770. midtonesExposure: number;
  89771. private _shadowsHue;
  89772. private _shadowsDensity;
  89773. private _shadowsSaturation;
  89774. private _shadowsExposure;
  89775. /**
  89776. * Gets the shadows Hue value.
  89777. * 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).
  89778. */
  89779. /**
  89780. * Sets the shadows Hue value.
  89781. * 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).
  89782. */
  89783. shadowsHue: number;
  89784. /**
  89785. * Gets the shadows Density value.
  89786. * 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.
  89787. * Values less than zero provide a filter of opposite hue.
  89788. */
  89789. /**
  89790. * Sets the shadows Density value.
  89791. * 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.
  89792. * Values less than zero provide a filter of opposite hue.
  89793. */
  89794. shadowsDensity: number;
  89795. /**
  89796. * Gets the shadows Saturation value.
  89797. * 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.
  89798. */
  89799. /**
  89800. * Sets the shadows Saturation value.
  89801. * 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.
  89802. */
  89803. shadowsSaturation: number;
  89804. /**
  89805. * Gets the shadows Exposure value.
  89806. * 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.
  89807. */
  89808. /**
  89809. * Sets the shadows Exposure value.
  89810. * 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.
  89811. */
  89812. shadowsExposure: number;
  89813. /**
  89814. * Returns the class name
  89815. * @returns The class name
  89816. */
  89817. getClassName(): string;
  89818. /**
  89819. * Binds the color curves to the shader.
  89820. * @param colorCurves The color curve to bind
  89821. * @param effect The effect to bind to
  89822. * @param positiveUniform The positive uniform shader parameter
  89823. * @param neutralUniform The neutral uniform shader parameter
  89824. * @param negativeUniform The negative uniform shader parameter
  89825. */
  89826. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89827. /**
  89828. * Prepare the list of uniforms associated with the ColorCurves effects.
  89829. * @param uniformsList The list of uniforms used in the effect
  89830. */
  89831. static PrepareUniforms(uniformsList: string[]): void;
  89832. /**
  89833. * Returns color grading data based on a hue, density, saturation and exposure value.
  89834. * @param filterHue The hue of the color filter.
  89835. * @param filterDensity The density of the color filter.
  89836. * @param saturation The saturation.
  89837. * @param exposure The exposure.
  89838. * @param result The result data container.
  89839. */
  89840. private getColorGradingDataToRef;
  89841. /**
  89842. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89843. * @param value The input slider value in range [-100,100].
  89844. * @returns Adjusted value.
  89845. */
  89846. private static applyColorGradingSliderNonlinear;
  89847. /**
  89848. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89849. * @param hue The hue (H) input.
  89850. * @param saturation The saturation (S) input.
  89851. * @param brightness The brightness (B) input.
  89852. * @result An RGBA color represented as Vector4.
  89853. */
  89854. private static fromHSBToRef;
  89855. /**
  89856. * Returns a value clamped between min and max
  89857. * @param value The value to clamp
  89858. * @param min The minimum of value
  89859. * @param max The maximum of value
  89860. * @returns The clamped value.
  89861. */
  89862. private static clamp;
  89863. /**
  89864. * Clones the current color curve instance.
  89865. * @return The cloned curves
  89866. */
  89867. clone(): ColorCurves;
  89868. /**
  89869. * Serializes the current color curve instance to a json representation.
  89870. * @return a JSON representation
  89871. */
  89872. serialize(): any;
  89873. /**
  89874. * Parses the color curve from a json representation.
  89875. * @param source the JSON source to parse
  89876. * @return The parsed curves
  89877. */
  89878. static Parse(source: any): ColorCurves;
  89879. }
  89880. }
  89881. declare module BABYLON {
  89882. /**
  89883. * Interface to follow in your material defines to integrate easily the
  89884. * Image proccessing functions.
  89885. * @hidden
  89886. */
  89887. export interface IImageProcessingConfigurationDefines {
  89888. IMAGEPROCESSING: boolean;
  89889. VIGNETTE: boolean;
  89890. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89891. VIGNETTEBLENDMODEOPAQUE: boolean;
  89892. TONEMAPPING: boolean;
  89893. TONEMAPPING_ACES: boolean;
  89894. CONTRAST: boolean;
  89895. EXPOSURE: boolean;
  89896. COLORCURVES: boolean;
  89897. COLORGRADING: boolean;
  89898. COLORGRADING3D: boolean;
  89899. SAMPLER3DGREENDEPTH: boolean;
  89900. SAMPLER3DBGRMAP: boolean;
  89901. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89902. }
  89903. /**
  89904. * @hidden
  89905. */
  89906. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89907. IMAGEPROCESSING: boolean;
  89908. VIGNETTE: boolean;
  89909. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89910. VIGNETTEBLENDMODEOPAQUE: boolean;
  89911. TONEMAPPING: boolean;
  89912. TONEMAPPING_ACES: boolean;
  89913. CONTRAST: boolean;
  89914. COLORCURVES: boolean;
  89915. COLORGRADING: boolean;
  89916. COLORGRADING3D: boolean;
  89917. SAMPLER3DGREENDEPTH: boolean;
  89918. SAMPLER3DBGRMAP: boolean;
  89919. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89920. EXPOSURE: boolean;
  89921. constructor();
  89922. }
  89923. /**
  89924. * This groups together the common properties used for image processing either in direct forward pass
  89925. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89926. * or not.
  89927. */
  89928. export class ImageProcessingConfiguration {
  89929. /**
  89930. * Default tone mapping applied in BabylonJS.
  89931. */
  89932. static readonly TONEMAPPING_STANDARD: number;
  89933. /**
  89934. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89935. * to other engines rendering to increase portability.
  89936. */
  89937. static readonly TONEMAPPING_ACES: number;
  89938. /**
  89939. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89940. */
  89941. colorCurves: Nullable<ColorCurves>;
  89942. private _colorCurvesEnabled;
  89943. /**
  89944. * Gets wether the color curves effect is enabled.
  89945. */
  89946. /**
  89947. * Sets wether the color curves effect is enabled.
  89948. */
  89949. colorCurvesEnabled: boolean;
  89950. private _colorGradingTexture;
  89951. /**
  89952. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89953. */
  89954. /**
  89955. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89956. */
  89957. colorGradingTexture: Nullable<BaseTexture>;
  89958. private _colorGradingEnabled;
  89959. /**
  89960. * Gets wether the color grading effect is enabled.
  89961. */
  89962. /**
  89963. * Sets wether the color grading effect is enabled.
  89964. */
  89965. colorGradingEnabled: boolean;
  89966. private _colorGradingWithGreenDepth;
  89967. /**
  89968. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89969. */
  89970. /**
  89971. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89972. */
  89973. colorGradingWithGreenDepth: boolean;
  89974. private _colorGradingBGR;
  89975. /**
  89976. * Gets wether the color grading texture contains BGR values.
  89977. */
  89978. /**
  89979. * Sets wether the color grading texture contains BGR values.
  89980. */
  89981. colorGradingBGR: boolean;
  89982. /** @hidden */
  89983. _exposure: number;
  89984. /**
  89985. * Gets the Exposure used in the effect.
  89986. */
  89987. /**
  89988. * Sets the Exposure used in the effect.
  89989. */
  89990. exposure: number;
  89991. private _toneMappingEnabled;
  89992. /**
  89993. * Gets wether the tone mapping effect is enabled.
  89994. */
  89995. /**
  89996. * Sets wether the tone mapping effect is enabled.
  89997. */
  89998. toneMappingEnabled: boolean;
  89999. private _toneMappingType;
  90000. /**
  90001. * Gets the type of tone mapping effect.
  90002. */
  90003. /**
  90004. * Sets the type of tone mapping effect used in BabylonJS.
  90005. */
  90006. toneMappingType: number;
  90007. protected _contrast: number;
  90008. /**
  90009. * Gets the contrast used in the effect.
  90010. */
  90011. /**
  90012. * Sets the contrast used in the effect.
  90013. */
  90014. contrast: number;
  90015. /**
  90016. * Vignette stretch size.
  90017. */
  90018. vignetteStretch: number;
  90019. /**
  90020. * Vignette centre X Offset.
  90021. */
  90022. vignetteCentreX: number;
  90023. /**
  90024. * Vignette centre Y Offset.
  90025. */
  90026. vignetteCentreY: number;
  90027. /**
  90028. * Vignette weight or intensity of the vignette effect.
  90029. */
  90030. vignetteWeight: number;
  90031. /**
  90032. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  90033. * if vignetteEnabled is set to true.
  90034. */
  90035. vignetteColor: Color4;
  90036. /**
  90037. * Camera field of view used by the Vignette effect.
  90038. */
  90039. vignetteCameraFov: number;
  90040. private _vignetteBlendMode;
  90041. /**
  90042. * Gets the vignette blend mode allowing different kind of effect.
  90043. */
  90044. /**
  90045. * Sets the vignette blend mode allowing different kind of effect.
  90046. */
  90047. vignetteBlendMode: number;
  90048. private _vignetteEnabled;
  90049. /**
  90050. * Gets wether the vignette effect is enabled.
  90051. */
  90052. /**
  90053. * Sets wether the vignette effect is enabled.
  90054. */
  90055. vignetteEnabled: boolean;
  90056. private _applyByPostProcess;
  90057. /**
  90058. * Gets wether the image processing is applied through a post process or not.
  90059. */
  90060. /**
  90061. * Sets wether the image processing is applied through a post process or not.
  90062. */
  90063. applyByPostProcess: boolean;
  90064. private _isEnabled;
  90065. /**
  90066. * Gets wether the image processing is enabled or not.
  90067. */
  90068. /**
  90069. * Sets wether the image processing is enabled or not.
  90070. */
  90071. isEnabled: boolean;
  90072. /**
  90073. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  90074. */
  90075. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  90076. /**
  90077. * Method called each time the image processing information changes requires to recompile the effect.
  90078. */
  90079. protected _updateParameters(): void;
  90080. /**
  90081. * Gets the current class name.
  90082. * @return "ImageProcessingConfiguration"
  90083. */
  90084. getClassName(): string;
  90085. /**
  90086. * Prepare the list of uniforms associated with the Image Processing effects.
  90087. * @param uniforms The list of uniforms used in the effect
  90088. * @param defines the list of defines currently in use
  90089. */
  90090. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  90091. /**
  90092. * Prepare the list of samplers associated with the Image Processing effects.
  90093. * @param samplersList The list of uniforms used in the effect
  90094. * @param defines the list of defines currently in use
  90095. */
  90096. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  90097. /**
  90098. * Prepare the list of defines associated to the shader.
  90099. * @param defines the list of defines to complete
  90100. * @param forPostProcess Define if we are currently in post process mode or not
  90101. */
  90102. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  90103. /**
  90104. * Returns true if all the image processing information are ready.
  90105. * @returns True if ready, otherwise, false
  90106. */
  90107. isReady(): boolean;
  90108. /**
  90109. * Binds the image processing to the shader.
  90110. * @param effect The effect to bind to
  90111. * @param aspectRatio Define the current aspect ratio of the effect
  90112. */
  90113. bind(effect: Effect, aspectRatio?: number): void;
  90114. /**
  90115. * Clones the current image processing instance.
  90116. * @return The cloned image processing
  90117. */
  90118. clone(): ImageProcessingConfiguration;
  90119. /**
  90120. * Serializes the current image processing instance to a json representation.
  90121. * @return a JSON representation
  90122. */
  90123. serialize(): any;
  90124. /**
  90125. * Parses the image processing from a json representation.
  90126. * @param source the JSON source to parse
  90127. * @return The parsed image processing
  90128. */
  90129. static Parse(source: any): ImageProcessingConfiguration;
  90130. private static _VIGNETTEMODE_MULTIPLY;
  90131. private static _VIGNETTEMODE_OPAQUE;
  90132. /**
  90133. * Used to apply the vignette as a mix with the pixel color.
  90134. */
  90135. static readonly VIGNETTEMODE_MULTIPLY: number;
  90136. /**
  90137. * Used to apply the vignette as a replacement of the pixel color.
  90138. */
  90139. static readonly VIGNETTEMODE_OPAQUE: number;
  90140. }
  90141. }
  90142. declare module BABYLON {
  90143. /**
  90144. * This represents all the required information to add a fresnel effect on a material:
  90145. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  90146. */
  90147. export class FresnelParameters {
  90148. private _isEnabled;
  90149. /**
  90150. * Define if the fresnel effect is enable or not.
  90151. */
  90152. isEnabled: boolean;
  90153. /**
  90154. * Define the color used on edges (grazing angle)
  90155. */
  90156. leftColor: Color3;
  90157. /**
  90158. * Define the color used on center
  90159. */
  90160. rightColor: Color3;
  90161. /**
  90162. * Define bias applied to computed fresnel term
  90163. */
  90164. bias: number;
  90165. /**
  90166. * Defined the power exponent applied to fresnel term
  90167. */
  90168. power: number;
  90169. /**
  90170. * Clones the current fresnel and its valuues
  90171. * @returns a clone fresnel configuration
  90172. */
  90173. clone(): FresnelParameters;
  90174. /**
  90175. * Serializes the current fresnel parameters to a JSON representation.
  90176. * @return the JSON serialization
  90177. */
  90178. serialize(): any;
  90179. /**
  90180. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  90181. * @param parsedFresnelParameters Define the JSON representation
  90182. * @returns the parsed parameters
  90183. */
  90184. static Parse(parsedFresnelParameters: any): FresnelParameters;
  90185. }
  90186. }
  90187. declare module BABYLON {
  90188. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  90189. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90190. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90191. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90192. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90193. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90194. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90195. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90196. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90197. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90198. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90199. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90200. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90201. /**
  90202. * Decorator used to define property that can be serialized as reference to a camera
  90203. * @param sourceName defines the name of the property to decorate
  90204. */
  90205. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90206. /**
  90207. * Class used to help serialization objects
  90208. */
  90209. export class SerializationHelper {
  90210. /** hidden */
  90211. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  90212. /** hidden */
  90213. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  90214. /** hidden */
  90215. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  90216. /** hidden */
  90217. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  90218. /**
  90219. * Appends the serialized animations from the source animations
  90220. * @param source Source containing the animations
  90221. * @param destination Target to store the animations
  90222. */
  90223. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  90224. /**
  90225. * Static function used to serialized a specific entity
  90226. * @param entity defines the entity to serialize
  90227. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  90228. * @returns a JSON compatible object representing the serialization of the entity
  90229. */
  90230. static Serialize<T>(entity: T, serializationObject?: any): any;
  90231. /**
  90232. * Creates a new entity from a serialization data object
  90233. * @param creationFunction defines a function used to instanciated the new entity
  90234. * @param source defines the source serialization data
  90235. * @param scene defines the hosting scene
  90236. * @param rootUrl defines the root url for resources
  90237. * @returns a new entity
  90238. */
  90239. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  90240. /**
  90241. * Clones an object
  90242. * @param creationFunction defines the function used to instanciate the new object
  90243. * @param source defines the source object
  90244. * @returns the cloned object
  90245. */
  90246. static Clone<T>(creationFunction: () => T, source: T): T;
  90247. /**
  90248. * Instanciates a new object based on a source one (some data will be shared between both object)
  90249. * @param creationFunction defines the function used to instanciate the new object
  90250. * @param source defines the source object
  90251. * @returns the new object
  90252. */
  90253. static Instanciate<T>(creationFunction: () => T, source: T): T;
  90254. }
  90255. }
  90256. declare module BABYLON {
  90257. /**
  90258. * This is the base class of all the camera used in the application.
  90259. * @see http://doc.babylonjs.com/features/cameras
  90260. */
  90261. export class Camera extends Node {
  90262. /** @hidden */
  90263. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90264. /**
  90265. * This is the default projection mode used by the cameras.
  90266. * It helps recreating a feeling of perspective and better appreciate depth.
  90267. * This is the best way to simulate real life cameras.
  90268. */
  90269. static readonly PERSPECTIVE_CAMERA: number;
  90270. /**
  90271. * This helps creating camera with an orthographic mode.
  90272. * 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.
  90273. */
  90274. static readonly ORTHOGRAPHIC_CAMERA: number;
  90275. /**
  90276. * This is the default FOV mode for perspective cameras.
  90277. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90278. */
  90279. static readonly FOVMODE_VERTICAL_FIXED: number;
  90280. /**
  90281. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90282. */
  90283. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90284. /**
  90285. * This specifies ther is no need for a camera rig.
  90286. * Basically only one eye is rendered corresponding to the camera.
  90287. */
  90288. static readonly RIG_MODE_NONE: number;
  90289. /**
  90290. * Simulates a camera Rig with one blue eye and one red eye.
  90291. * This can be use with 3d blue and red glasses.
  90292. */
  90293. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90294. /**
  90295. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90296. */
  90297. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90298. /**
  90299. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90300. */
  90301. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90302. /**
  90303. * Defines that both eyes of the camera will be rendered over under each other.
  90304. */
  90305. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90306. /**
  90307. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90308. */
  90309. static readonly RIG_MODE_VR: number;
  90310. /**
  90311. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90312. */
  90313. static readonly RIG_MODE_WEBVR: number;
  90314. /**
  90315. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90316. */
  90317. static readonly RIG_MODE_CUSTOM: number;
  90318. /**
  90319. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90320. */
  90321. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90322. /**
  90323. * Define the input manager associated with the camera.
  90324. */
  90325. inputs: CameraInputsManager<Camera>;
  90326. /** @hidden */
  90327. _position: Vector3;
  90328. /**
  90329. * Define the current local position of the camera in the scene
  90330. */
  90331. position: Vector3;
  90332. /**
  90333. * The vector the camera should consider as up.
  90334. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90335. */
  90336. upVector: Vector3;
  90337. /**
  90338. * Define the current limit on the left side for an orthographic camera
  90339. * In scene unit
  90340. */
  90341. orthoLeft: Nullable<number>;
  90342. /**
  90343. * Define the current limit on the right side for an orthographic camera
  90344. * In scene unit
  90345. */
  90346. orthoRight: Nullable<number>;
  90347. /**
  90348. * Define the current limit on the bottom side for an orthographic camera
  90349. * In scene unit
  90350. */
  90351. orthoBottom: Nullable<number>;
  90352. /**
  90353. * Define the current limit on the top side for an orthographic camera
  90354. * In scene unit
  90355. */
  90356. orthoTop: Nullable<number>;
  90357. /**
  90358. * Field Of View is set in Radians. (default is 0.8)
  90359. */
  90360. fov: number;
  90361. /**
  90362. * Define the minimum distance the camera can see from.
  90363. * This is important to note that the depth buffer are not infinite and the closer it starts
  90364. * the more your scene might encounter depth fighting issue.
  90365. */
  90366. minZ: number;
  90367. /**
  90368. * Define the maximum distance the camera can see to.
  90369. * This is important to note that the depth buffer are not infinite and the further it end
  90370. * the more your scene might encounter depth fighting issue.
  90371. */
  90372. maxZ: number;
  90373. /**
  90374. * Define the default inertia of the camera.
  90375. * This helps giving a smooth feeling to the camera movement.
  90376. */
  90377. inertia: number;
  90378. /**
  90379. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  90380. */
  90381. mode: number;
  90382. /**
  90383. * Define wether the camera is intermediate.
  90384. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90385. */
  90386. isIntermediate: boolean;
  90387. /**
  90388. * Define the viewport of the camera.
  90389. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90390. */
  90391. viewport: Viewport;
  90392. /**
  90393. * Restricts the camera to viewing objects with the same layerMask.
  90394. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90395. */
  90396. layerMask: number;
  90397. /**
  90398. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90399. */
  90400. fovMode: number;
  90401. /**
  90402. * Rig mode of the camera.
  90403. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90404. * This is normally controlled byt the camera themselves as internal use.
  90405. */
  90406. cameraRigMode: number;
  90407. /**
  90408. * Defines the distance between both "eyes" in case of a RIG
  90409. */
  90410. interaxialDistance: number;
  90411. /**
  90412. * Defines if stereoscopic rendering is done side by side or over under.
  90413. */
  90414. isStereoscopicSideBySide: boolean;
  90415. /**
  90416. * 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
  90417. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90418. * else in the scene.
  90419. */
  90420. customRenderTargets: RenderTargetTexture[];
  90421. /**
  90422. * When set, the camera will render to this render target instead of the default canvas
  90423. */
  90424. outputRenderTarget: Nullable<RenderTargetTexture>;
  90425. /**
  90426. * Observable triggered when the camera view matrix has changed.
  90427. */
  90428. onViewMatrixChangedObservable: Observable<Camera>;
  90429. /**
  90430. * Observable triggered when the camera Projection matrix has changed.
  90431. */
  90432. onProjectionMatrixChangedObservable: Observable<Camera>;
  90433. /**
  90434. * Observable triggered when the inputs have been processed.
  90435. */
  90436. onAfterCheckInputsObservable: Observable<Camera>;
  90437. /**
  90438. * Observable triggered when reset has been called and applied to the camera.
  90439. */
  90440. onRestoreStateObservable: Observable<Camera>;
  90441. /** @hidden */
  90442. _cameraRigParams: any;
  90443. /** @hidden */
  90444. _rigCameras: Camera[];
  90445. /** @hidden */
  90446. _rigPostProcess: Nullable<PostProcess>;
  90447. protected _webvrViewMatrix: Matrix;
  90448. /** @hidden */
  90449. _skipRendering: boolean;
  90450. /** @hidden */
  90451. _projectionMatrix: Matrix;
  90452. /** @hidden */
  90453. _postProcesses: Nullable<PostProcess>[];
  90454. /** @hidden */
  90455. _activeMeshes: SmartArray<AbstractMesh>;
  90456. protected _globalPosition: Vector3;
  90457. /** hidden */
  90458. _computedViewMatrix: Matrix;
  90459. private _doNotComputeProjectionMatrix;
  90460. private _transformMatrix;
  90461. private _frustumPlanes;
  90462. private _refreshFrustumPlanes;
  90463. private _storedFov;
  90464. private _stateStored;
  90465. /**
  90466. * Instantiates a new camera object.
  90467. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90468. * @see http://doc.babylonjs.com/features/cameras
  90469. * @param name Defines the name of the camera in the scene
  90470. * @param position Defines the position of the camera
  90471. * @param scene Defines the scene the camera belongs too
  90472. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90473. */
  90474. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90475. /**
  90476. * Store current camera state (fov, position, etc..)
  90477. * @returns the camera
  90478. */
  90479. storeState(): Camera;
  90480. /**
  90481. * Restores the camera state values if it has been stored. You must call storeState() first
  90482. */
  90483. protected _restoreStateValues(): boolean;
  90484. /**
  90485. * Restored camera state. You must call storeState() first.
  90486. * @returns true if restored and false otherwise
  90487. */
  90488. restoreState(): boolean;
  90489. /**
  90490. * Gets the class name of the camera.
  90491. * @returns the class name
  90492. */
  90493. getClassName(): string;
  90494. /** @hidden */
  90495. readonly _isCamera: boolean;
  90496. /**
  90497. * Gets a string representation of the camera useful for debug purpose.
  90498. * @param fullDetails Defines that a more verboe level of logging is required
  90499. * @returns the string representation
  90500. */
  90501. toString(fullDetails?: boolean): string;
  90502. /**
  90503. * Gets the current world space position of the camera.
  90504. */
  90505. readonly globalPosition: Vector3;
  90506. /**
  90507. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90508. * @returns the active meshe list
  90509. */
  90510. getActiveMeshes(): SmartArray<AbstractMesh>;
  90511. /**
  90512. * Check wether a mesh is part of the current active mesh list of the camera
  90513. * @param mesh Defines the mesh to check
  90514. * @returns true if active, false otherwise
  90515. */
  90516. isActiveMesh(mesh: Mesh): boolean;
  90517. /**
  90518. * Is this camera ready to be used/rendered
  90519. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90520. * @return true if the camera is ready
  90521. */
  90522. isReady(completeCheck?: boolean): boolean;
  90523. /** @hidden */
  90524. _initCache(): void;
  90525. /** @hidden */
  90526. _updateCache(ignoreParentClass?: boolean): void;
  90527. /** @hidden */
  90528. _isSynchronized(): boolean;
  90529. /** @hidden */
  90530. _isSynchronizedViewMatrix(): boolean;
  90531. /** @hidden */
  90532. _isSynchronizedProjectionMatrix(): boolean;
  90533. /**
  90534. * Attach the input controls to a specific dom element to get the input from.
  90535. * @param element Defines the element the controls should be listened from
  90536. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90537. */
  90538. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90539. /**
  90540. * Detach the current controls from the specified dom element.
  90541. * @param element Defines the element to stop listening the inputs from
  90542. */
  90543. detachControl(element: HTMLElement): void;
  90544. /**
  90545. * Update the camera state according to the different inputs gathered during the frame.
  90546. */
  90547. update(): void;
  90548. /** @hidden */
  90549. _checkInputs(): void;
  90550. /** @hidden */
  90551. readonly rigCameras: Camera[];
  90552. /**
  90553. * Gets the post process used by the rig cameras
  90554. */
  90555. readonly rigPostProcess: Nullable<PostProcess>;
  90556. /**
  90557. * Internal, gets the first post proces.
  90558. * @returns the first post process to be run on this camera.
  90559. */
  90560. _getFirstPostProcess(): Nullable<PostProcess>;
  90561. private _cascadePostProcessesToRigCams;
  90562. /**
  90563. * Attach a post process to the camera.
  90564. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90565. * @param postProcess The post process to attach to the camera
  90566. * @param insertAt The position of the post process in case several of them are in use in the scene
  90567. * @returns the position the post process has been inserted at
  90568. */
  90569. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90570. /**
  90571. * Detach a post process to the camera.
  90572. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90573. * @param postProcess The post process to detach from the camera
  90574. */
  90575. detachPostProcess(postProcess: PostProcess): void;
  90576. /**
  90577. * Gets the current world matrix of the camera
  90578. */
  90579. getWorldMatrix(): Matrix;
  90580. /** @hidden */
  90581. _getViewMatrix(): Matrix;
  90582. /**
  90583. * Gets the current view matrix of the camera.
  90584. * @param force forces the camera to recompute the matrix without looking at the cached state
  90585. * @returns the view matrix
  90586. */
  90587. getViewMatrix(force?: boolean): Matrix;
  90588. /**
  90589. * Freeze the projection matrix.
  90590. * It will prevent the cache check of the camera projection compute and can speed up perf
  90591. * if no parameter of the camera are meant to change
  90592. * @param projection Defines manually a projection if necessary
  90593. */
  90594. freezeProjectionMatrix(projection?: Matrix): void;
  90595. /**
  90596. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90597. */
  90598. unfreezeProjectionMatrix(): void;
  90599. /**
  90600. * Gets the current projection matrix of the camera.
  90601. * @param force forces the camera to recompute the matrix without looking at the cached state
  90602. * @returns the projection matrix
  90603. */
  90604. getProjectionMatrix(force?: boolean): Matrix;
  90605. /**
  90606. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90607. * @returns a Matrix
  90608. */
  90609. getTransformationMatrix(): Matrix;
  90610. private _updateFrustumPlanes;
  90611. /**
  90612. * Checks if a cullable object (mesh...) is in the camera frustum
  90613. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90614. * @param target The object to check
  90615. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90616. * @returns true if the object is in frustum otherwise false
  90617. */
  90618. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90619. /**
  90620. * Checks if a cullable object (mesh...) is in the camera frustum
  90621. * Unlike isInFrustum this cheks the full bounding box
  90622. * @param target The object to check
  90623. * @returns true if the object is in frustum otherwise false
  90624. */
  90625. isCompletelyInFrustum(target: ICullable): boolean;
  90626. /**
  90627. * Gets a ray in the forward direction from the camera.
  90628. * @param length Defines the length of the ray to create
  90629. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90630. * @param origin Defines the start point of the ray which defaults to the camera position
  90631. * @returns the forward ray
  90632. */
  90633. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90634. /**
  90635. * Releases resources associated with this node.
  90636. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90637. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90638. */
  90639. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90640. /** @hidden */
  90641. _isLeftCamera: boolean;
  90642. /**
  90643. * Gets the left camera of a rig setup in case of Rigged Camera
  90644. */
  90645. readonly isLeftCamera: boolean;
  90646. /** @hidden */
  90647. _isRightCamera: boolean;
  90648. /**
  90649. * Gets the right camera of a rig setup in case of Rigged Camera
  90650. */
  90651. readonly isRightCamera: boolean;
  90652. /**
  90653. * Gets the left camera of a rig setup in case of Rigged Camera
  90654. */
  90655. readonly leftCamera: Nullable<FreeCamera>;
  90656. /**
  90657. * Gets the right camera of a rig setup in case of Rigged Camera
  90658. */
  90659. readonly rightCamera: Nullable<FreeCamera>;
  90660. /**
  90661. * Gets the left camera target of a rig setup in case of Rigged Camera
  90662. * @returns the target position
  90663. */
  90664. getLeftTarget(): Nullable<Vector3>;
  90665. /**
  90666. * Gets the right camera target of a rig setup in case of Rigged Camera
  90667. * @returns the target position
  90668. */
  90669. getRightTarget(): Nullable<Vector3>;
  90670. /**
  90671. * @hidden
  90672. */
  90673. setCameraRigMode(mode: number, rigParams: any): void;
  90674. /** @hidden */
  90675. static _setStereoscopicRigMode(camera: Camera): void;
  90676. /** @hidden */
  90677. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90678. /** @hidden */
  90679. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90680. /** @hidden */
  90681. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90682. /** @hidden */
  90683. _getVRProjectionMatrix(): Matrix;
  90684. protected _updateCameraRotationMatrix(): void;
  90685. protected _updateWebVRCameraRotationMatrix(): void;
  90686. /**
  90687. * This function MUST be overwritten by the different WebVR cameras available.
  90688. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90689. * @hidden
  90690. */
  90691. _getWebVRProjectionMatrix(): Matrix;
  90692. /**
  90693. * This function MUST be overwritten by the different WebVR cameras available.
  90694. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90695. * @hidden
  90696. */
  90697. _getWebVRViewMatrix(): Matrix;
  90698. /** @hidden */
  90699. setCameraRigParameter(name: string, value: any): void;
  90700. /**
  90701. * needs to be overridden by children so sub has required properties to be copied
  90702. * @hidden
  90703. */
  90704. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90705. /**
  90706. * May need to be overridden by children
  90707. * @hidden
  90708. */
  90709. _updateRigCameras(): void;
  90710. /** @hidden */
  90711. _setupInputs(): void;
  90712. /**
  90713. * Serialiaze the camera setup to a json represention
  90714. * @returns the JSON representation
  90715. */
  90716. serialize(): any;
  90717. /**
  90718. * Clones the current camera.
  90719. * @param name The cloned camera name
  90720. * @returns the cloned camera
  90721. */
  90722. clone(name: string): Camera;
  90723. /**
  90724. * Gets the direction of the camera relative to a given local axis.
  90725. * @param localAxis Defines the reference axis to provide a relative direction.
  90726. * @return the direction
  90727. */
  90728. getDirection(localAxis: Vector3): Vector3;
  90729. /**
  90730. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90731. * @param localAxis Defines the reference axis to provide a relative direction.
  90732. * @param result Defines the vector to store the result in
  90733. */
  90734. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90735. /**
  90736. * Gets a camera constructor for a given camera type
  90737. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90738. * @param name The name of the camera the result will be able to instantiate
  90739. * @param scene The scene the result will construct the camera in
  90740. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90741. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90742. * @returns a factory method to construc the camera
  90743. */
  90744. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90745. /**
  90746. * Compute the world matrix of the camera.
  90747. * @returns the camera workd matrix
  90748. */
  90749. computeWorldMatrix(): Matrix;
  90750. /**
  90751. * Parse a JSON and creates the camera from the parsed information
  90752. * @param parsedCamera The JSON to parse
  90753. * @param scene The scene to instantiate the camera in
  90754. * @returns the newly constructed camera
  90755. */
  90756. static Parse(parsedCamera: any, scene: Scene): Camera;
  90757. }
  90758. }
  90759. declare module BABYLON {
  90760. /**
  90761. * Interface for any object that can request an animation frame
  90762. */
  90763. export interface ICustomAnimationFrameRequester {
  90764. /**
  90765. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  90766. */
  90767. renderFunction?: Function;
  90768. /**
  90769. * Called to request the next frame to render to
  90770. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  90771. */
  90772. requestAnimationFrame: Function;
  90773. /**
  90774. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  90775. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  90776. */
  90777. requestID?: number;
  90778. }
  90779. /**
  90780. * Interface containing an array of animations
  90781. */
  90782. export interface IAnimatable {
  90783. /**
  90784. * Array of animations
  90785. */
  90786. animations: Nullable<Array<Animation>>;
  90787. }
  90788. /** Interface used by value gradients (color, factor, ...) */
  90789. export interface IValueGradient {
  90790. /**
  90791. * Gets or sets the gradient value (between 0 and 1)
  90792. */
  90793. gradient: number;
  90794. }
  90795. /** Class used to store color4 gradient */
  90796. export class ColorGradient implements IValueGradient {
  90797. /**
  90798. * Gets or sets the gradient value (between 0 and 1)
  90799. */
  90800. gradient: number;
  90801. /**
  90802. * Gets or sets first associated color
  90803. */
  90804. color1: Color4;
  90805. /**
  90806. * Gets or sets second associated color
  90807. */
  90808. color2?: Color4;
  90809. /**
  90810. * Will get a color picked randomly between color1 and color2.
  90811. * If color2 is undefined then color1 will be used
  90812. * @param result defines the target Color4 to store the result in
  90813. */
  90814. getColorToRef(result: Color4): void;
  90815. }
  90816. /** Class used to store color 3 gradient */
  90817. export class Color3Gradient implements IValueGradient {
  90818. /**
  90819. * Gets or sets the gradient value (between 0 and 1)
  90820. */
  90821. gradient: number;
  90822. /**
  90823. * Gets or sets the associated color
  90824. */
  90825. color: Color3;
  90826. }
  90827. /** Class used to store factor gradient */
  90828. export class FactorGradient implements IValueGradient {
  90829. /**
  90830. * Gets or sets the gradient value (between 0 and 1)
  90831. */
  90832. gradient: number;
  90833. /**
  90834. * Gets or sets first associated factor
  90835. */
  90836. factor1: number;
  90837. /**
  90838. * Gets or sets second associated factor
  90839. */
  90840. factor2?: number;
  90841. /**
  90842. * Will get a number picked randomly between factor1 and factor2.
  90843. * If factor2 is undefined then factor1 will be used
  90844. * @returns the picked number
  90845. */
  90846. getFactor(): number;
  90847. }
  90848. /**
  90849. * @ignore
  90850. * Application error to support additional information when loading a file
  90851. */
  90852. export class LoadFileError extends Error {
  90853. /** defines the optional web request */
  90854. request?: WebRequest | undefined;
  90855. private static _setPrototypeOf;
  90856. /**
  90857. * Creates a new LoadFileError
  90858. * @param message defines the message of the error
  90859. * @param request defines the optional web request
  90860. */
  90861. constructor(message: string,
  90862. /** defines the optional web request */
  90863. request?: WebRequest | undefined);
  90864. }
  90865. /**
  90866. * Class used to define a retry strategy when error happens while loading assets
  90867. */
  90868. export class RetryStrategy {
  90869. /**
  90870. * Function used to defines an exponential back off strategy
  90871. * @param maxRetries defines the maximum number of retries (3 by default)
  90872. * @param baseInterval defines the interval between retries
  90873. * @returns the strategy function to use
  90874. */
  90875. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90876. }
  90877. /**
  90878. * File request interface
  90879. */
  90880. export interface IFileRequest {
  90881. /**
  90882. * Raised when the request is complete (success or error).
  90883. */
  90884. onCompleteObservable: Observable<IFileRequest>;
  90885. /**
  90886. * Aborts the request for a file.
  90887. */
  90888. abort: () => void;
  90889. }
  90890. /**
  90891. * Class containing a set of static utilities functions
  90892. */
  90893. export class Tools {
  90894. /**
  90895. * Gets or sets the base URL to use to load assets
  90896. */
  90897. static BaseUrl: string;
  90898. /**
  90899. * Enable/Disable Custom HTTP Request Headers globally.
  90900. * default = false
  90901. * @see CustomRequestHeaders
  90902. */
  90903. static UseCustomRequestHeaders: boolean;
  90904. /**
  90905. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90906. * i.e. when loading files, where the server/service expects an Authorization header
  90907. */
  90908. static CustomRequestHeaders: {
  90909. [key: string]: string;
  90910. };
  90911. /**
  90912. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90913. */
  90914. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90915. /**
  90916. * Default behaviour for cors in the application.
  90917. * It can be a string if the expected behavior is identical in the entire app.
  90918. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90919. */
  90920. static CorsBehavior: string | ((url: string | string[]) => string);
  90921. /**
  90922. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90923. * @ignorenaming
  90924. */
  90925. static UseFallbackTexture: boolean;
  90926. /**
  90927. * Use this object to register external classes like custom textures or material
  90928. * to allow the laoders to instantiate them
  90929. */
  90930. static RegisteredExternalClasses: {
  90931. [key: string]: Object;
  90932. };
  90933. /**
  90934. * Texture content used if a texture cannot loaded
  90935. * @ignorenaming
  90936. */
  90937. static fallbackTexture: string;
  90938. /**
  90939. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90940. * @param u defines the coordinate on X axis
  90941. * @param v defines the coordinate on Y axis
  90942. * @param width defines the width of the source data
  90943. * @param height defines the height of the source data
  90944. * @param pixels defines the source byte array
  90945. * @param color defines the output color
  90946. */
  90947. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90948. /**
  90949. * Interpolates between a and b via alpha
  90950. * @param a The lower value (returned when alpha = 0)
  90951. * @param b The upper value (returned when alpha = 1)
  90952. * @param alpha The interpolation-factor
  90953. * @return The mixed value
  90954. */
  90955. static Mix(a: number, b: number, alpha: number): number;
  90956. /**
  90957. * Tries to instantiate a new object from a given class name
  90958. * @param className defines the class name to instantiate
  90959. * @returns the new object or null if the system was not able to do the instantiation
  90960. */
  90961. static Instantiate(className: string): any;
  90962. /**
  90963. * Provides a slice function that will work even on IE
  90964. * @param data defines the array to slice
  90965. * @param start defines the start of the data (optional)
  90966. * @param end defines the end of the data (optional)
  90967. * @returns the new sliced array
  90968. */
  90969. static Slice<T>(data: T, start?: number, end?: number): T;
  90970. /**
  90971. * Polyfill for setImmediate
  90972. * @param action defines the action to execute after the current execution block
  90973. */
  90974. static SetImmediate(action: () => void): void;
  90975. /**
  90976. * Function indicating if a number is an exponent of 2
  90977. * @param value defines the value to test
  90978. * @returns true if the value is an exponent of 2
  90979. */
  90980. static IsExponentOfTwo(value: number): boolean;
  90981. private static _tmpFloatArray;
  90982. /**
  90983. * Returns the nearest 32-bit single precision float representation of a Number
  90984. * @param value A Number. If the parameter is of a different type, it will get converted
  90985. * to a number or to NaN if it cannot be converted
  90986. * @returns number
  90987. */
  90988. static FloatRound(value: number): number;
  90989. /**
  90990. * Find the next highest power of two.
  90991. * @param x Number to start search from.
  90992. * @return Next highest power of two.
  90993. */
  90994. static CeilingPOT(x: number): number;
  90995. /**
  90996. * Find the next lowest power of two.
  90997. * @param x Number to start search from.
  90998. * @return Next lowest power of two.
  90999. */
  91000. static FloorPOT(x: number): number;
  91001. /**
  91002. * Find the nearest power of two.
  91003. * @param x Number to start search from.
  91004. * @return Next nearest power of two.
  91005. */
  91006. static NearestPOT(x: number): number;
  91007. /**
  91008. * Get the closest exponent of two
  91009. * @param value defines the value to approximate
  91010. * @param max defines the maximum value to return
  91011. * @param mode defines how to define the closest value
  91012. * @returns closest exponent of two of the given value
  91013. */
  91014. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  91015. /**
  91016. * Extracts the filename from a path
  91017. * @param path defines the path to use
  91018. * @returns the filename
  91019. */
  91020. static GetFilename(path: string): string;
  91021. /**
  91022. * Extracts the "folder" part of a path (everything before the filename).
  91023. * @param uri The URI to extract the info from
  91024. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  91025. * @returns The "folder" part of the path
  91026. */
  91027. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  91028. /**
  91029. * Extracts text content from a DOM element hierarchy
  91030. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  91031. */
  91032. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  91033. /**
  91034. * Convert an angle in radians to degrees
  91035. * @param angle defines the angle to convert
  91036. * @returns the angle in degrees
  91037. */
  91038. static ToDegrees(angle: number): number;
  91039. /**
  91040. * Convert an angle in degrees to radians
  91041. * @param angle defines the angle to convert
  91042. * @returns the angle in radians
  91043. */
  91044. static ToRadians(angle: number): number;
  91045. /**
  91046. * Encode a buffer to a base64 string
  91047. * @param buffer defines the buffer to encode
  91048. * @returns the encoded string
  91049. */
  91050. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  91051. /**
  91052. * Extracts minimum and maximum values from a list of indexed positions
  91053. * @param positions defines the positions to use
  91054. * @param indices defines the indices to the positions
  91055. * @param indexStart defines the start index
  91056. * @param indexCount defines the end index
  91057. * @param bias defines bias value to add to the result
  91058. * @return minimum and maximum values
  91059. */
  91060. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  91061. minimum: Vector3;
  91062. maximum: Vector3;
  91063. };
  91064. /**
  91065. * Extracts minimum and maximum values from a list of positions
  91066. * @param positions defines the positions to use
  91067. * @param start defines the start index in the positions array
  91068. * @param count defines the number of positions to handle
  91069. * @param bias defines bias value to add to the result
  91070. * @param stride defines the stride size to use (distance between two positions in the positions array)
  91071. * @return minimum and maximum values
  91072. */
  91073. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  91074. minimum: Vector3;
  91075. maximum: Vector3;
  91076. };
  91077. /**
  91078. * Returns an array if obj is not an array
  91079. * @param obj defines the object to evaluate as an array
  91080. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  91081. * @returns either obj directly if obj is an array or a new array containing obj
  91082. */
  91083. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  91084. /**
  91085. * Gets the pointer prefix to use
  91086. * @returns "pointer" if touch is enabled. Else returns "mouse"
  91087. */
  91088. static GetPointerPrefix(): string;
  91089. /**
  91090. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  91091. * @param func - the function to be called
  91092. * @param requester - the object that will request the next frame. Falls back to window.
  91093. * @returns frame number
  91094. */
  91095. static QueueNewFrame(func: () => void, requester?: any): number;
  91096. /**
  91097. * Ask the browser to promote the current element to fullscreen rendering mode
  91098. * @param element defines the DOM element to promote
  91099. */
  91100. static RequestFullscreen(element: HTMLElement): void;
  91101. /**
  91102. * Asks the browser to exit fullscreen mode
  91103. */
  91104. static ExitFullscreen(): void;
  91105. /**
  91106. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  91107. * @param url define the url we are trying
  91108. * @param element define the dom element where to configure the cors policy
  91109. */
  91110. static SetCorsBehavior(url: string | string[], element: {
  91111. crossOrigin: string | null;
  91112. }): void;
  91113. /**
  91114. * Removes unwanted characters from an url
  91115. * @param url defines the url to clean
  91116. * @returns the cleaned url
  91117. */
  91118. static CleanUrl(url: string): string;
  91119. /**
  91120. * Gets or sets a function used to pre-process url before using them to load assets
  91121. */
  91122. static PreprocessUrl: (url: string) => string;
  91123. /**
  91124. * Loads an image as an HTMLImageElement.
  91125. * @param input url string, ArrayBuffer, or Blob to load
  91126. * @param onLoad callback called when the image successfully loads
  91127. * @param onError callback called when the image fails to load
  91128. * @param offlineProvider offline provider for caching
  91129. * @returns the HTMLImageElement of the loaded image
  91130. */
  91131. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  91132. /**
  91133. * Loads a file
  91134. * @param url url string, ArrayBuffer, or Blob to load
  91135. * @param onSuccess callback called when the file successfully loads
  91136. * @param onProgress callback called while file is loading (if the server supports this mode)
  91137. * @param offlineProvider defines the offline provider for caching
  91138. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  91139. * @param onError callback called when the file fails to load
  91140. * @returns a file request object
  91141. */
  91142. 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;
  91143. /**
  91144. * Load a script (identified by an url). When the url returns, the
  91145. * content of this file is added into a new script element, attached to the DOM (body element)
  91146. * @param scriptUrl defines the url of the script to laod
  91147. * @param onSuccess defines the callback called when the script is loaded
  91148. * @param onError defines the callback to call if an error occurs
  91149. * @param scriptId defines the id of the script element
  91150. */
  91151. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  91152. /**
  91153. * Load an asynchronous script (identified by an url). When the url returns, the
  91154. * content of this file is added into a new script element, attached to the DOM (body element)
  91155. * @param scriptUrl defines the url of the script to laod
  91156. * @param scriptId defines the id of the script element
  91157. * @returns a promise request object
  91158. */
  91159. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  91160. /**
  91161. * Loads a file from a blob
  91162. * @param fileToLoad defines the blob to use
  91163. * @param callback defines the callback to call when data is loaded
  91164. * @param progressCallback defines the callback to call during loading process
  91165. * @returns a file request object
  91166. */
  91167. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  91168. /**
  91169. * Loads a file
  91170. * @param fileToLoad defines the file to load
  91171. * @param callback defines the callback to call when data is loaded
  91172. * @param progressCallBack defines the callback to call during loading process
  91173. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  91174. * @returns a file request object
  91175. */
  91176. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  91177. /**
  91178. * Creates a data url from a given string content
  91179. * @param content defines the content to convert
  91180. * @returns the new data url link
  91181. */
  91182. static FileAsURL(content: string): string;
  91183. /**
  91184. * Format the given number to a specific decimal format
  91185. * @param value defines the number to format
  91186. * @param decimals defines the number of decimals to use
  91187. * @returns the formatted string
  91188. */
  91189. static Format(value: number, decimals?: number): string;
  91190. /**
  91191. * Checks if a given vector is inside a specific range
  91192. * @param v defines the vector to test
  91193. * @param min defines the minimum range
  91194. * @param max defines the maximum range
  91195. */
  91196. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  91197. /**
  91198. * Tries to copy an object by duplicating every property
  91199. * @param source defines the source object
  91200. * @param destination defines the target object
  91201. * @param doNotCopyList defines a list of properties to avoid
  91202. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  91203. */
  91204. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  91205. /**
  91206. * Gets a boolean indicating if the given object has no own property
  91207. * @param obj defines the object to test
  91208. * @returns true if object has no own property
  91209. */
  91210. static IsEmpty(obj: any): boolean;
  91211. /**
  91212. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  91213. * @param str Source string
  91214. * @param suffix Suffix to search for in the source string
  91215. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  91216. */
  91217. static EndsWith(str: string, suffix: string): boolean;
  91218. /**
  91219. * Function used to register events at window level
  91220. * @param events defines the events to register
  91221. */
  91222. static RegisterTopRootEvents(events: {
  91223. name: string;
  91224. handler: Nullable<(e: FocusEvent) => any>;
  91225. }[]): void;
  91226. /**
  91227. * Function used to unregister events from window level
  91228. * @param events defines the events to unregister
  91229. */
  91230. static UnregisterTopRootEvents(events: {
  91231. name: string;
  91232. handler: Nullable<(e: FocusEvent) => any>;
  91233. }[]): void;
  91234. /**
  91235. * @ignore
  91236. */
  91237. static _ScreenshotCanvas: HTMLCanvasElement;
  91238. /**
  91239. * Dumps the current bound framebuffer
  91240. * @param width defines the rendering width
  91241. * @param height defines the rendering height
  91242. * @param engine defines the hosting engine
  91243. * @param successCallback defines the callback triggered once the data are available
  91244. * @param mimeType defines the mime type of the result
  91245. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  91246. */
  91247. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91248. /**
  91249. * Converts the canvas data to blob.
  91250. * This acts as a polyfill for browsers not supporting the to blob function.
  91251. * @param canvas Defines the canvas to extract the data from
  91252. * @param successCallback Defines the callback triggered once the data are available
  91253. * @param mimeType Defines the mime type of the result
  91254. */
  91255. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  91256. /**
  91257. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  91258. * @param successCallback defines the callback triggered once the data are available
  91259. * @param mimeType defines the mime type of the result
  91260. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  91261. */
  91262. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91263. /**
  91264. * Downloads a blob in the browser
  91265. * @param blob defines the blob to download
  91266. * @param fileName defines the name of the downloaded file
  91267. */
  91268. static Download(blob: Blob, fileName: string): void;
  91269. /**
  91270. * Captures a screenshot of the current rendering
  91271. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91272. * @param engine defines the rendering engine
  91273. * @param camera defines the source camera
  91274. * @param size This parameter can be set to a single number or to an object with the
  91275. * following (optional) properties: precision, width, height. If a single number is passed,
  91276. * it will be used for both width and height. If an object is passed, the screenshot size
  91277. * will be derived from the parameters. The precision property is a multiplier allowing
  91278. * rendering at a higher or lower resolution
  91279. * @param successCallback defines the callback receives a single parameter which contains the
  91280. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91281. * src parameter of an <img> to display it
  91282. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  91283. * Check your browser for supported MIME types
  91284. */
  91285. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  91286. /**
  91287. * Generates an image screenshot from the specified camera.
  91288. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91289. * @param engine The engine to use for rendering
  91290. * @param camera The camera to use for rendering
  91291. * @param size This parameter can be set to a single number or to an object with the
  91292. * following (optional) properties: precision, width, height. If a single number is passed,
  91293. * it will be used for both width and height. If an object is passed, the screenshot size
  91294. * will be derived from the parameters. The precision property is a multiplier allowing
  91295. * rendering at a higher or lower resolution
  91296. * @param successCallback The callback receives a single parameter which contains the
  91297. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91298. * src parameter of an <img> to display it
  91299. * @param mimeType The MIME type of the screenshot image (default: image/png).
  91300. * Check your browser for supported MIME types
  91301. * @param samples Texture samples (default: 1)
  91302. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  91303. * @param fileName A name for for the downloaded file.
  91304. */
  91305. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  91306. /**
  91307. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91308. * Be aware Math.random() could cause collisions, but:
  91309. * "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"
  91310. * @returns a pseudo random id
  91311. */
  91312. static RandomId(): string;
  91313. /**
  91314. * Test if the given uri is a base64 string
  91315. * @param uri The uri to test
  91316. * @return True if the uri is a base64 string or false otherwise
  91317. */
  91318. static IsBase64(uri: string): boolean;
  91319. /**
  91320. * Decode the given base64 uri.
  91321. * @param uri The uri to decode
  91322. * @return The decoded base64 data.
  91323. */
  91324. static DecodeBase64(uri: string): ArrayBuffer;
  91325. /**
  91326. * Gets the absolute url.
  91327. * @param url the input url
  91328. * @return the absolute url
  91329. */
  91330. static GetAbsoluteUrl(url: string): string;
  91331. /**
  91332. * No log
  91333. */
  91334. static readonly NoneLogLevel: number;
  91335. /**
  91336. * Only message logs
  91337. */
  91338. static readonly MessageLogLevel: number;
  91339. /**
  91340. * Only warning logs
  91341. */
  91342. static readonly WarningLogLevel: number;
  91343. /**
  91344. * Only error logs
  91345. */
  91346. static readonly ErrorLogLevel: number;
  91347. /**
  91348. * All logs
  91349. */
  91350. static readonly AllLogLevel: number;
  91351. /**
  91352. * Gets a value indicating the number of loading errors
  91353. * @ignorenaming
  91354. */
  91355. static readonly errorsCount: number;
  91356. /**
  91357. * Callback called when a new log is added
  91358. */
  91359. static OnNewCacheEntry: (entry: string) => void;
  91360. /**
  91361. * Log a message to the console
  91362. * @param message defines the message to log
  91363. */
  91364. static Log(message: string): void;
  91365. /**
  91366. * Write a warning message to the console
  91367. * @param message defines the message to log
  91368. */
  91369. static Warn(message: string): void;
  91370. /**
  91371. * Write an error message to the console
  91372. * @param message defines the message to log
  91373. */
  91374. static Error(message: string): void;
  91375. /**
  91376. * Gets current log cache (list of logs)
  91377. */
  91378. static readonly LogCache: string;
  91379. /**
  91380. * Clears the log cache
  91381. */
  91382. static ClearLogCache(): void;
  91383. /**
  91384. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  91385. */
  91386. static LogLevels: number;
  91387. /**
  91388. * Checks if the loaded document was accessed via `file:`-Protocol.
  91389. * @returns boolean
  91390. */
  91391. static IsFileURL(): boolean;
  91392. /**
  91393. * Checks if the window object exists
  91394. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  91395. */
  91396. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  91397. /**
  91398. * No performance log
  91399. */
  91400. static readonly PerformanceNoneLogLevel: number;
  91401. /**
  91402. * Use user marks to log performance
  91403. */
  91404. static readonly PerformanceUserMarkLogLevel: number;
  91405. /**
  91406. * Log performance to the console
  91407. */
  91408. static readonly PerformanceConsoleLogLevel: number;
  91409. private static _performance;
  91410. /**
  91411. * Sets the current performance log level
  91412. */
  91413. static PerformanceLogLevel: number;
  91414. private static _StartPerformanceCounterDisabled;
  91415. private static _EndPerformanceCounterDisabled;
  91416. private static _StartUserMark;
  91417. private static _EndUserMark;
  91418. private static _StartPerformanceConsole;
  91419. private static _EndPerformanceConsole;
  91420. /**
  91421. * Starts a performance counter
  91422. */
  91423. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91424. /**
  91425. * Ends a specific performance coutner
  91426. */
  91427. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91428. /**
  91429. * Gets either window.performance.now() if supported or Date.now() else
  91430. */
  91431. static readonly Now: number;
  91432. /**
  91433. * This method will return the name of the class used to create the instance of the given object.
  91434. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  91435. * @param object the object to get the class name from
  91436. * @param isType defines if the object is actually a type
  91437. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  91438. */
  91439. static GetClassName(object: any, isType?: boolean): string;
  91440. /**
  91441. * Gets the first element of an array satisfying a given predicate
  91442. * @param array defines the array to browse
  91443. * @param predicate defines the predicate to use
  91444. * @returns null if not found or the element
  91445. */
  91446. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  91447. /**
  91448. * This method will return the name of the full name of the class, including its owning module (if any).
  91449. * 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).
  91450. * @param object the object to get the class name from
  91451. * @param isType defines if the object is actually a type
  91452. * @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.
  91453. * @ignorenaming
  91454. */
  91455. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  91456. /**
  91457. * Returns a promise that resolves after the given amount of time.
  91458. * @param delay Number of milliseconds to delay
  91459. * @returns Promise that resolves after the given amount of time
  91460. */
  91461. static DelayAsync(delay: number): Promise<void>;
  91462. /**
  91463. * Gets the current gradient from an array of IValueGradient
  91464. * @param ratio defines the current ratio to get
  91465. * @param gradients defines the array of IValueGradient
  91466. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91467. */
  91468. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91469. }
  91470. /**
  91471. * This class is used to track a performance counter which is number based.
  91472. * The user has access to many properties which give statistics of different nature.
  91473. *
  91474. * The implementer can track two kinds of Performance Counter: time and count.
  91475. * 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.
  91476. * 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.
  91477. */
  91478. export class PerfCounter {
  91479. /**
  91480. * Gets or sets a global boolean to turn on and off all the counters
  91481. */
  91482. static Enabled: boolean;
  91483. /**
  91484. * Returns the smallest value ever
  91485. */
  91486. readonly min: number;
  91487. /**
  91488. * Returns the biggest value ever
  91489. */
  91490. readonly max: number;
  91491. /**
  91492. * Returns the average value since the performance counter is running
  91493. */
  91494. readonly average: number;
  91495. /**
  91496. * Returns the average value of the last second the counter was monitored
  91497. */
  91498. readonly lastSecAverage: number;
  91499. /**
  91500. * Returns the current value
  91501. */
  91502. readonly current: number;
  91503. /**
  91504. * Gets the accumulated total
  91505. */
  91506. readonly total: number;
  91507. /**
  91508. * Gets the total value count
  91509. */
  91510. readonly count: number;
  91511. /**
  91512. * Creates a new counter
  91513. */
  91514. constructor();
  91515. /**
  91516. * Call this method to start monitoring a new frame.
  91517. * 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.
  91518. */
  91519. fetchNewFrame(): void;
  91520. /**
  91521. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  91522. * @param newCount the count value to add to the monitored count
  91523. * @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.
  91524. */
  91525. addCount(newCount: number, fetchResult: boolean): void;
  91526. /**
  91527. * Start monitoring this performance counter
  91528. */
  91529. beginMonitoring(): void;
  91530. /**
  91531. * Compute the time lapsed since the previous beginMonitoring() call.
  91532. * @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
  91533. */
  91534. endMonitoring(newFrame?: boolean): void;
  91535. private _fetchResult;
  91536. private _startMonitoringTime;
  91537. private _min;
  91538. private _max;
  91539. private _average;
  91540. private _current;
  91541. private _totalValueCount;
  91542. private _totalAccumulated;
  91543. private _lastSecAverage;
  91544. private _lastSecAccumulated;
  91545. private _lastSecTime;
  91546. private _lastSecValueCount;
  91547. }
  91548. /**
  91549. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  91550. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  91551. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  91552. * @param name The name of the class, case should be preserved
  91553. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  91554. */
  91555. export function className(name: string, module?: string): (target: Object) => void;
  91556. /**
  91557. * An implementation of a loop for asynchronous functions.
  91558. */
  91559. export class AsyncLoop {
  91560. /**
  91561. * Defines the number of iterations for the loop
  91562. */
  91563. iterations: number;
  91564. /**
  91565. * Defines the current index of the loop.
  91566. */
  91567. index: number;
  91568. private _done;
  91569. private _fn;
  91570. private _successCallback;
  91571. /**
  91572. * Constructor.
  91573. * @param iterations the number of iterations.
  91574. * @param func the function to run each iteration
  91575. * @param successCallback the callback that will be called upon succesful execution
  91576. * @param offset starting offset.
  91577. */
  91578. constructor(
  91579. /**
  91580. * Defines the number of iterations for the loop
  91581. */
  91582. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  91583. /**
  91584. * Execute the next iteration. Must be called after the last iteration was finished.
  91585. */
  91586. executeNext(): void;
  91587. /**
  91588. * Break the loop and run the success callback.
  91589. */
  91590. breakLoop(): void;
  91591. /**
  91592. * Create and run an async loop.
  91593. * @param iterations the number of iterations.
  91594. * @param fn the function to run each iteration
  91595. * @param successCallback the callback that will be called upon succesful execution
  91596. * @param offset starting offset.
  91597. * @returns the created async loop object
  91598. */
  91599. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  91600. /**
  91601. * A for-loop that will run a given number of iterations synchronous and the rest async.
  91602. * @param iterations total number of iterations
  91603. * @param syncedIterations number of synchronous iterations in each async iteration.
  91604. * @param fn the function to call each iteration.
  91605. * @param callback a success call back that will be called when iterating stops.
  91606. * @param breakFunction a break condition (optional)
  91607. * @param timeout timeout settings for the setTimeout function. default - 0.
  91608. * @returns the created async loop object
  91609. */
  91610. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  91611. }
  91612. }
  91613. declare module BABYLON {
  91614. /** @hidden */
  91615. export interface ICollisionCoordinator {
  91616. createCollider(): Collider;
  91617. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91618. init(scene: Scene): void;
  91619. }
  91620. /** @hidden */
  91621. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  91622. private _scene;
  91623. private _scaledPosition;
  91624. private _scaledVelocity;
  91625. private _finalPosition;
  91626. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91627. createCollider(): Collider;
  91628. init(scene: Scene): void;
  91629. private _collideWithWorld;
  91630. }
  91631. }
  91632. declare module BABYLON {
  91633. /**
  91634. * Class used to manage all inputs for the scene.
  91635. */
  91636. export class InputManager {
  91637. /** The distance in pixel that you have to move to prevent some events */
  91638. static DragMovementThreshold: number;
  91639. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91640. static LongPressDelay: number;
  91641. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91642. static DoubleClickDelay: number;
  91643. /** If you need to check double click without raising a single click at first click, enable this flag */
  91644. static ExclusiveDoubleClickMode: boolean;
  91645. private _wheelEventName;
  91646. private _onPointerMove;
  91647. private _onPointerDown;
  91648. private _onPointerUp;
  91649. private _initClickEvent;
  91650. private _initActionManager;
  91651. private _delayedSimpleClick;
  91652. private _delayedSimpleClickTimeout;
  91653. private _previousDelayedSimpleClickTimeout;
  91654. private _meshPickProceed;
  91655. private _previousButtonPressed;
  91656. private _currentPickResult;
  91657. private _previousPickResult;
  91658. private _totalPointersPressed;
  91659. private _doubleClickOccured;
  91660. private _pointerOverMesh;
  91661. private _pickedDownMesh;
  91662. private _pickedUpMesh;
  91663. private _pointerX;
  91664. private _pointerY;
  91665. private _unTranslatedPointerX;
  91666. private _unTranslatedPointerY;
  91667. private _startingPointerPosition;
  91668. private _previousStartingPointerPosition;
  91669. private _startingPointerTime;
  91670. private _previousStartingPointerTime;
  91671. private _pointerCaptures;
  91672. private _onKeyDown;
  91673. private _onKeyUp;
  91674. private _onCanvasFocusObserver;
  91675. private _onCanvasBlurObserver;
  91676. private _scene;
  91677. /**
  91678. * Creates a new InputManager
  91679. * @param scene defines the hosting scene
  91680. */
  91681. constructor(scene: Scene);
  91682. /**
  91683. * Gets the mesh that is currently under the pointer
  91684. */
  91685. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91686. /**
  91687. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  91688. */
  91689. readonly unTranslatedPointer: Vector2;
  91690. /**
  91691. * Gets or sets the current on-screen X position of the pointer
  91692. */
  91693. pointerX: number;
  91694. /**
  91695. * Gets or sets the current on-screen Y position of the pointer
  91696. */
  91697. pointerY: number;
  91698. private _updatePointerPosition;
  91699. private _processPointerMove;
  91700. private _setRayOnPointerInfo;
  91701. private _checkPrePointerObservable;
  91702. /**
  91703. * Use this method to simulate a pointer move on a mesh
  91704. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91705. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91706. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91707. */
  91708. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91709. /**
  91710. * Use this method to simulate a pointer down on a mesh
  91711. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91712. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91713. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91714. */
  91715. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91716. private _processPointerDown;
  91717. /** @hidden */
  91718. _isPointerSwiping(): boolean;
  91719. /**
  91720. * Use this method to simulate a pointer up on a mesh
  91721. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91722. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91723. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91724. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91725. */
  91726. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  91727. private _processPointerUp;
  91728. /**
  91729. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91730. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  91731. * @returns true if the pointer was captured
  91732. */
  91733. isPointerCaptured(pointerId?: number): boolean;
  91734. /**
  91735. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  91736. * @param attachUp defines if you want to attach events to pointerup
  91737. * @param attachDown defines if you want to attach events to pointerdown
  91738. * @param attachMove defines if you want to attach events to pointermove
  91739. */
  91740. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  91741. /**
  91742. * Detaches all event handlers
  91743. */
  91744. detachControl(): void;
  91745. /**
  91746. * Force the value of meshUnderPointer
  91747. * @param mesh defines the mesh to use
  91748. */
  91749. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  91750. /**
  91751. * Gets the mesh under the pointer
  91752. * @returns a Mesh or null if no mesh is under the pointer
  91753. */
  91754. getPointerOverMesh(): Nullable<AbstractMesh>;
  91755. }
  91756. }
  91757. declare module BABYLON {
  91758. /**
  91759. * This class defines the direct association between an animation and a target
  91760. */
  91761. export class TargetedAnimation {
  91762. /**
  91763. * Animation to perform
  91764. */
  91765. animation: Animation;
  91766. /**
  91767. * Target to animate
  91768. */
  91769. target: any;
  91770. }
  91771. /**
  91772. * Use this class to create coordinated animations on multiple targets
  91773. */
  91774. export class AnimationGroup implements IDisposable {
  91775. /** The name of the animation group */
  91776. name: string;
  91777. private _scene;
  91778. private _targetedAnimations;
  91779. private _animatables;
  91780. private _from;
  91781. private _to;
  91782. private _isStarted;
  91783. private _isPaused;
  91784. private _speedRatio;
  91785. private _loopAnimation;
  91786. /**
  91787. * Gets or sets the unique id of the node
  91788. */
  91789. uniqueId: number;
  91790. /**
  91791. * This observable will notify when one animation have ended
  91792. */
  91793. onAnimationEndObservable: Observable<TargetedAnimation>;
  91794. /**
  91795. * Observer raised when one animation loops
  91796. */
  91797. onAnimationLoopObservable: Observable<TargetedAnimation>;
  91798. /**
  91799. * This observable will notify when all animations have ended.
  91800. */
  91801. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  91802. /**
  91803. * This observable will notify when all animations have paused.
  91804. */
  91805. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  91806. /**
  91807. * This observable will notify when all animations are playing.
  91808. */
  91809. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  91810. /**
  91811. * Gets the first frame
  91812. */
  91813. readonly from: number;
  91814. /**
  91815. * Gets the last frame
  91816. */
  91817. readonly to: number;
  91818. /**
  91819. * Define if the animations are started
  91820. */
  91821. readonly isStarted: boolean;
  91822. /**
  91823. * Gets a value indicating that the current group is playing
  91824. */
  91825. readonly isPlaying: boolean;
  91826. /**
  91827. * Gets or sets the speed ratio to use for all animations
  91828. */
  91829. /**
  91830. * Gets or sets the speed ratio to use for all animations
  91831. */
  91832. speedRatio: number;
  91833. /**
  91834. * Gets or sets if all animations should loop or not
  91835. */
  91836. loopAnimation: boolean;
  91837. /**
  91838. * Gets the targeted animations for this animation group
  91839. */
  91840. readonly targetedAnimations: Array<TargetedAnimation>;
  91841. /**
  91842. * returning the list of animatables controlled by this animation group.
  91843. */
  91844. readonly animatables: Array<Animatable>;
  91845. /**
  91846. * Instantiates a new Animation Group.
  91847. * This helps managing several animations at once.
  91848. * @see http://doc.babylonjs.com/how_to/group
  91849. * @param name Defines the name of the group
  91850. * @param scene Defines the scene the group belongs to
  91851. */
  91852. constructor(
  91853. /** The name of the animation group */
  91854. name: string, scene?: Nullable<Scene>);
  91855. /**
  91856. * Add an animation (with its target) in the group
  91857. * @param animation defines the animation we want to add
  91858. * @param target defines the target of the animation
  91859. * @returns the TargetedAnimation object
  91860. */
  91861. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  91862. /**
  91863. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  91864. * It can add constant keys at begin or end
  91865. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  91866. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  91867. * @returns the animation group
  91868. */
  91869. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  91870. /**
  91871. * Start all animations on given targets
  91872. * @param loop defines if animations must loop
  91873. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  91874. * @param from defines the from key (optional)
  91875. * @param to defines the to key (optional)
  91876. * @returns the current animation group
  91877. */
  91878. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  91879. /**
  91880. * Pause all animations
  91881. * @returns the animation group
  91882. */
  91883. pause(): AnimationGroup;
  91884. /**
  91885. * Play all animations to initial state
  91886. * This function will start() the animations if they were not started or will restart() them if they were paused
  91887. * @param loop defines if animations must loop
  91888. * @returns the animation group
  91889. */
  91890. play(loop?: boolean): AnimationGroup;
  91891. /**
  91892. * Reset all animations to initial state
  91893. * @returns the animation group
  91894. */
  91895. reset(): AnimationGroup;
  91896. /**
  91897. * Restart animations from key 0
  91898. * @returns the animation group
  91899. */
  91900. restart(): AnimationGroup;
  91901. /**
  91902. * Stop all animations
  91903. * @returns the animation group
  91904. */
  91905. stop(): AnimationGroup;
  91906. /**
  91907. * Set animation weight for all animatables
  91908. * @param weight defines the weight to use
  91909. * @return the animationGroup
  91910. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91911. */
  91912. setWeightForAllAnimatables(weight: number): AnimationGroup;
  91913. /**
  91914. * Synchronize and normalize all animatables with a source animatable
  91915. * @param root defines the root animatable to synchronize with
  91916. * @return the animationGroup
  91917. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91918. */
  91919. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  91920. /**
  91921. * Goes to a specific frame in this animation group
  91922. * @param frame the frame number to go to
  91923. * @return the animationGroup
  91924. */
  91925. goToFrame(frame: number): AnimationGroup;
  91926. /**
  91927. * Dispose all associated resources
  91928. */
  91929. dispose(): void;
  91930. private _checkAnimationGroupEnded;
  91931. /**
  91932. * Clone the current animation group and returns a copy
  91933. * @param newName defines the name of the new group
  91934. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  91935. * @returns the new aniamtion group
  91936. */
  91937. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  91938. /**
  91939. * Returns a new AnimationGroup object parsed from the source provided.
  91940. * @param parsedAnimationGroup defines the source
  91941. * @param scene defines the scene that will receive the animationGroup
  91942. * @returns a new AnimationGroup
  91943. */
  91944. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  91945. /**
  91946. * Returns the string "AnimationGroup"
  91947. * @returns "AnimationGroup"
  91948. */
  91949. getClassName(): string;
  91950. /**
  91951. * Creates a detailled string about the object
  91952. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  91953. * @returns a string representing the object
  91954. */
  91955. toString(fullDetails?: boolean): string;
  91956. }
  91957. }
  91958. declare module BABYLON {
  91959. /**
  91960. * Define an interface for all classes that will hold resources
  91961. */
  91962. export interface IDisposable {
  91963. /**
  91964. * Releases all held resources
  91965. */
  91966. dispose(): void;
  91967. }
  91968. /** Interface defining initialization parameters for Scene class */
  91969. export interface SceneOptions {
  91970. /**
  91971. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  91972. * It will improve performance when the number of geometries becomes important.
  91973. */
  91974. useGeometryUniqueIdsMap?: boolean;
  91975. /**
  91976. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  91977. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91978. */
  91979. useMaterialMeshMap?: boolean;
  91980. /**
  91981. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91982. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91983. */
  91984. useClonedMeshhMap?: boolean;
  91985. }
  91986. /**
  91987. * Represents a scene to be rendered by the engine.
  91988. * @see http://doc.babylonjs.com/features/scene
  91989. */
  91990. export class Scene extends AbstractScene implements IAnimatable {
  91991. private static _uniqueIdCounter;
  91992. /** The fog is deactivated */
  91993. static readonly FOGMODE_NONE: number;
  91994. /** The fog density is following an exponential function */
  91995. static readonly FOGMODE_EXP: number;
  91996. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  91997. static readonly FOGMODE_EXP2: number;
  91998. /** The fog density is following a linear function. */
  91999. static readonly FOGMODE_LINEAR: number;
  92000. /**
  92001. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  92002. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92003. */
  92004. static MinDeltaTime: number;
  92005. /**
  92006. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  92007. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92008. */
  92009. static MaxDeltaTime: number;
  92010. /**
  92011. * Factory used to create the default material.
  92012. * @param name The name of the material to create
  92013. * @param scene The scene to create the material for
  92014. * @returns The default material
  92015. */
  92016. static DefaultMaterialFactory(scene: Scene): Material;
  92017. /**
  92018. * Factory used to create the a collision coordinator.
  92019. * @returns The collision coordinator
  92020. */
  92021. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  92022. /** @hidden */
  92023. _inputManager: InputManager;
  92024. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  92025. cameraToUseForPointers: Nullable<Camera>;
  92026. /** @hidden */
  92027. readonly _isScene: boolean;
  92028. /**
  92029. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  92030. */
  92031. autoClear: boolean;
  92032. /**
  92033. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  92034. */
  92035. autoClearDepthAndStencil: boolean;
  92036. /**
  92037. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  92038. */
  92039. clearColor: Color4;
  92040. /**
  92041. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  92042. */
  92043. ambientColor: Color3;
  92044. /**
  92045. * This is use to store the default BRDF lookup for PBR materials in your scene.
  92046. * It should only be one of the following (if not the default embedded one):
  92047. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  92048. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  92049. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  92050. * The material properties need to be setup according to the type of texture in use.
  92051. */
  92052. environmentBRDFTexture: BaseTexture;
  92053. /** @hidden */
  92054. protected _environmentTexture: Nullable<BaseTexture>;
  92055. /**
  92056. * Texture used in all pbr material as the reflection texture.
  92057. * As in the majority of the scene they are the same (exception for multi room and so on),
  92058. * this is easier to reference from here than from all the materials.
  92059. */
  92060. /**
  92061. * Texture used in all pbr material as the reflection texture.
  92062. * As in the majority of the scene they are the same (exception for multi room and so on),
  92063. * this is easier to set here than in all the materials.
  92064. */
  92065. environmentTexture: Nullable<BaseTexture>;
  92066. /** @hidden */
  92067. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  92068. /**
  92069. * Default image processing configuration used either in the rendering
  92070. * Forward main pass or through the imageProcessingPostProcess if present.
  92071. * As in the majority of the scene they are the same (exception for multi camera),
  92072. * this is easier to reference from here than from all the materials and post process.
  92073. *
  92074. * No setter as we it is a shared configuration, you can set the values instead.
  92075. */
  92076. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  92077. private _forceWireframe;
  92078. /**
  92079. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  92080. */
  92081. forceWireframe: boolean;
  92082. private _forcePointsCloud;
  92083. /**
  92084. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  92085. */
  92086. forcePointsCloud: boolean;
  92087. /**
  92088. * Gets or sets the active clipplane 1
  92089. */
  92090. clipPlane: Nullable<Plane>;
  92091. /**
  92092. * Gets or sets the active clipplane 2
  92093. */
  92094. clipPlane2: Nullable<Plane>;
  92095. /**
  92096. * Gets or sets the active clipplane 3
  92097. */
  92098. clipPlane3: Nullable<Plane>;
  92099. /**
  92100. * Gets or sets the active clipplane 4
  92101. */
  92102. clipPlane4: Nullable<Plane>;
  92103. /**
  92104. * Gets or sets a boolean indicating if animations are enabled
  92105. */
  92106. animationsEnabled: boolean;
  92107. private _animationPropertiesOverride;
  92108. /**
  92109. * Gets or sets the animation properties override
  92110. */
  92111. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  92112. /**
  92113. * Gets or sets a boolean indicating if a constant deltatime has to be used
  92114. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  92115. */
  92116. useConstantAnimationDeltaTime: boolean;
  92117. /**
  92118. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  92119. * Please note that it requires to run a ray cast through the scene on every frame
  92120. */
  92121. constantlyUpdateMeshUnderPointer: boolean;
  92122. /**
  92123. * Defines the HTML cursor to use when hovering over interactive elements
  92124. */
  92125. hoverCursor: string;
  92126. /**
  92127. * Defines the HTML default cursor to use (empty by default)
  92128. */
  92129. defaultCursor: string;
  92130. /**
  92131. * This is used to call preventDefault() on pointer down
  92132. * in order to block unwanted artifacts like system double clicks
  92133. */
  92134. preventDefaultOnPointerDown: boolean;
  92135. /**
  92136. * This is used to call preventDefault() on pointer up
  92137. * in order to block unwanted artifacts like system double clicks
  92138. */
  92139. preventDefaultOnPointerUp: boolean;
  92140. /**
  92141. * Gets or sets user defined metadata
  92142. */
  92143. metadata: any;
  92144. /**
  92145. * For internal use only. Please do not use.
  92146. */
  92147. reservedDataStore: any;
  92148. /**
  92149. * Gets the name of the plugin used to load this scene (null by default)
  92150. */
  92151. loadingPluginName: string;
  92152. /**
  92153. * Use this array to add regular expressions used to disable offline support for specific urls
  92154. */
  92155. disableOfflineSupportExceptionRules: RegExp[];
  92156. /**
  92157. * An event triggered when the scene is disposed.
  92158. */
  92159. onDisposeObservable: Observable<Scene>;
  92160. private _onDisposeObserver;
  92161. /** Sets a function to be executed when this scene is disposed. */
  92162. onDispose: () => void;
  92163. /**
  92164. * An event triggered before rendering the scene (right after animations and physics)
  92165. */
  92166. onBeforeRenderObservable: Observable<Scene>;
  92167. private _onBeforeRenderObserver;
  92168. /** Sets a function to be executed before rendering this scene */
  92169. beforeRender: Nullable<() => void>;
  92170. /**
  92171. * An event triggered after rendering the scene
  92172. */
  92173. onAfterRenderObservable: Observable<Scene>;
  92174. private _onAfterRenderObserver;
  92175. /** Sets a function to be executed after rendering this scene */
  92176. afterRender: Nullable<() => void>;
  92177. /**
  92178. * An event triggered before animating the scene
  92179. */
  92180. onBeforeAnimationsObservable: Observable<Scene>;
  92181. /**
  92182. * An event triggered after animations processing
  92183. */
  92184. onAfterAnimationsObservable: Observable<Scene>;
  92185. /**
  92186. * An event triggered before draw calls are ready to be sent
  92187. */
  92188. onBeforeDrawPhaseObservable: Observable<Scene>;
  92189. /**
  92190. * An event triggered after draw calls have been sent
  92191. */
  92192. onAfterDrawPhaseObservable: Observable<Scene>;
  92193. /**
  92194. * An event triggered when the scene is ready
  92195. */
  92196. onReadyObservable: Observable<Scene>;
  92197. /**
  92198. * An event triggered before rendering a camera
  92199. */
  92200. onBeforeCameraRenderObservable: Observable<Camera>;
  92201. private _onBeforeCameraRenderObserver;
  92202. /** Sets a function to be executed before rendering a camera*/
  92203. beforeCameraRender: () => void;
  92204. /**
  92205. * An event triggered after rendering a camera
  92206. */
  92207. onAfterCameraRenderObservable: Observable<Camera>;
  92208. private _onAfterCameraRenderObserver;
  92209. /** Sets a function to be executed after rendering a camera*/
  92210. afterCameraRender: () => void;
  92211. /**
  92212. * An event triggered when active meshes evaluation is about to start
  92213. */
  92214. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  92215. /**
  92216. * An event triggered when active meshes evaluation is done
  92217. */
  92218. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  92219. /**
  92220. * An event triggered when particles rendering is about to start
  92221. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92222. */
  92223. onBeforeParticlesRenderingObservable: Observable<Scene>;
  92224. /**
  92225. * An event triggered when particles rendering is done
  92226. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92227. */
  92228. onAfterParticlesRenderingObservable: Observable<Scene>;
  92229. /**
  92230. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  92231. */
  92232. onDataLoadedObservable: Observable<Scene>;
  92233. /**
  92234. * An event triggered when a camera is created
  92235. */
  92236. onNewCameraAddedObservable: Observable<Camera>;
  92237. /**
  92238. * An event triggered when a camera is removed
  92239. */
  92240. onCameraRemovedObservable: Observable<Camera>;
  92241. /**
  92242. * An event triggered when a light is created
  92243. */
  92244. onNewLightAddedObservable: Observable<Light>;
  92245. /**
  92246. * An event triggered when a light is removed
  92247. */
  92248. onLightRemovedObservable: Observable<Light>;
  92249. /**
  92250. * An event triggered when a geometry is created
  92251. */
  92252. onNewGeometryAddedObservable: Observable<Geometry>;
  92253. /**
  92254. * An event triggered when a geometry is removed
  92255. */
  92256. onGeometryRemovedObservable: Observable<Geometry>;
  92257. /**
  92258. * An event triggered when a transform node is created
  92259. */
  92260. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  92261. /**
  92262. * An event triggered when a transform node is removed
  92263. */
  92264. onTransformNodeRemovedObservable: Observable<TransformNode>;
  92265. /**
  92266. * An event triggered when a mesh is created
  92267. */
  92268. onNewMeshAddedObservable: Observable<AbstractMesh>;
  92269. /**
  92270. * An event triggered when a mesh is removed
  92271. */
  92272. onMeshRemovedObservable: Observable<AbstractMesh>;
  92273. /**
  92274. * An event triggered when a skeleton is created
  92275. */
  92276. onNewSkeletonAddedObservable: Observable<Skeleton>;
  92277. /**
  92278. * An event triggered when a skeleton is removed
  92279. */
  92280. onSkeletonRemovedObservable: Observable<Skeleton>;
  92281. /**
  92282. * An event triggered when a material is created
  92283. */
  92284. onNewMaterialAddedObservable: Observable<Material>;
  92285. /**
  92286. * An event triggered when a material is removed
  92287. */
  92288. onMaterialRemovedObservable: Observable<Material>;
  92289. /**
  92290. * An event triggered when a texture is created
  92291. */
  92292. onNewTextureAddedObservable: Observable<BaseTexture>;
  92293. /**
  92294. * An event triggered when a texture is removed
  92295. */
  92296. onTextureRemovedObservable: Observable<BaseTexture>;
  92297. /**
  92298. * An event triggered when render targets are about to be rendered
  92299. * Can happen multiple times per frame.
  92300. */
  92301. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  92302. /**
  92303. * An event triggered when render targets were rendered.
  92304. * Can happen multiple times per frame.
  92305. */
  92306. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  92307. /**
  92308. * An event triggered before calculating deterministic simulation step
  92309. */
  92310. onBeforeStepObservable: Observable<Scene>;
  92311. /**
  92312. * An event triggered after calculating deterministic simulation step
  92313. */
  92314. onAfterStepObservable: Observable<Scene>;
  92315. /**
  92316. * An event triggered when the activeCamera property is updated
  92317. */
  92318. onActiveCameraChanged: Observable<Scene>;
  92319. /**
  92320. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  92321. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92322. * 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)
  92323. */
  92324. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92325. /**
  92326. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  92327. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92328. * 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)
  92329. */
  92330. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92331. /**
  92332. * This Observable will when a mesh has been imported into the scene.
  92333. */
  92334. onMeshImportedObservable: Observable<AbstractMesh>;
  92335. /**
  92336. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  92337. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  92338. */
  92339. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  92340. /** @hidden */
  92341. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  92342. /**
  92343. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  92344. */
  92345. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  92346. /**
  92347. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  92348. */
  92349. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  92350. /**
  92351. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  92352. */
  92353. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  92354. /** Callback called when a pointer move is detected */
  92355. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92356. /** Callback called when a pointer down is detected */
  92357. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92358. /** Callback called when a pointer up is detected */
  92359. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  92360. /** Callback called when a pointer pick is detected */
  92361. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  92362. /**
  92363. * 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).
  92364. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  92365. */
  92366. onPrePointerObservable: Observable<PointerInfoPre>;
  92367. /**
  92368. * Observable event triggered each time an input event is received from the rendering canvas
  92369. */
  92370. onPointerObservable: Observable<PointerInfo>;
  92371. /**
  92372. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  92373. */
  92374. readonly unTranslatedPointer: Vector2;
  92375. /**
  92376. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  92377. */
  92378. static DragMovementThreshold: number;
  92379. /**
  92380. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  92381. */
  92382. static LongPressDelay: number;
  92383. /**
  92384. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  92385. */
  92386. static DoubleClickDelay: number;
  92387. /** If you need to check double click without raising a single click at first click, enable this flag */
  92388. static ExclusiveDoubleClickMode: boolean;
  92389. /** @hidden */
  92390. _mirroredCameraPosition: Nullable<Vector3>;
  92391. /**
  92392. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  92393. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  92394. */
  92395. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  92396. /**
  92397. * Observable event triggered each time an keyboard event is received from the hosting window
  92398. */
  92399. onKeyboardObservable: Observable<KeyboardInfo>;
  92400. private _useRightHandedSystem;
  92401. /**
  92402. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  92403. */
  92404. useRightHandedSystem: boolean;
  92405. private _timeAccumulator;
  92406. private _currentStepId;
  92407. private _currentInternalStep;
  92408. /**
  92409. * Sets the step Id used by deterministic lock step
  92410. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92411. * @param newStepId defines the step Id
  92412. */
  92413. setStepId(newStepId: number): void;
  92414. /**
  92415. * Gets the step Id used by deterministic lock step
  92416. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92417. * @returns the step Id
  92418. */
  92419. getStepId(): number;
  92420. /**
  92421. * Gets the internal step used by deterministic lock step
  92422. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92423. * @returns the internal step
  92424. */
  92425. getInternalStep(): number;
  92426. private _fogEnabled;
  92427. /**
  92428. * Gets or sets a boolean indicating if fog is enabled on this scene
  92429. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92430. * (Default is true)
  92431. */
  92432. fogEnabled: boolean;
  92433. private _fogMode;
  92434. /**
  92435. * Gets or sets the fog mode to use
  92436. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92437. * | mode | value |
  92438. * | --- | --- |
  92439. * | FOGMODE_NONE | 0 |
  92440. * | FOGMODE_EXP | 1 |
  92441. * | FOGMODE_EXP2 | 2 |
  92442. * | FOGMODE_LINEAR | 3 |
  92443. */
  92444. fogMode: number;
  92445. /**
  92446. * Gets or sets the fog color to use
  92447. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92448. * (Default is Color3(0.2, 0.2, 0.3))
  92449. */
  92450. fogColor: Color3;
  92451. /**
  92452. * Gets or sets the fog density to use
  92453. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92454. * (Default is 0.1)
  92455. */
  92456. fogDensity: number;
  92457. /**
  92458. * Gets or sets the fog start distance to use
  92459. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92460. * (Default is 0)
  92461. */
  92462. fogStart: number;
  92463. /**
  92464. * Gets or sets the fog end distance to use
  92465. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92466. * (Default is 1000)
  92467. */
  92468. fogEnd: number;
  92469. private _shadowsEnabled;
  92470. /**
  92471. * Gets or sets a boolean indicating if shadows are enabled on this scene
  92472. */
  92473. shadowsEnabled: boolean;
  92474. private _lightsEnabled;
  92475. /**
  92476. * Gets or sets a boolean indicating if lights are enabled on this scene
  92477. */
  92478. lightsEnabled: boolean;
  92479. /** All of the active cameras added to this scene. */
  92480. activeCameras: Camera[];
  92481. /** @hidden */
  92482. _activeCamera: Nullable<Camera>;
  92483. /** Gets or sets the current active camera */
  92484. activeCamera: Nullable<Camera>;
  92485. private _defaultMaterial;
  92486. /** The default material used on meshes when no material is affected */
  92487. /** The default material used on meshes when no material is affected */
  92488. defaultMaterial: Material;
  92489. private _texturesEnabled;
  92490. /**
  92491. * Gets or sets a boolean indicating if textures are enabled on this scene
  92492. */
  92493. texturesEnabled: boolean;
  92494. /**
  92495. * Gets or sets a boolean indicating if particles are enabled on this scene
  92496. */
  92497. particlesEnabled: boolean;
  92498. /**
  92499. * Gets or sets a boolean indicating if sprites are enabled on this scene
  92500. */
  92501. spritesEnabled: boolean;
  92502. private _skeletonsEnabled;
  92503. /**
  92504. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  92505. */
  92506. skeletonsEnabled: boolean;
  92507. /**
  92508. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  92509. */
  92510. lensFlaresEnabled: boolean;
  92511. /**
  92512. * Gets or sets a boolean indicating if collisions are enabled on this scene
  92513. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92514. */
  92515. collisionsEnabled: boolean;
  92516. private _collisionCoordinator;
  92517. /** @hidden */
  92518. readonly collisionCoordinator: ICollisionCoordinator;
  92519. /**
  92520. * Defines the gravity applied to this scene (used only for collisions)
  92521. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92522. */
  92523. gravity: Vector3;
  92524. /**
  92525. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  92526. */
  92527. postProcessesEnabled: boolean;
  92528. /**
  92529. * The list of postprocesses added to the scene
  92530. */
  92531. postProcesses: PostProcess[];
  92532. /**
  92533. * Gets the current postprocess manager
  92534. */
  92535. postProcessManager: PostProcessManager;
  92536. /**
  92537. * Gets or sets a boolean indicating if render targets are enabled on this scene
  92538. */
  92539. renderTargetsEnabled: boolean;
  92540. /**
  92541. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  92542. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  92543. */
  92544. dumpNextRenderTargets: boolean;
  92545. /**
  92546. * The list of user defined render targets added to the scene
  92547. */
  92548. customRenderTargets: RenderTargetTexture[];
  92549. /**
  92550. * Defines if texture loading must be delayed
  92551. * If true, textures will only be loaded when they need to be rendered
  92552. */
  92553. useDelayedTextureLoading: boolean;
  92554. /**
  92555. * Gets the list of meshes imported to the scene through SceneLoader
  92556. */
  92557. importedMeshesFiles: String[];
  92558. /**
  92559. * Gets or sets a boolean indicating if probes are enabled on this scene
  92560. */
  92561. probesEnabled: boolean;
  92562. /**
  92563. * Gets or sets the current offline provider to use to store scene data
  92564. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  92565. */
  92566. offlineProvider: IOfflineProvider;
  92567. /**
  92568. * Gets or sets the action manager associated with the scene
  92569. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92570. */
  92571. actionManager: AbstractActionManager;
  92572. private _meshesForIntersections;
  92573. /**
  92574. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  92575. */
  92576. proceduralTexturesEnabled: boolean;
  92577. private _engine;
  92578. private _totalVertices;
  92579. /** @hidden */
  92580. _activeIndices: PerfCounter;
  92581. /** @hidden */
  92582. _activeParticles: PerfCounter;
  92583. /** @hidden */
  92584. _activeBones: PerfCounter;
  92585. private _animationRatio;
  92586. /** @hidden */
  92587. _animationTimeLast: number;
  92588. /** @hidden */
  92589. _animationTime: number;
  92590. /**
  92591. * Gets or sets a general scale for animation speed
  92592. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  92593. */
  92594. animationTimeScale: number;
  92595. /** @hidden */
  92596. _cachedMaterial: Nullable<Material>;
  92597. /** @hidden */
  92598. _cachedEffect: Nullable<Effect>;
  92599. /** @hidden */
  92600. _cachedVisibility: Nullable<number>;
  92601. private _renderId;
  92602. private _frameId;
  92603. private _executeWhenReadyTimeoutId;
  92604. private _intermediateRendering;
  92605. private _viewUpdateFlag;
  92606. private _projectionUpdateFlag;
  92607. /** @hidden */
  92608. _toBeDisposed: Nullable<IDisposable>[];
  92609. private _activeRequests;
  92610. /** @hidden */
  92611. _pendingData: any[];
  92612. private _isDisposed;
  92613. /**
  92614. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  92615. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  92616. */
  92617. dispatchAllSubMeshesOfActiveMeshes: boolean;
  92618. private _activeMeshes;
  92619. private _processedMaterials;
  92620. private _renderTargets;
  92621. /** @hidden */
  92622. _activeParticleSystems: SmartArray<IParticleSystem>;
  92623. private _activeSkeletons;
  92624. private _softwareSkinnedMeshes;
  92625. private _renderingManager;
  92626. /** @hidden */
  92627. _activeAnimatables: Animatable[];
  92628. private _transformMatrix;
  92629. private _sceneUbo;
  92630. /** @hidden */
  92631. _viewMatrix: Matrix;
  92632. private _projectionMatrix;
  92633. /** @hidden */
  92634. _forcedViewPosition: Nullable<Vector3>;
  92635. /** @hidden */
  92636. _frustumPlanes: Plane[];
  92637. /**
  92638. * Gets the list of frustum planes (built from the active camera)
  92639. */
  92640. readonly frustumPlanes: Plane[];
  92641. /**
  92642. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  92643. * This is useful if there are more lights that the maximum simulteanous authorized
  92644. */
  92645. requireLightSorting: boolean;
  92646. /** @hidden */
  92647. readonly useMaterialMeshMap: boolean;
  92648. /** @hidden */
  92649. readonly useClonedMeshhMap: boolean;
  92650. private _externalData;
  92651. private _uid;
  92652. /**
  92653. * @hidden
  92654. * Backing store of defined scene components.
  92655. */
  92656. _components: ISceneComponent[];
  92657. /**
  92658. * @hidden
  92659. * Backing store of defined scene components.
  92660. */
  92661. _serializableComponents: ISceneSerializableComponent[];
  92662. /**
  92663. * List of components to register on the next registration step.
  92664. */
  92665. private _transientComponents;
  92666. /**
  92667. * Registers the transient components if needed.
  92668. */
  92669. private _registerTransientComponents;
  92670. /**
  92671. * @hidden
  92672. * Add a component to the scene.
  92673. * Note that the ccomponent could be registered on th next frame if this is called after
  92674. * the register component stage.
  92675. * @param component Defines the component to add to the scene
  92676. */
  92677. _addComponent(component: ISceneComponent): void;
  92678. /**
  92679. * @hidden
  92680. * Gets a component from the scene.
  92681. * @param name defines the name of the component to retrieve
  92682. * @returns the component or null if not present
  92683. */
  92684. _getComponent(name: string): Nullable<ISceneComponent>;
  92685. /**
  92686. * @hidden
  92687. * Defines the actions happening before camera updates.
  92688. */
  92689. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  92690. /**
  92691. * @hidden
  92692. * Defines the actions happening before clear the canvas.
  92693. */
  92694. _beforeClearStage: Stage<SimpleStageAction>;
  92695. /**
  92696. * @hidden
  92697. * Defines the actions when collecting render targets for the frame.
  92698. */
  92699. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92700. /**
  92701. * @hidden
  92702. * Defines the actions happening for one camera in the frame.
  92703. */
  92704. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92705. /**
  92706. * @hidden
  92707. * Defines the actions happening during the per mesh ready checks.
  92708. */
  92709. _isReadyForMeshStage: Stage<MeshStageAction>;
  92710. /**
  92711. * @hidden
  92712. * Defines the actions happening before evaluate active mesh checks.
  92713. */
  92714. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  92715. /**
  92716. * @hidden
  92717. * Defines the actions happening during the evaluate sub mesh checks.
  92718. */
  92719. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  92720. /**
  92721. * @hidden
  92722. * Defines the actions happening during the active mesh stage.
  92723. */
  92724. _activeMeshStage: Stage<ActiveMeshStageAction>;
  92725. /**
  92726. * @hidden
  92727. * Defines the actions happening during the per camera render target step.
  92728. */
  92729. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  92730. /**
  92731. * @hidden
  92732. * Defines the actions happening just before the active camera is drawing.
  92733. */
  92734. _beforeCameraDrawStage: Stage<CameraStageAction>;
  92735. /**
  92736. * @hidden
  92737. * Defines the actions happening just before a render target is drawing.
  92738. */
  92739. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92740. /**
  92741. * @hidden
  92742. * Defines the actions happening just before a rendering group is drawing.
  92743. */
  92744. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92745. /**
  92746. * @hidden
  92747. * Defines the actions happening just before a mesh is drawing.
  92748. */
  92749. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92750. /**
  92751. * @hidden
  92752. * Defines the actions happening just after a mesh has been drawn.
  92753. */
  92754. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92755. /**
  92756. * @hidden
  92757. * Defines the actions happening just after a rendering group has been drawn.
  92758. */
  92759. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92760. /**
  92761. * @hidden
  92762. * Defines the actions happening just after the active camera has been drawn.
  92763. */
  92764. _afterCameraDrawStage: Stage<CameraStageAction>;
  92765. /**
  92766. * @hidden
  92767. * Defines the actions happening just after a render target has been drawn.
  92768. */
  92769. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92770. /**
  92771. * @hidden
  92772. * Defines the actions happening just after rendering all cameras and computing intersections.
  92773. */
  92774. _afterRenderStage: Stage<SimpleStageAction>;
  92775. /**
  92776. * @hidden
  92777. * Defines the actions happening when a pointer move event happens.
  92778. */
  92779. _pointerMoveStage: Stage<PointerMoveStageAction>;
  92780. /**
  92781. * @hidden
  92782. * Defines the actions happening when a pointer down event happens.
  92783. */
  92784. _pointerDownStage: Stage<PointerUpDownStageAction>;
  92785. /**
  92786. * @hidden
  92787. * Defines the actions happening when a pointer up event happens.
  92788. */
  92789. _pointerUpStage: Stage<PointerUpDownStageAction>;
  92790. /**
  92791. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  92792. */
  92793. private geometriesByUniqueId;
  92794. /**
  92795. * Creates a new Scene
  92796. * @param engine defines the engine to use to render this scene
  92797. * @param options defines the scene options
  92798. */
  92799. constructor(engine: Engine, options?: SceneOptions);
  92800. /**
  92801. * Gets a string idenfifying the name of the class
  92802. * @returns "Scene" string
  92803. */
  92804. getClassName(): string;
  92805. private _defaultMeshCandidates;
  92806. /**
  92807. * @hidden
  92808. */
  92809. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  92810. private _defaultSubMeshCandidates;
  92811. /**
  92812. * @hidden
  92813. */
  92814. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  92815. /**
  92816. * Sets the default candidate providers for the scene.
  92817. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  92818. * and getCollidingSubMeshCandidates to their default function
  92819. */
  92820. setDefaultCandidateProviders(): void;
  92821. /**
  92822. * Gets the mesh that is currently under the pointer
  92823. */
  92824. readonly meshUnderPointer: Nullable<AbstractMesh>;
  92825. /**
  92826. * Gets or sets the current on-screen X position of the pointer
  92827. */
  92828. pointerX: number;
  92829. /**
  92830. * Gets or sets the current on-screen Y position of the pointer
  92831. */
  92832. pointerY: number;
  92833. /**
  92834. * Gets the cached material (ie. the latest rendered one)
  92835. * @returns the cached material
  92836. */
  92837. getCachedMaterial(): Nullable<Material>;
  92838. /**
  92839. * Gets the cached effect (ie. the latest rendered one)
  92840. * @returns the cached effect
  92841. */
  92842. getCachedEffect(): Nullable<Effect>;
  92843. /**
  92844. * Gets the cached visibility state (ie. the latest rendered one)
  92845. * @returns the cached visibility state
  92846. */
  92847. getCachedVisibility(): Nullable<number>;
  92848. /**
  92849. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  92850. * @param material defines the current material
  92851. * @param effect defines the current effect
  92852. * @param visibility defines the current visibility state
  92853. * @returns true if one parameter is not cached
  92854. */
  92855. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  92856. /**
  92857. * Gets the engine associated with the scene
  92858. * @returns an Engine
  92859. */
  92860. getEngine(): Engine;
  92861. /**
  92862. * Gets the total number of vertices rendered per frame
  92863. * @returns the total number of vertices rendered per frame
  92864. */
  92865. getTotalVertices(): number;
  92866. /**
  92867. * Gets the performance counter for total vertices
  92868. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92869. */
  92870. readonly totalVerticesPerfCounter: PerfCounter;
  92871. /**
  92872. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  92873. * @returns the total number of active indices rendered per frame
  92874. */
  92875. getActiveIndices(): number;
  92876. /**
  92877. * Gets the performance counter for active indices
  92878. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92879. */
  92880. readonly totalActiveIndicesPerfCounter: PerfCounter;
  92881. /**
  92882. * Gets the total number of active particles rendered per frame
  92883. * @returns the total number of active particles rendered per frame
  92884. */
  92885. getActiveParticles(): number;
  92886. /**
  92887. * Gets the performance counter for active particles
  92888. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92889. */
  92890. readonly activeParticlesPerfCounter: PerfCounter;
  92891. /**
  92892. * Gets the total number of active bones rendered per frame
  92893. * @returns the total number of active bones rendered per frame
  92894. */
  92895. getActiveBones(): number;
  92896. /**
  92897. * Gets the performance counter for active bones
  92898. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92899. */
  92900. readonly activeBonesPerfCounter: PerfCounter;
  92901. /**
  92902. * Gets the array of active meshes
  92903. * @returns an array of AbstractMesh
  92904. */
  92905. getActiveMeshes(): SmartArray<AbstractMesh>;
  92906. /**
  92907. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  92908. * @returns a number
  92909. */
  92910. getAnimationRatio(): number;
  92911. /**
  92912. * Gets an unique Id for the current render phase
  92913. * @returns a number
  92914. */
  92915. getRenderId(): number;
  92916. /**
  92917. * Gets an unique Id for the current frame
  92918. * @returns a number
  92919. */
  92920. getFrameId(): number;
  92921. /** Call this function if you want to manually increment the render Id*/
  92922. incrementRenderId(): void;
  92923. private _createUbo;
  92924. /**
  92925. * Use this method to simulate a pointer move on a mesh
  92926. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92927. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92928. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92929. * @returns the current scene
  92930. */
  92931. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92932. /**
  92933. * Use this method to simulate a pointer down on a mesh
  92934. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92935. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92936. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92937. * @returns the current scene
  92938. */
  92939. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92940. /**
  92941. * Use this method to simulate a pointer up on a mesh
  92942. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92943. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92944. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92945. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  92946. * @returns the current scene
  92947. */
  92948. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  92949. /**
  92950. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  92951. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92952. * @returns true if the pointer was captured
  92953. */
  92954. isPointerCaptured(pointerId?: number): boolean;
  92955. /**
  92956. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92957. * @param attachUp defines if you want to attach events to pointerup
  92958. * @param attachDown defines if you want to attach events to pointerdown
  92959. * @param attachMove defines if you want to attach events to pointermove
  92960. */
  92961. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92962. /** Detaches all event handlers*/
  92963. detachControl(): void;
  92964. /**
  92965. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92966. * Delay loaded resources are not taking in account
  92967. * @return true if all required resources are ready
  92968. */
  92969. isReady(): boolean;
  92970. /** Resets all cached information relative to material (including effect and visibility) */
  92971. resetCachedMaterial(): void;
  92972. /**
  92973. * Registers a function to be called before every frame render
  92974. * @param func defines the function to register
  92975. */
  92976. registerBeforeRender(func: () => void): void;
  92977. /**
  92978. * Unregisters a function called before every frame render
  92979. * @param func defines the function to unregister
  92980. */
  92981. unregisterBeforeRender(func: () => void): void;
  92982. /**
  92983. * Registers a function to be called after every frame render
  92984. * @param func defines the function to register
  92985. */
  92986. registerAfterRender(func: () => void): void;
  92987. /**
  92988. * Unregisters a function called after every frame render
  92989. * @param func defines the function to unregister
  92990. */
  92991. unregisterAfterRender(func: () => void): void;
  92992. private _executeOnceBeforeRender;
  92993. /**
  92994. * The provided function will run before render once and will be disposed afterwards.
  92995. * A timeout delay can be provided so that the function will be executed in N ms.
  92996. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92997. * @param func The function to be executed.
  92998. * @param timeout optional delay in ms
  92999. */
  93000. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  93001. /** @hidden */
  93002. _addPendingData(data: any): void;
  93003. /** @hidden */
  93004. _removePendingData(data: any): void;
  93005. /**
  93006. * Returns the number of items waiting to be loaded
  93007. * @returns the number of items waiting to be loaded
  93008. */
  93009. getWaitingItemsCount(): number;
  93010. /**
  93011. * Returns a boolean indicating if the scene is still loading data
  93012. */
  93013. readonly isLoading: boolean;
  93014. /**
  93015. * Registers a function to be executed when the scene is ready
  93016. * @param {Function} func - the function to be executed
  93017. */
  93018. executeWhenReady(func: () => void): void;
  93019. /**
  93020. * Returns a promise that resolves when the scene is ready
  93021. * @returns A promise that resolves when the scene is ready
  93022. */
  93023. whenReadyAsync(): Promise<void>;
  93024. /** @hidden */
  93025. _checkIsReady(): void;
  93026. /**
  93027. * Gets all animatable attached to the scene
  93028. */
  93029. readonly animatables: Animatable[];
  93030. /**
  93031. * Resets the last animation time frame.
  93032. * Useful to override when animations start running when loading a scene for the first time.
  93033. */
  93034. resetLastAnimationTimeFrame(): void;
  93035. /**
  93036. * Gets the current view matrix
  93037. * @returns a Matrix
  93038. */
  93039. getViewMatrix(): Matrix;
  93040. /**
  93041. * Gets the current projection matrix
  93042. * @returns a Matrix
  93043. */
  93044. getProjectionMatrix(): Matrix;
  93045. /**
  93046. * Gets the current transform matrix
  93047. * @returns a Matrix made of View * Projection
  93048. */
  93049. getTransformMatrix(): Matrix;
  93050. /**
  93051. * Sets the current transform matrix
  93052. * @param viewL defines the View matrix to use
  93053. * @param projectionL defines the Projection matrix to use
  93054. * @param viewR defines the right View matrix to use (if provided)
  93055. * @param projectionR defines the right Projection matrix to use (if provided)
  93056. */
  93057. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  93058. /**
  93059. * Gets the uniform buffer used to store scene data
  93060. * @returns a UniformBuffer
  93061. */
  93062. getSceneUniformBuffer(): UniformBuffer;
  93063. /**
  93064. * Gets an unique (relatively to the current scene) Id
  93065. * @returns an unique number for the scene
  93066. */
  93067. getUniqueId(): number;
  93068. /**
  93069. * Add a mesh to the list of scene's meshes
  93070. * @param newMesh defines the mesh to add
  93071. * @param recursive if all child meshes should also be added to the scene
  93072. */
  93073. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  93074. /**
  93075. * Remove a mesh for the list of scene's meshes
  93076. * @param toRemove defines the mesh to remove
  93077. * @param recursive if all child meshes should also be removed from the scene
  93078. * @returns the index where the mesh was in the mesh list
  93079. */
  93080. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  93081. /**
  93082. * Add a transform node to the list of scene's transform nodes
  93083. * @param newTransformNode defines the transform node to add
  93084. */
  93085. addTransformNode(newTransformNode: TransformNode): void;
  93086. /**
  93087. * Remove a transform node for the list of scene's transform nodes
  93088. * @param toRemove defines the transform node to remove
  93089. * @returns the index where the transform node was in the transform node list
  93090. */
  93091. removeTransformNode(toRemove: TransformNode): number;
  93092. /**
  93093. * Remove a skeleton for the list of scene's skeletons
  93094. * @param toRemove defines the skeleton to remove
  93095. * @returns the index where the skeleton was in the skeleton list
  93096. */
  93097. removeSkeleton(toRemove: Skeleton): number;
  93098. /**
  93099. * Remove a morph target for the list of scene's morph targets
  93100. * @param toRemove defines the morph target to remove
  93101. * @returns the index where the morph target was in the morph target list
  93102. */
  93103. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  93104. /**
  93105. * Remove a light for the list of scene's lights
  93106. * @param toRemove defines the light to remove
  93107. * @returns the index where the light was in the light list
  93108. */
  93109. removeLight(toRemove: Light): number;
  93110. /**
  93111. * Remove a camera for the list of scene's cameras
  93112. * @param toRemove defines the camera to remove
  93113. * @returns the index where the camera was in the camera list
  93114. */
  93115. removeCamera(toRemove: Camera): number;
  93116. /**
  93117. * Remove a particle system for the list of scene's particle systems
  93118. * @param toRemove defines the particle system to remove
  93119. * @returns the index where the particle system was in the particle system list
  93120. */
  93121. removeParticleSystem(toRemove: IParticleSystem): number;
  93122. /**
  93123. * Remove a animation for the list of scene's animations
  93124. * @param toRemove defines the animation to remove
  93125. * @returns the index where the animation was in the animation list
  93126. */
  93127. removeAnimation(toRemove: Animation): number;
  93128. /**
  93129. * Will stop the animation of the given target
  93130. * @param target - the target
  93131. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  93132. * @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)
  93133. */
  93134. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  93135. /**
  93136. * Removes the given animation group from this scene.
  93137. * @param toRemove The animation group to remove
  93138. * @returns The index of the removed animation group
  93139. */
  93140. removeAnimationGroup(toRemove: AnimationGroup): number;
  93141. /**
  93142. * Removes the given multi-material from this scene.
  93143. * @param toRemove The multi-material to remove
  93144. * @returns The index of the removed multi-material
  93145. */
  93146. removeMultiMaterial(toRemove: MultiMaterial): number;
  93147. /**
  93148. * Removes the given material from this scene.
  93149. * @param toRemove The material to remove
  93150. * @returns The index of the removed material
  93151. */
  93152. removeMaterial(toRemove: Material): number;
  93153. /**
  93154. * Removes the given action manager from this scene.
  93155. * @param toRemove The action manager to remove
  93156. * @returns The index of the removed action manager
  93157. */
  93158. removeActionManager(toRemove: AbstractActionManager): number;
  93159. /**
  93160. * Removes the given texture from this scene.
  93161. * @param toRemove The texture to remove
  93162. * @returns The index of the removed texture
  93163. */
  93164. removeTexture(toRemove: BaseTexture): number;
  93165. /**
  93166. * Adds the given light to this scene
  93167. * @param newLight The light to add
  93168. */
  93169. addLight(newLight: Light): void;
  93170. /**
  93171. * Sorts the list list based on light priorities
  93172. */
  93173. sortLightsByPriority(): void;
  93174. /**
  93175. * Adds the given camera to this scene
  93176. * @param newCamera The camera to add
  93177. */
  93178. addCamera(newCamera: Camera): void;
  93179. /**
  93180. * Adds the given skeleton to this scene
  93181. * @param newSkeleton The skeleton to add
  93182. */
  93183. addSkeleton(newSkeleton: Skeleton): void;
  93184. /**
  93185. * Adds the given particle system to this scene
  93186. * @param newParticleSystem The particle system to add
  93187. */
  93188. addParticleSystem(newParticleSystem: IParticleSystem): void;
  93189. /**
  93190. * Adds the given animation to this scene
  93191. * @param newAnimation The animation to add
  93192. */
  93193. addAnimation(newAnimation: Animation): void;
  93194. /**
  93195. * Adds the given animation group to this scene.
  93196. * @param newAnimationGroup The animation group to add
  93197. */
  93198. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  93199. /**
  93200. * Adds the given multi-material to this scene
  93201. * @param newMultiMaterial The multi-material to add
  93202. */
  93203. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  93204. /**
  93205. * Adds the given material to this scene
  93206. * @param newMaterial The material to add
  93207. */
  93208. addMaterial(newMaterial: Material): void;
  93209. /**
  93210. * Adds the given morph target to this scene
  93211. * @param newMorphTargetManager The morph target to add
  93212. */
  93213. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  93214. /**
  93215. * Adds the given geometry to this scene
  93216. * @param newGeometry The geometry to add
  93217. */
  93218. addGeometry(newGeometry: Geometry): void;
  93219. /**
  93220. * Adds the given action manager to this scene
  93221. * @param newActionManager The action manager to add
  93222. */
  93223. addActionManager(newActionManager: AbstractActionManager): void;
  93224. /**
  93225. * Adds the given texture to this scene.
  93226. * @param newTexture The texture to add
  93227. */
  93228. addTexture(newTexture: BaseTexture): void;
  93229. /**
  93230. * Switch active camera
  93231. * @param newCamera defines the new active camera
  93232. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  93233. */
  93234. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  93235. /**
  93236. * sets the active camera of the scene using its ID
  93237. * @param id defines the camera's ID
  93238. * @return the new active camera or null if none found.
  93239. */
  93240. setActiveCameraByID(id: string): Nullable<Camera>;
  93241. /**
  93242. * sets the active camera of the scene using its name
  93243. * @param name defines the camera's name
  93244. * @returns the new active camera or null if none found.
  93245. */
  93246. setActiveCameraByName(name: string): Nullable<Camera>;
  93247. /**
  93248. * get an animation group using its name
  93249. * @param name defines the material's name
  93250. * @return the animation group or null if none found.
  93251. */
  93252. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  93253. /**
  93254. * Get a material using its unique id
  93255. * @param uniqueId defines the material's unique id
  93256. * @return the material or null if none found.
  93257. */
  93258. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  93259. /**
  93260. * get a material using its id
  93261. * @param id defines the material's ID
  93262. * @return the material or null if none found.
  93263. */
  93264. getMaterialByID(id: string): Nullable<Material>;
  93265. /**
  93266. * Gets a material using its name
  93267. * @param name defines the material's name
  93268. * @return the material or null if none found.
  93269. */
  93270. getMaterialByName(name: string): Nullable<Material>;
  93271. /**
  93272. * Gets a camera using its id
  93273. * @param id defines the id to look for
  93274. * @returns the camera or null if not found
  93275. */
  93276. getCameraByID(id: string): Nullable<Camera>;
  93277. /**
  93278. * Gets a camera using its unique id
  93279. * @param uniqueId defines the unique id to look for
  93280. * @returns the camera or null if not found
  93281. */
  93282. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  93283. /**
  93284. * Gets a camera using its name
  93285. * @param name defines the camera's name
  93286. * @return the camera or null if none found.
  93287. */
  93288. getCameraByName(name: string): Nullable<Camera>;
  93289. /**
  93290. * Gets a bone using its id
  93291. * @param id defines the bone's id
  93292. * @return the bone or null if not found
  93293. */
  93294. getBoneByID(id: string): Nullable<Bone>;
  93295. /**
  93296. * Gets a bone using its id
  93297. * @param name defines the bone's name
  93298. * @return the bone or null if not found
  93299. */
  93300. getBoneByName(name: string): Nullable<Bone>;
  93301. /**
  93302. * Gets a light node using its name
  93303. * @param name defines the the light's name
  93304. * @return the light or null if none found.
  93305. */
  93306. getLightByName(name: string): Nullable<Light>;
  93307. /**
  93308. * Gets a light node using its id
  93309. * @param id defines the light's id
  93310. * @return the light or null if none found.
  93311. */
  93312. getLightByID(id: string): Nullable<Light>;
  93313. /**
  93314. * Gets a light node using its scene-generated unique ID
  93315. * @param uniqueId defines the light's unique id
  93316. * @return the light or null if none found.
  93317. */
  93318. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  93319. /**
  93320. * Gets a particle system by id
  93321. * @param id defines the particle system id
  93322. * @return the corresponding system or null if none found
  93323. */
  93324. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  93325. /**
  93326. * Gets a geometry using its ID
  93327. * @param id defines the geometry's id
  93328. * @return the geometry or null if none found.
  93329. */
  93330. getGeometryByID(id: string): Nullable<Geometry>;
  93331. private _getGeometryByUniqueID;
  93332. /**
  93333. * Add a new geometry to this scene
  93334. * @param geometry defines the geometry to be added to the scene.
  93335. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  93336. * @return a boolean defining if the geometry was added or not
  93337. */
  93338. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  93339. /**
  93340. * Removes an existing geometry
  93341. * @param geometry defines the geometry to be removed from the scene
  93342. * @return a boolean defining if the geometry was removed or not
  93343. */
  93344. removeGeometry(geometry: Geometry): boolean;
  93345. /**
  93346. * Gets the list of geometries attached to the scene
  93347. * @returns an array of Geometry
  93348. */
  93349. getGeometries(): Geometry[];
  93350. /**
  93351. * Gets the first added mesh found of a given ID
  93352. * @param id defines the id to search for
  93353. * @return the mesh found or null if not found at all
  93354. */
  93355. getMeshByID(id: string): Nullable<AbstractMesh>;
  93356. /**
  93357. * Gets a list of meshes using their id
  93358. * @param id defines the id to search for
  93359. * @returns a list of meshes
  93360. */
  93361. getMeshesByID(id: string): Array<AbstractMesh>;
  93362. /**
  93363. * Gets the first added transform node found of a given ID
  93364. * @param id defines the id to search for
  93365. * @return the found transform node or null if not found at all.
  93366. */
  93367. getTransformNodeByID(id: string): Nullable<TransformNode>;
  93368. /**
  93369. * Gets a transform node with its auto-generated unique id
  93370. * @param uniqueId efines the unique id to search for
  93371. * @return the found transform node or null if not found at all.
  93372. */
  93373. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  93374. /**
  93375. * Gets a list of transform nodes using their id
  93376. * @param id defines the id to search for
  93377. * @returns a list of transform nodes
  93378. */
  93379. getTransformNodesByID(id: string): Array<TransformNode>;
  93380. /**
  93381. * Gets a mesh with its auto-generated unique id
  93382. * @param uniqueId defines the unique id to search for
  93383. * @return the found mesh or null if not found at all.
  93384. */
  93385. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  93386. /**
  93387. * Gets a the last added mesh using a given id
  93388. * @param id defines the id to search for
  93389. * @return the found mesh or null if not found at all.
  93390. */
  93391. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  93392. /**
  93393. * Gets a the last added node (Mesh, Camera, Light) using a given id
  93394. * @param id defines the id to search for
  93395. * @return the found node or null if not found at all
  93396. */
  93397. getLastEntryByID(id: string): Nullable<Node>;
  93398. /**
  93399. * Gets a node (Mesh, Camera, Light) using a given id
  93400. * @param id defines the id to search for
  93401. * @return the found node or null if not found at all
  93402. */
  93403. getNodeByID(id: string): Nullable<Node>;
  93404. /**
  93405. * Gets a node (Mesh, Camera, Light) using a given name
  93406. * @param name defines the name to search for
  93407. * @return the found node or null if not found at all.
  93408. */
  93409. getNodeByName(name: string): Nullable<Node>;
  93410. /**
  93411. * Gets a mesh using a given name
  93412. * @param name defines the name to search for
  93413. * @return the found mesh or null if not found at all.
  93414. */
  93415. getMeshByName(name: string): Nullable<AbstractMesh>;
  93416. /**
  93417. * Gets a transform node using a given name
  93418. * @param name defines the name to search for
  93419. * @return the found transform node or null if not found at all.
  93420. */
  93421. getTransformNodeByName(name: string): Nullable<TransformNode>;
  93422. /**
  93423. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  93424. * @param id defines the id to search for
  93425. * @return the found skeleton or null if not found at all.
  93426. */
  93427. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  93428. /**
  93429. * Gets a skeleton using a given auto generated unique id
  93430. * @param uniqueId defines the unique id to search for
  93431. * @return the found skeleton or null if not found at all.
  93432. */
  93433. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  93434. /**
  93435. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  93436. * @param id defines the id to search for
  93437. * @return the found skeleton or null if not found at all.
  93438. */
  93439. getSkeletonById(id: string): Nullable<Skeleton>;
  93440. /**
  93441. * Gets a skeleton using a given name
  93442. * @param name defines the name to search for
  93443. * @return the found skeleton or null if not found at all.
  93444. */
  93445. getSkeletonByName(name: string): Nullable<Skeleton>;
  93446. /**
  93447. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  93448. * @param id defines the id to search for
  93449. * @return the found morph target manager or null if not found at all.
  93450. */
  93451. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  93452. /**
  93453. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  93454. * @param id defines the id to search for
  93455. * @return the found morph target or null if not found at all.
  93456. */
  93457. getMorphTargetById(id: string): Nullable<MorphTarget>;
  93458. /**
  93459. * Gets a boolean indicating if the given mesh is active
  93460. * @param mesh defines the mesh to look for
  93461. * @returns true if the mesh is in the active list
  93462. */
  93463. isActiveMesh(mesh: AbstractMesh): boolean;
  93464. /**
  93465. * Return a unique id as a string which can serve as an identifier for the scene
  93466. */
  93467. readonly uid: string;
  93468. /**
  93469. * Add an externaly attached data from its key.
  93470. * This method call will fail and return false, if such key already exists.
  93471. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  93472. * @param key the unique key that identifies the data
  93473. * @param data the data object to associate to the key for this Engine instance
  93474. * @return true if no such key were already present and the data was added successfully, false otherwise
  93475. */
  93476. addExternalData<T>(key: string, data: T): boolean;
  93477. /**
  93478. * Get an externaly attached data from its key
  93479. * @param key the unique key that identifies the data
  93480. * @return the associated data, if present (can be null), or undefined if not present
  93481. */
  93482. getExternalData<T>(key: string): Nullable<T>;
  93483. /**
  93484. * Get an externaly attached data from its key, create it using a factory if it's not already present
  93485. * @param key the unique key that identifies the data
  93486. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  93487. * @return the associated data, can be null if the factory returned null.
  93488. */
  93489. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  93490. /**
  93491. * Remove an externaly attached data from the Engine instance
  93492. * @param key the unique key that identifies the data
  93493. * @return true if the data was successfully removed, false if it doesn't exist
  93494. */
  93495. removeExternalData(key: string): boolean;
  93496. private _evaluateSubMesh;
  93497. /**
  93498. * Clear the processed materials smart array preventing retention point in material dispose.
  93499. */
  93500. freeProcessedMaterials(): void;
  93501. private _preventFreeActiveMeshesAndRenderingGroups;
  93502. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  93503. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  93504. * when disposing several meshes in a row or a hierarchy of meshes.
  93505. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  93506. */
  93507. blockfreeActiveMeshesAndRenderingGroups: boolean;
  93508. /**
  93509. * Clear the active meshes smart array preventing retention point in mesh dispose.
  93510. */
  93511. freeActiveMeshes(): void;
  93512. /**
  93513. * Clear the info related to rendering groups preventing retention points during dispose.
  93514. */
  93515. freeRenderingGroups(): void;
  93516. /** @hidden */
  93517. _isInIntermediateRendering(): boolean;
  93518. /**
  93519. * Lambda returning the list of potentially active meshes.
  93520. */
  93521. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  93522. /**
  93523. * Lambda returning the list of potentially active sub meshes.
  93524. */
  93525. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  93526. /**
  93527. * Lambda returning the list of potentially intersecting sub meshes.
  93528. */
  93529. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  93530. /**
  93531. * Lambda returning the list of potentially colliding sub meshes.
  93532. */
  93533. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  93534. private _activeMeshesFrozen;
  93535. /**
  93536. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  93537. * @returns the current scene
  93538. */
  93539. freezeActiveMeshes(): Scene;
  93540. /**
  93541. * Use this function to restart evaluating active meshes on every frame
  93542. * @returns the current scene
  93543. */
  93544. unfreezeActiveMeshes(): Scene;
  93545. private _evaluateActiveMeshes;
  93546. private _activeMesh;
  93547. /**
  93548. * Update the transform matrix to update from the current active camera
  93549. * @param force defines a boolean used to force the update even if cache is up to date
  93550. */
  93551. updateTransformMatrix(force?: boolean): void;
  93552. private _bindFrameBuffer;
  93553. /** @hidden */
  93554. _allowPostProcessClearColor: boolean;
  93555. /** @hidden */
  93556. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  93557. private _processSubCameras;
  93558. private _checkIntersections;
  93559. /** @hidden */
  93560. _advancePhysicsEngineStep(step: number): void;
  93561. /**
  93562. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  93563. */
  93564. getDeterministicFrameTime: () => number;
  93565. /** @hidden */
  93566. _animate(): void;
  93567. /** Execute all animations (for a frame) */
  93568. animate(): void;
  93569. /**
  93570. * Render the scene
  93571. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  93572. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  93573. */
  93574. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  93575. /**
  93576. * Freeze all materials
  93577. * A frozen material will not be updatable but should be faster to render
  93578. */
  93579. freezeMaterials(): void;
  93580. /**
  93581. * Unfreeze all materials
  93582. * A frozen material will not be updatable but should be faster to render
  93583. */
  93584. unfreezeMaterials(): void;
  93585. /**
  93586. * Releases all held ressources
  93587. */
  93588. dispose(): void;
  93589. /**
  93590. * Gets if the scene is already disposed
  93591. */
  93592. readonly isDisposed: boolean;
  93593. /**
  93594. * Call this function to reduce memory footprint of the scene.
  93595. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  93596. */
  93597. clearCachedVertexData(): void;
  93598. /**
  93599. * This function will remove the local cached buffer data from texture.
  93600. * It will save memory but will prevent the texture from being rebuilt
  93601. */
  93602. cleanCachedTextureBuffer(): void;
  93603. /**
  93604. * Get the world extend vectors with an optional filter
  93605. *
  93606. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  93607. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  93608. */
  93609. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  93610. min: Vector3;
  93611. max: Vector3;
  93612. };
  93613. /**
  93614. * Creates a ray that can be used to pick in the scene
  93615. * @param x defines the x coordinate of the origin (on-screen)
  93616. * @param y defines the y coordinate of the origin (on-screen)
  93617. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93618. * @param camera defines the camera to use for the picking
  93619. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93620. * @returns a Ray
  93621. */
  93622. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  93623. /**
  93624. * Creates a ray that can be used to pick in the scene
  93625. * @param x defines the x coordinate of the origin (on-screen)
  93626. * @param y defines the y coordinate of the origin (on-screen)
  93627. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93628. * @param result defines the ray where to store the picking ray
  93629. * @param camera defines the camera to use for the picking
  93630. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93631. * @returns the current scene
  93632. */
  93633. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  93634. /**
  93635. * Creates a ray that can be used to pick in the scene
  93636. * @param x defines the x coordinate of the origin (on-screen)
  93637. * @param y defines the y coordinate of the origin (on-screen)
  93638. * @param camera defines the camera to use for the picking
  93639. * @returns a Ray
  93640. */
  93641. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  93642. /**
  93643. * Creates a ray that can be used to pick in the scene
  93644. * @param x defines the x coordinate of the origin (on-screen)
  93645. * @param y defines the y coordinate of the origin (on-screen)
  93646. * @param result defines the ray where to store the picking ray
  93647. * @param camera defines the camera to use for the picking
  93648. * @returns the current scene
  93649. */
  93650. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  93651. /** Launch a ray to try to pick a mesh in the scene
  93652. * @param x position on screen
  93653. * @param y position on screen
  93654. * @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
  93655. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  93656. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93657. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93658. * @returns a PickingInfo
  93659. */
  93660. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  93661. /** Use the given ray to pick a mesh in the scene
  93662. * @param ray The ray to use to pick meshes
  93663. * @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
  93664. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  93665. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93666. * @returns a PickingInfo
  93667. */
  93668. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  93669. /**
  93670. * Launch a ray to try to pick a mesh in the scene
  93671. * @param x X position on screen
  93672. * @param y Y position on screen
  93673. * @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
  93674. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93675. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93676. * @returns an array of PickingInfo
  93677. */
  93678. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93679. /**
  93680. * Launch a ray to try to pick a mesh in the scene
  93681. * @param ray Ray to use
  93682. * @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
  93683. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93684. * @returns an array of PickingInfo
  93685. */
  93686. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93687. /**
  93688. * Force the value of meshUnderPointer
  93689. * @param mesh defines the mesh to use
  93690. */
  93691. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  93692. /**
  93693. * Gets the mesh under the pointer
  93694. * @returns a Mesh or null if no mesh is under the pointer
  93695. */
  93696. getPointerOverMesh(): Nullable<AbstractMesh>;
  93697. /** @hidden */
  93698. _rebuildGeometries(): void;
  93699. /** @hidden */
  93700. _rebuildTextures(): void;
  93701. private _getByTags;
  93702. /**
  93703. * Get a list of meshes by tags
  93704. * @param tagsQuery defines the tags query to use
  93705. * @param forEach defines a predicate used to filter results
  93706. * @returns an array of Mesh
  93707. */
  93708. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  93709. /**
  93710. * Get a list of cameras by tags
  93711. * @param tagsQuery defines the tags query to use
  93712. * @param forEach defines a predicate used to filter results
  93713. * @returns an array of Camera
  93714. */
  93715. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  93716. /**
  93717. * Get a list of lights by tags
  93718. * @param tagsQuery defines the tags query to use
  93719. * @param forEach defines a predicate used to filter results
  93720. * @returns an array of Light
  93721. */
  93722. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  93723. /**
  93724. * Get a list of materials by tags
  93725. * @param tagsQuery defines the tags query to use
  93726. * @param forEach defines a predicate used to filter results
  93727. * @returns an array of Material
  93728. */
  93729. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  93730. /**
  93731. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93732. * This allowed control for front to back rendering or reversly depending of the special needs.
  93733. *
  93734. * @param renderingGroupId The rendering group id corresponding to its index
  93735. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93736. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93737. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93738. */
  93739. 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;
  93740. /**
  93741. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93742. *
  93743. * @param renderingGroupId The rendering group id corresponding to its index
  93744. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93745. * @param depth Automatically clears depth between groups if true and autoClear is true.
  93746. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  93747. */
  93748. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  93749. /**
  93750. * Gets the current auto clear configuration for one rendering group of the rendering
  93751. * manager.
  93752. * @param index the rendering group index to get the information for
  93753. * @returns The auto clear setup for the requested rendering group
  93754. */
  93755. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  93756. private _blockMaterialDirtyMechanism;
  93757. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  93758. blockMaterialDirtyMechanism: boolean;
  93759. /**
  93760. * Will flag all materials as dirty to trigger new shader compilation
  93761. * @param flag defines the flag used to specify which material part must be marked as dirty
  93762. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  93763. */
  93764. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93765. /** @hidden */
  93766. _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;
  93767. /** @hidden */
  93768. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  93769. }
  93770. }
  93771. declare module BABYLON {
  93772. /**
  93773. * Set of assets to keep when moving a scene into an asset container.
  93774. */
  93775. export class KeepAssets extends AbstractScene {
  93776. }
  93777. /**
  93778. * Container with a set of assets that can be added or removed from a scene.
  93779. */
  93780. export class AssetContainer extends AbstractScene {
  93781. /**
  93782. * The scene the AssetContainer belongs to.
  93783. */
  93784. scene: Scene;
  93785. /**
  93786. * Instantiates an AssetContainer.
  93787. * @param scene The scene the AssetContainer belongs to.
  93788. */
  93789. constructor(scene: Scene);
  93790. /**
  93791. * Adds all the assets from the container to the scene.
  93792. */
  93793. addAllToScene(): void;
  93794. /**
  93795. * Removes all the assets in the container from the scene
  93796. */
  93797. removeAllFromScene(): void;
  93798. /**
  93799. * Disposes all the assets in the container
  93800. */
  93801. dispose(): void;
  93802. private _moveAssets;
  93803. /**
  93804. * Removes all the assets contained in the scene and adds them to the container.
  93805. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  93806. */
  93807. moveAllFromScene(keepAssets?: KeepAssets): void;
  93808. /**
  93809. * 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.
  93810. * @returns the root mesh
  93811. */
  93812. createRootMesh(): Mesh;
  93813. }
  93814. }
  93815. declare module BABYLON {
  93816. /**
  93817. * Defines how the parser contract is defined.
  93818. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  93819. */
  93820. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  93821. /**
  93822. * Defines how the individual parser contract is defined.
  93823. * These parser can parse an individual asset
  93824. */
  93825. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  93826. /**
  93827. * Base class of the scene acting as a container for the different elements composing a scene.
  93828. * This class is dynamically extended by the different components of the scene increasing
  93829. * flexibility and reducing coupling
  93830. */
  93831. export abstract class AbstractScene {
  93832. /**
  93833. * Stores the list of available parsers in the application.
  93834. */
  93835. private static _BabylonFileParsers;
  93836. /**
  93837. * Stores the list of available individual parsers in the application.
  93838. */
  93839. private static _IndividualBabylonFileParsers;
  93840. /**
  93841. * Adds a parser in the list of available ones
  93842. * @param name Defines the name of the parser
  93843. * @param parser Defines the parser to add
  93844. */
  93845. static AddParser(name: string, parser: BabylonFileParser): void;
  93846. /**
  93847. * Gets a general parser from the list of avaialble ones
  93848. * @param name Defines the name of the parser
  93849. * @returns the requested parser or null
  93850. */
  93851. static GetParser(name: string): Nullable<BabylonFileParser>;
  93852. /**
  93853. * Adds n individual parser in the list of available ones
  93854. * @param name Defines the name of the parser
  93855. * @param parser Defines the parser to add
  93856. */
  93857. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  93858. /**
  93859. * Gets an individual parser from the list of avaialble ones
  93860. * @param name Defines the name of the parser
  93861. * @returns the requested parser or null
  93862. */
  93863. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  93864. /**
  93865. * Parser json data and populate both a scene and its associated container object
  93866. * @param jsonData Defines the data to parse
  93867. * @param scene Defines the scene to parse the data for
  93868. * @param container Defines the container attached to the parsing sequence
  93869. * @param rootUrl Defines the root url of the data
  93870. */
  93871. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  93872. /**
  93873. * Gets the list of root nodes (ie. nodes with no parent)
  93874. */
  93875. rootNodes: Node[];
  93876. /** All of the cameras added to this scene
  93877. * @see http://doc.babylonjs.com/babylon101/cameras
  93878. */
  93879. cameras: Camera[];
  93880. /**
  93881. * All of the lights added to this scene
  93882. * @see http://doc.babylonjs.com/babylon101/lights
  93883. */
  93884. lights: Light[];
  93885. /**
  93886. * All of the (abstract) meshes added to this scene
  93887. */
  93888. meshes: AbstractMesh[];
  93889. /**
  93890. * The list of skeletons added to the scene
  93891. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93892. */
  93893. skeletons: Skeleton[];
  93894. /**
  93895. * All of the particle systems added to this scene
  93896. * @see http://doc.babylonjs.com/babylon101/particles
  93897. */
  93898. particleSystems: IParticleSystem[];
  93899. /**
  93900. * Gets a list of Animations associated with the scene
  93901. */
  93902. animations: Animation[];
  93903. /**
  93904. * All of the animation groups added to this scene
  93905. * @see http://doc.babylonjs.com/how_to/group
  93906. */
  93907. animationGroups: AnimationGroup[];
  93908. /**
  93909. * All of the multi-materials added to this scene
  93910. * @see http://doc.babylonjs.com/how_to/multi_materials
  93911. */
  93912. multiMaterials: MultiMaterial[];
  93913. /**
  93914. * All of the materials added to this scene
  93915. * In the context of a Scene, it is not supposed to be modified manually.
  93916. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  93917. * Note also that the order of the Material wihin the array is not significant and might change.
  93918. * @see http://doc.babylonjs.com/babylon101/materials
  93919. */
  93920. materials: Material[];
  93921. /**
  93922. * The list of morph target managers added to the scene
  93923. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  93924. */
  93925. morphTargetManagers: MorphTargetManager[];
  93926. /**
  93927. * The list of geometries used in the scene.
  93928. */
  93929. geometries: Geometry[];
  93930. /**
  93931. * All of the tranform nodes added to this scene
  93932. * In the context of a Scene, it is not supposed to be modified manually.
  93933. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  93934. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  93935. * @see http://doc.babylonjs.com/how_to/transformnode
  93936. */
  93937. transformNodes: TransformNode[];
  93938. /**
  93939. * ActionManagers available on the scene.
  93940. */
  93941. actionManagers: AbstractActionManager[];
  93942. /**
  93943. * Textures to keep.
  93944. */
  93945. textures: BaseTexture[];
  93946. /**
  93947. * Environment texture for the scene
  93948. */
  93949. environmentTexture: Nullable<BaseTexture>;
  93950. }
  93951. }
  93952. declare module BABYLON {
  93953. /**
  93954. * Defines a sound that can be played in the application.
  93955. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  93956. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93957. */
  93958. export class Sound {
  93959. /**
  93960. * The name of the sound in the scene.
  93961. */
  93962. name: string;
  93963. /**
  93964. * Does the sound autoplay once loaded.
  93965. */
  93966. autoplay: boolean;
  93967. /**
  93968. * Does the sound loop after it finishes playing once.
  93969. */
  93970. loop: boolean;
  93971. /**
  93972. * Does the sound use a custom attenuation curve to simulate the falloff
  93973. * happening when the source gets further away from the camera.
  93974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93975. */
  93976. useCustomAttenuation: boolean;
  93977. /**
  93978. * The sound track id this sound belongs to.
  93979. */
  93980. soundTrackId: number;
  93981. /**
  93982. * Is this sound currently played.
  93983. */
  93984. isPlaying: boolean;
  93985. /**
  93986. * Is this sound currently paused.
  93987. */
  93988. isPaused: boolean;
  93989. /**
  93990. * Does this sound enables spatial sound.
  93991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93992. */
  93993. spatialSound: boolean;
  93994. /**
  93995. * Define the reference distance the sound should be heard perfectly.
  93996. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93997. */
  93998. refDistance: number;
  93999. /**
  94000. * Define the roll off factor of spatial sounds.
  94001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94002. */
  94003. rolloffFactor: number;
  94004. /**
  94005. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  94006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94007. */
  94008. maxDistance: number;
  94009. /**
  94010. * Define the distance attenuation model the sound will follow.
  94011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94012. */
  94013. distanceModel: string;
  94014. /**
  94015. * @hidden
  94016. * Back Compat
  94017. **/
  94018. onended: () => any;
  94019. /**
  94020. * Observable event when the current playing sound finishes.
  94021. */
  94022. onEndedObservable: Observable<Sound>;
  94023. private _panningModel;
  94024. private _playbackRate;
  94025. private _streaming;
  94026. private _startTime;
  94027. private _startOffset;
  94028. private _position;
  94029. /** @hidden */
  94030. _positionInEmitterSpace: boolean;
  94031. private _localDirection;
  94032. private _volume;
  94033. private _isReadyToPlay;
  94034. private _isDirectional;
  94035. private _readyToPlayCallback;
  94036. private _audioBuffer;
  94037. private _soundSource;
  94038. private _streamingSource;
  94039. private _soundPanner;
  94040. private _soundGain;
  94041. private _inputAudioNode;
  94042. private _outputAudioNode;
  94043. private _coneInnerAngle;
  94044. private _coneOuterAngle;
  94045. private _coneOuterGain;
  94046. private _scene;
  94047. private _connectedTransformNode;
  94048. private _customAttenuationFunction;
  94049. private _registerFunc;
  94050. private _isOutputConnected;
  94051. private _htmlAudioElement;
  94052. private _urlType;
  94053. /** @hidden */
  94054. static _SceneComponentInitialization: (scene: Scene) => void;
  94055. /**
  94056. * Create a sound and attach it to a scene
  94057. * @param name Name of your sound
  94058. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  94059. * @param scene defines the scene the sound belongs to
  94060. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  94061. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  94062. */
  94063. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  94064. /**
  94065. * Release the sound and its associated resources
  94066. */
  94067. dispose(): void;
  94068. /**
  94069. * Gets if the sounds is ready to be played or not.
  94070. * @returns true if ready, otherwise false
  94071. */
  94072. isReady(): boolean;
  94073. private _soundLoaded;
  94074. /**
  94075. * Sets the data of the sound from an audiobuffer
  94076. * @param audioBuffer The audioBuffer containing the data
  94077. */
  94078. setAudioBuffer(audioBuffer: AudioBuffer): void;
  94079. /**
  94080. * Updates the current sounds options such as maxdistance, loop...
  94081. * @param options A JSON object containing values named as the object properties
  94082. */
  94083. updateOptions(options: any): void;
  94084. private _createSpatialParameters;
  94085. private _updateSpatialParameters;
  94086. /**
  94087. * Switch the panning model to HRTF:
  94088. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  94089. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94090. */
  94091. switchPanningModelToHRTF(): void;
  94092. /**
  94093. * Switch the panning model to Equal Power:
  94094. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  94095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94096. */
  94097. switchPanningModelToEqualPower(): void;
  94098. private _switchPanningModel;
  94099. /**
  94100. * Connect this sound to a sound track audio node like gain...
  94101. * @param soundTrackAudioNode the sound track audio node to connect to
  94102. */
  94103. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  94104. /**
  94105. * Transform this sound into a directional source
  94106. * @param coneInnerAngle Size of the inner cone in degree
  94107. * @param coneOuterAngle Size of the outer cone in degree
  94108. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  94109. */
  94110. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  94111. /**
  94112. * Gets or sets the inner angle for the directional cone.
  94113. */
  94114. /**
  94115. * Gets or sets the inner angle for the directional cone.
  94116. */
  94117. directionalConeInnerAngle: number;
  94118. /**
  94119. * Gets or sets the outer angle for the directional cone.
  94120. */
  94121. /**
  94122. * Gets or sets the outer angle for the directional cone.
  94123. */
  94124. directionalConeOuterAngle: number;
  94125. /**
  94126. * Sets the position of the emitter if spatial sound is enabled
  94127. * @param newPosition Defines the new posisiton
  94128. */
  94129. setPosition(newPosition: Vector3): void;
  94130. /**
  94131. * Sets the local direction of the emitter if spatial sound is enabled
  94132. * @param newLocalDirection Defines the new local direction
  94133. */
  94134. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  94135. private _updateDirection;
  94136. /** @hidden */
  94137. updateDistanceFromListener(): void;
  94138. /**
  94139. * Sets a new custom attenuation function for the sound.
  94140. * @param callback Defines the function used for the attenuation
  94141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  94142. */
  94143. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  94144. /**
  94145. * Play the sound
  94146. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  94147. * @param offset (optional) Start the sound setting it at a specific time
  94148. */
  94149. play(time?: number, offset?: number): void;
  94150. private _onended;
  94151. /**
  94152. * Stop the sound
  94153. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  94154. */
  94155. stop(time?: number): void;
  94156. /**
  94157. * Put the sound in pause
  94158. */
  94159. pause(): void;
  94160. /**
  94161. * Sets a dedicated volume for this sounds
  94162. * @param newVolume Define the new volume of the sound
  94163. * @param time Define in how long the sound should be at this value
  94164. */
  94165. setVolume(newVolume: number, time?: number): void;
  94166. /**
  94167. * Set the sound play back rate
  94168. * @param newPlaybackRate Define the playback rate the sound should be played at
  94169. */
  94170. setPlaybackRate(newPlaybackRate: number): void;
  94171. /**
  94172. * Gets the volume of the sound.
  94173. * @returns the volume of the sound
  94174. */
  94175. getVolume(): number;
  94176. /**
  94177. * Attach the sound to a dedicated mesh
  94178. * @param transformNode The transform node to connect the sound with
  94179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  94180. */
  94181. attachToMesh(transformNode: TransformNode): void;
  94182. /**
  94183. * Detach the sound from the previously attached mesh
  94184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  94185. */
  94186. detachFromMesh(): void;
  94187. private _onRegisterAfterWorldMatrixUpdate;
  94188. /**
  94189. * Clone the current sound in the scene.
  94190. * @returns the new sound clone
  94191. */
  94192. clone(): Nullable<Sound>;
  94193. /**
  94194. * Gets the current underlying audio buffer containing the data
  94195. * @returns the audio buffer
  94196. */
  94197. getAudioBuffer(): Nullable<AudioBuffer>;
  94198. /**
  94199. * Serializes the Sound in a JSON representation
  94200. * @returns the JSON representation of the sound
  94201. */
  94202. serialize(): any;
  94203. /**
  94204. * Parse a JSON representation of a sound to innstantiate in a given scene
  94205. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  94206. * @param scene Define the scene the new parsed sound should be created in
  94207. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  94208. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  94209. * @returns the newly parsed sound
  94210. */
  94211. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  94212. }
  94213. }
  94214. declare module BABYLON {
  94215. /**
  94216. * This defines an action helpful to play a defined sound on a triggered action.
  94217. */
  94218. export class PlaySoundAction extends Action {
  94219. private _sound;
  94220. /**
  94221. * Instantiate the action
  94222. * @param triggerOptions defines the trigger options
  94223. * @param sound defines the sound to play
  94224. * @param condition defines the trigger related conditions
  94225. */
  94226. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94227. /** @hidden */
  94228. _prepare(): void;
  94229. /**
  94230. * Execute the action and play the sound.
  94231. */
  94232. execute(): void;
  94233. /**
  94234. * Serializes the actions and its related information.
  94235. * @param parent defines the object to serialize in
  94236. * @returns the serialized object
  94237. */
  94238. serialize(parent: any): any;
  94239. }
  94240. /**
  94241. * This defines an action helpful to stop a defined sound on a triggered action.
  94242. */
  94243. export class StopSoundAction extends Action {
  94244. private _sound;
  94245. /**
  94246. * Instantiate the action
  94247. * @param triggerOptions defines the trigger options
  94248. * @param sound defines the sound to stop
  94249. * @param condition defines the trigger related conditions
  94250. */
  94251. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94252. /** @hidden */
  94253. _prepare(): void;
  94254. /**
  94255. * Execute the action and stop the sound.
  94256. */
  94257. execute(): void;
  94258. /**
  94259. * Serializes the actions and its related information.
  94260. * @param parent defines the object to serialize in
  94261. * @returns the serialized object
  94262. */
  94263. serialize(parent: any): any;
  94264. }
  94265. }
  94266. declare module BABYLON {
  94267. /**
  94268. * This defines an action responsible to change the value of a property
  94269. * by interpolating between its current value and the newly set one once triggered.
  94270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94271. */
  94272. export class InterpolateValueAction extends Action {
  94273. /**
  94274. * Defines the path of the property where the value should be interpolated
  94275. */
  94276. propertyPath: string;
  94277. /**
  94278. * Defines the target value at the end of the interpolation.
  94279. */
  94280. value: any;
  94281. /**
  94282. * Defines the time it will take for the property to interpolate to the value.
  94283. */
  94284. duration: number;
  94285. /**
  94286. * Defines if the other scene animations should be stopped when the action has been triggered
  94287. */
  94288. stopOtherAnimations?: boolean;
  94289. /**
  94290. * Defines a callback raised once the interpolation animation has been done.
  94291. */
  94292. onInterpolationDone?: () => void;
  94293. /**
  94294. * Observable triggered once the interpolation animation has been done.
  94295. */
  94296. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  94297. private _target;
  94298. private _effectiveTarget;
  94299. private _property;
  94300. /**
  94301. * Instantiate the action
  94302. * @param triggerOptions defines the trigger options
  94303. * @param target defines the object containing the value to interpolate
  94304. * @param propertyPath defines the path to the property in the target object
  94305. * @param value defines the target value at the end of the interpolation
  94306. * @param duration deines the time it will take for the property to interpolate to the value.
  94307. * @param condition defines the trigger related conditions
  94308. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  94309. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  94310. */
  94311. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  94312. /** @hidden */
  94313. _prepare(): void;
  94314. /**
  94315. * Execute the action starts the value interpolation.
  94316. */
  94317. execute(): void;
  94318. /**
  94319. * Serializes the actions and its related information.
  94320. * @param parent defines the object to serialize in
  94321. * @returns the serialized object
  94322. */
  94323. serialize(parent: any): any;
  94324. }
  94325. }
  94326. declare module BABYLON {
  94327. /**
  94328. * Options allowed during the creation of a sound track.
  94329. */
  94330. export interface ISoundTrackOptions {
  94331. /**
  94332. * The volume the sound track should take during creation
  94333. */
  94334. volume?: number;
  94335. /**
  94336. * Define if the sound track is the main sound track of the scene
  94337. */
  94338. mainTrack?: boolean;
  94339. }
  94340. /**
  94341. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  94342. * It will be also used in a future release to apply effects on a specific track.
  94343. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94344. */
  94345. export class SoundTrack {
  94346. /**
  94347. * The unique identifier of the sound track in the scene.
  94348. */
  94349. id: number;
  94350. /**
  94351. * The list of sounds included in the sound track.
  94352. */
  94353. soundCollection: Array<Sound>;
  94354. private _outputAudioNode;
  94355. private _scene;
  94356. private _isMainTrack;
  94357. private _connectedAnalyser;
  94358. private _options;
  94359. private _isInitialized;
  94360. /**
  94361. * Creates a new sound track.
  94362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94363. * @param scene Define the scene the sound track belongs to
  94364. * @param options
  94365. */
  94366. constructor(scene: Scene, options?: ISoundTrackOptions);
  94367. private _initializeSoundTrackAudioGraph;
  94368. /**
  94369. * Release the sound track and its associated resources
  94370. */
  94371. dispose(): void;
  94372. /**
  94373. * Adds a sound to this sound track
  94374. * @param sound define the cound to add
  94375. * @ignoreNaming
  94376. */
  94377. AddSound(sound: Sound): void;
  94378. /**
  94379. * Removes a sound to this sound track
  94380. * @param sound define the cound to remove
  94381. * @ignoreNaming
  94382. */
  94383. RemoveSound(sound: Sound): void;
  94384. /**
  94385. * Set a global volume for the full sound track.
  94386. * @param newVolume Define the new volume of the sound track
  94387. */
  94388. setVolume(newVolume: number): void;
  94389. /**
  94390. * Switch the panning model to HRTF:
  94391. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  94392. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94393. */
  94394. switchPanningModelToHRTF(): void;
  94395. /**
  94396. * Switch the panning model to Equal Power:
  94397. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  94398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94399. */
  94400. switchPanningModelToEqualPower(): void;
  94401. /**
  94402. * Connect the sound track to an audio analyser allowing some amazing
  94403. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  94404. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  94405. * @param analyser The analyser to connect to the engine
  94406. */
  94407. connectToAnalyser(analyser: Analyser): void;
  94408. }
  94409. }
  94410. declare module BABYLON {
  94411. interface AbstractScene {
  94412. /**
  94413. * The list of sounds used in the scene.
  94414. */
  94415. sounds: Nullable<Array<Sound>>;
  94416. }
  94417. interface Scene {
  94418. /**
  94419. * @hidden
  94420. * Backing field
  94421. */
  94422. _mainSoundTrack: SoundTrack;
  94423. /**
  94424. * The main sound track played by the scene.
  94425. * It cotains your primary collection of sounds.
  94426. */
  94427. mainSoundTrack: SoundTrack;
  94428. /**
  94429. * The list of sound tracks added to the scene
  94430. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94431. */
  94432. soundTracks: Nullable<Array<SoundTrack>>;
  94433. /**
  94434. * Gets a sound using a given name
  94435. * @param name defines the name to search for
  94436. * @return the found sound or null if not found at all.
  94437. */
  94438. getSoundByName(name: string): Nullable<Sound>;
  94439. /**
  94440. * Gets or sets if audio support is enabled
  94441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94442. */
  94443. audioEnabled: boolean;
  94444. /**
  94445. * Gets or sets if audio will be output to headphones
  94446. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94447. */
  94448. headphone: boolean;
  94449. }
  94450. /**
  94451. * Defines the sound scene component responsible to manage any sounds
  94452. * in a given scene.
  94453. */
  94454. export class AudioSceneComponent implements ISceneSerializableComponent {
  94455. /**
  94456. * The component name helpfull to identify the component in the list of scene components.
  94457. */
  94458. readonly name: string;
  94459. /**
  94460. * The scene the component belongs to.
  94461. */
  94462. scene: Scene;
  94463. private _audioEnabled;
  94464. /**
  94465. * Gets whether audio is enabled or not.
  94466. * Please use related enable/disable method to switch state.
  94467. */
  94468. readonly audioEnabled: boolean;
  94469. private _headphone;
  94470. /**
  94471. * Gets whether audio is outputing to headphone or not.
  94472. * Please use the according Switch methods to change output.
  94473. */
  94474. readonly headphone: boolean;
  94475. /**
  94476. * Creates a new instance of the component for the given scene
  94477. * @param scene Defines the scene to register the component in
  94478. */
  94479. constructor(scene: Scene);
  94480. /**
  94481. * Registers the component in a given scene
  94482. */
  94483. register(): void;
  94484. /**
  94485. * Rebuilds the elements related to this component in case of
  94486. * context lost for instance.
  94487. */
  94488. rebuild(): void;
  94489. /**
  94490. * Serializes the component data to the specified json object
  94491. * @param serializationObject The object to serialize to
  94492. */
  94493. serialize(serializationObject: any): void;
  94494. /**
  94495. * Adds all the element from the container to the scene
  94496. * @param container the container holding the elements
  94497. */
  94498. addFromContainer(container: AbstractScene): void;
  94499. /**
  94500. * Removes all the elements in the container from the scene
  94501. * @param container contains the elements to remove
  94502. * @param dispose if the removed element should be disposed (default: false)
  94503. */
  94504. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  94505. /**
  94506. * Disposes the component and the associated ressources.
  94507. */
  94508. dispose(): void;
  94509. /**
  94510. * Disables audio in the associated scene.
  94511. */
  94512. disableAudio(): void;
  94513. /**
  94514. * Enables audio in the associated scene.
  94515. */
  94516. enableAudio(): void;
  94517. /**
  94518. * Switch audio to headphone output.
  94519. */
  94520. switchAudioModeForHeadphones(): void;
  94521. /**
  94522. * Switch audio to normal speakers.
  94523. */
  94524. switchAudioModeForNormalSpeakers(): void;
  94525. private _afterRender;
  94526. }
  94527. }
  94528. declare module BABYLON {
  94529. /**
  94530. * Wraps one or more Sound objects and selects one with random weight for playback.
  94531. */
  94532. export class WeightedSound {
  94533. /** When true a Sound will be selected and played when the current playing Sound completes. */
  94534. loop: boolean;
  94535. private _coneInnerAngle;
  94536. private _coneOuterAngle;
  94537. private _volume;
  94538. /** A Sound is currently playing. */
  94539. isPlaying: boolean;
  94540. /** A Sound is currently paused. */
  94541. isPaused: boolean;
  94542. private _sounds;
  94543. private _weights;
  94544. private _currentIndex?;
  94545. /**
  94546. * Creates a new WeightedSound from the list of sounds given.
  94547. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  94548. * @param sounds Array of Sounds that will be selected from.
  94549. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  94550. */
  94551. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  94552. /**
  94553. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  94554. */
  94555. /**
  94556. * The size of cone in degress for a directional sound in which there will be no attenuation.
  94557. */
  94558. directionalConeInnerAngle: number;
  94559. /**
  94560. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94561. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94562. */
  94563. /**
  94564. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94565. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94566. */
  94567. directionalConeOuterAngle: number;
  94568. /**
  94569. * Playback volume.
  94570. */
  94571. /**
  94572. * Playback volume.
  94573. */
  94574. volume: number;
  94575. private _onended;
  94576. /**
  94577. * Suspend playback
  94578. */
  94579. pause(): void;
  94580. /**
  94581. * Stop playback
  94582. */
  94583. stop(): void;
  94584. /**
  94585. * Start playback.
  94586. * @param startOffset Position the clip head at a specific time in seconds.
  94587. */
  94588. play(startOffset?: number): void;
  94589. }
  94590. }
  94591. declare module BABYLON {
  94592. /**
  94593. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  94594. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94595. */
  94596. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  94597. /**
  94598. * Gets the name of the behavior.
  94599. */
  94600. readonly name: string;
  94601. /**
  94602. * The easing function used by animations
  94603. */
  94604. static EasingFunction: BackEase;
  94605. /**
  94606. * The easing mode used by animations
  94607. */
  94608. static EasingMode: number;
  94609. /**
  94610. * The duration of the animation, in milliseconds
  94611. */
  94612. transitionDuration: number;
  94613. /**
  94614. * Length of the distance animated by the transition when lower radius is reached
  94615. */
  94616. lowerRadiusTransitionRange: number;
  94617. /**
  94618. * Length of the distance animated by the transition when upper radius is reached
  94619. */
  94620. upperRadiusTransitionRange: number;
  94621. private _autoTransitionRange;
  94622. /**
  94623. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94624. */
  94625. /**
  94626. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94627. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  94628. */
  94629. autoTransitionRange: boolean;
  94630. private _attachedCamera;
  94631. private _onAfterCheckInputsObserver;
  94632. private _onMeshTargetChangedObserver;
  94633. /**
  94634. * Initializes the behavior.
  94635. */
  94636. init(): void;
  94637. /**
  94638. * Attaches the behavior to its arc rotate camera.
  94639. * @param camera Defines the camera to attach the behavior to
  94640. */
  94641. attach(camera: ArcRotateCamera): void;
  94642. /**
  94643. * Detaches the behavior from its current arc rotate camera.
  94644. */
  94645. detach(): void;
  94646. private _radiusIsAnimating;
  94647. private _radiusBounceTransition;
  94648. private _animatables;
  94649. private _cachedWheelPrecision;
  94650. /**
  94651. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  94652. * @param radiusLimit The limit to check against.
  94653. * @return Bool to indicate if at limit.
  94654. */
  94655. private _isRadiusAtLimit;
  94656. /**
  94657. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  94658. * @param radiusDelta The delta by which to animate to. Can be negative.
  94659. */
  94660. private _applyBoundRadiusAnimation;
  94661. /**
  94662. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  94663. */
  94664. protected _clearAnimationLocks(): void;
  94665. /**
  94666. * Stops and removes all animations that have been applied to the camera
  94667. */
  94668. stopAllAnimations(): void;
  94669. }
  94670. }
  94671. declare module BABYLON {
  94672. /**
  94673. * 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.
  94674. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94675. */
  94676. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  94677. /**
  94678. * Gets the name of the behavior.
  94679. */
  94680. readonly name: string;
  94681. private _mode;
  94682. private _radiusScale;
  94683. private _positionScale;
  94684. private _defaultElevation;
  94685. private _elevationReturnTime;
  94686. private _elevationReturnWaitTime;
  94687. private _zoomStopsAnimation;
  94688. private _framingTime;
  94689. /**
  94690. * The easing function used by animations
  94691. */
  94692. static EasingFunction: ExponentialEase;
  94693. /**
  94694. * The easing mode used by animations
  94695. */
  94696. static EasingMode: number;
  94697. /**
  94698. * Sets the current mode used by the behavior
  94699. */
  94700. /**
  94701. * Gets current mode used by the behavior.
  94702. */
  94703. mode: number;
  94704. /**
  94705. * Sets the scale applied to the radius (1 by default)
  94706. */
  94707. /**
  94708. * Gets the scale applied to the radius
  94709. */
  94710. radiusScale: number;
  94711. /**
  94712. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94713. */
  94714. /**
  94715. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94716. */
  94717. positionScale: number;
  94718. /**
  94719. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94720. * behaviour is triggered, in radians.
  94721. */
  94722. /**
  94723. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94724. * behaviour is triggered, in radians.
  94725. */
  94726. defaultElevation: number;
  94727. /**
  94728. * Sets the time (in milliseconds) taken to return to the default beta position.
  94729. * Negative value indicates camera should not return to default.
  94730. */
  94731. /**
  94732. * Gets the time (in milliseconds) taken to return to the default beta position.
  94733. * Negative value indicates camera should not return to default.
  94734. */
  94735. elevationReturnTime: number;
  94736. /**
  94737. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94738. */
  94739. /**
  94740. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94741. */
  94742. elevationReturnWaitTime: number;
  94743. /**
  94744. * Sets the flag that indicates if user zooming should stop animation.
  94745. */
  94746. /**
  94747. * Gets the flag that indicates if user zooming should stop animation.
  94748. */
  94749. zoomStopsAnimation: boolean;
  94750. /**
  94751. * Sets the transition time when framing the mesh, in milliseconds
  94752. */
  94753. /**
  94754. * Gets the transition time when framing the mesh, in milliseconds
  94755. */
  94756. framingTime: number;
  94757. /**
  94758. * Define if the behavior should automatically change the configured
  94759. * camera limits and sensibilities.
  94760. */
  94761. autoCorrectCameraLimitsAndSensibility: boolean;
  94762. private _onPrePointerObservableObserver;
  94763. private _onAfterCheckInputsObserver;
  94764. private _onMeshTargetChangedObserver;
  94765. private _attachedCamera;
  94766. private _isPointerDown;
  94767. private _lastInteractionTime;
  94768. /**
  94769. * Initializes the behavior.
  94770. */
  94771. init(): void;
  94772. /**
  94773. * Attaches the behavior to its arc rotate camera.
  94774. * @param camera Defines the camera to attach the behavior to
  94775. */
  94776. attach(camera: ArcRotateCamera): void;
  94777. /**
  94778. * Detaches the behavior from its current arc rotate camera.
  94779. */
  94780. detach(): void;
  94781. private _animatables;
  94782. private _betaIsAnimating;
  94783. private _betaTransition;
  94784. private _radiusTransition;
  94785. private _vectorTransition;
  94786. /**
  94787. * Targets the given mesh and updates zoom level accordingly.
  94788. * @param mesh The mesh to target.
  94789. * @param radius Optional. If a cached radius position already exists, overrides default.
  94790. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94791. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94792. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94793. */
  94794. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94795. /**
  94796. * Targets the given mesh with its children and updates zoom level accordingly.
  94797. * @param mesh The mesh to target.
  94798. * @param radius Optional. If a cached radius position already exists, overrides default.
  94799. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94800. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94801. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94802. */
  94803. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94804. /**
  94805. * Targets the given meshes with their children and updates zoom level accordingly.
  94806. * @param meshes The mesh to target.
  94807. * @param radius Optional. If a cached radius position already exists, overrides default.
  94808. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94809. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94810. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94811. */
  94812. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94813. /**
  94814. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  94815. * @param minimumWorld Determines the smaller position of the bounding box extend
  94816. * @param maximumWorld Determines the bigger position of the bounding box extend
  94817. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94818. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94819. */
  94820. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94821. /**
  94822. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  94823. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  94824. * frustum width.
  94825. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  94826. * to fully enclose the mesh in the viewing frustum.
  94827. */
  94828. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  94829. /**
  94830. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  94831. * is automatically returned to its default position (expected to be above ground plane).
  94832. */
  94833. private _maintainCameraAboveGround;
  94834. /**
  94835. * Returns the frustum slope based on the canvas ratio and camera FOV
  94836. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  94837. */
  94838. private _getFrustumSlope;
  94839. /**
  94840. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  94841. */
  94842. private _clearAnimationLocks;
  94843. /**
  94844. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94845. */
  94846. private _applyUserInteraction;
  94847. /**
  94848. * Stops and removes all animations that have been applied to the camera
  94849. */
  94850. stopAllAnimations(): void;
  94851. /**
  94852. * Gets a value indicating if the user is moving the camera
  94853. */
  94854. readonly isUserIsMoving: boolean;
  94855. /**
  94856. * The camera can move all the way towards the mesh.
  94857. */
  94858. static IgnoreBoundsSizeMode: number;
  94859. /**
  94860. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  94861. */
  94862. static FitFrustumSidesMode: number;
  94863. }
  94864. }
  94865. declare module BABYLON {
  94866. /**
  94867. * Base class for Camera Pointer Inputs.
  94868. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  94869. * for example usage.
  94870. */
  94871. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  94872. /**
  94873. * Defines the camera the input is attached to.
  94874. */
  94875. abstract camera: Camera;
  94876. /**
  94877. * Whether keyboard modifier keys are pressed at time of last mouse event.
  94878. */
  94879. protected _altKey: boolean;
  94880. protected _ctrlKey: boolean;
  94881. protected _metaKey: boolean;
  94882. protected _shiftKey: boolean;
  94883. /**
  94884. * Which mouse buttons were pressed at time of last mouse event.
  94885. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  94886. */
  94887. protected _buttonsPressed: number;
  94888. /**
  94889. * Defines the buttons associated with the input to handle camera move.
  94890. */
  94891. buttons: number[];
  94892. /**
  94893. * Attach the input controls to a specific dom element to get the input from.
  94894. * @param element Defines the element the controls should be listened from
  94895. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94896. */
  94897. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94898. /**
  94899. * Detach the current controls from the specified dom element.
  94900. * @param element Defines the element to stop listening the inputs from
  94901. */
  94902. detachControl(element: Nullable<HTMLElement>): void;
  94903. /**
  94904. * Gets the class name of the current input.
  94905. * @returns the class name
  94906. */
  94907. getClassName(): string;
  94908. /**
  94909. * Get the friendly name associated with the input class.
  94910. * @returns the input friendly name
  94911. */
  94912. getSimpleName(): string;
  94913. /**
  94914. * Called on pointer POINTERDOUBLETAP event.
  94915. * Override this method to provide functionality on POINTERDOUBLETAP event.
  94916. */
  94917. protected onDoubleTap(type: string): void;
  94918. /**
  94919. * Called on pointer POINTERMOVE event if only a single touch is active.
  94920. * Override this method to provide functionality.
  94921. */
  94922. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94923. /**
  94924. * Called on pointer POINTERMOVE event if multiple touches are active.
  94925. * Override this method to provide functionality.
  94926. */
  94927. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94928. /**
  94929. * Called on JS contextmenu event.
  94930. * Override this method to provide functionality.
  94931. */
  94932. protected onContextMenu(evt: PointerEvent): void;
  94933. /**
  94934. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94935. * press.
  94936. * Override this method to provide functionality.
  94937. */
  94938. protected onButtonDown(evt: PointerEvent): void;
  94939. /**
  94940. * Called each time a new POINTERUP event occurs. Ie, for each button
  94941. * release.
  94942. * Override this method to provide functionality.
  94943. */
  94944. protected onButtonUp(evt: PointerEvent): void;
  94945. /**
  94946. * Called when window becomes inactive.
  94947. * Override this method to provide functionality.
  94948. */
  94949. protected onLostFocus(): void;
  94950. private _pointerInput;
  94951. private _observer;
  94952. private _onLostFocus;
  94953. private pointA;
  94954. private pointB;
  94955. }
  94956. }
  94957. declare module BABYLON {
  94958. /**
  94959. * Manage the pointers inputs to control an arc rotate camera.
  94960. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94961. */
  94962. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94963. /**
  94964. * Defines the camera the input is attached to.
  94965. */
  94966. camera: ArcRotateCamera;
  94967. /**
  94968. * Gets the class name of the current input.
  94969. * @returns the class name
  94970. */
  94971. getClassName(): string;
  94972. /**
  94973. * Defines the buttons associated with the input to handle camera move.
  94974. */
  94975. buttons: number[];
  94976. /**
  94977. * Defines the pointer angular sensibility along the X axis or how fast is
  94978. * the camera rotating.
  94979. */
  94980. angularSensibilityX: number;
  94981. /**
  94982. * Defines the pointer angular sensibility along the Y axis or how fast is
  94983. * the camera rotating.
  94984. */
  94985. angularSensibilityY: number;
  94986. /**
  94987. * Defines the pointer pinch precision or how fast is the camera zooming.
  94988. */
  94989. pinchPrecision: number;
  94990. /**
  94991. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94992. * from 0.
  94993. * It defines the percentage of current camera.radius to use as delta when
  94994. * pinch zoom is used.
  94995. */
  94996. pinchDeltaPercentage: number;
  94997. /**
  94998. * Defines the pointer panning sensibility or how fast is the camera moving.
  94999. */
  95000. panningSensibility: number;
  95001. /**
  95002. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  95003. */
  95004. multiTouchPanning: boolean;
  95005. /**
  95006. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  95007. * zoom (pinch) through multitouch.
  95008. */
  95009. multiTouchPanAndZoom: boolean;
  95010. /**
  95011. * Revers pinch action direction.
  95012. */
  95013. pinchInwards: boolean;
  95014. private _isPanClick;
  95015. private _twoFingerActivityCount;
  95016. private _isPinching;
  95017. /**
  95018. * Called on pointer POINTERMOVE event if only a single touch is active.
  95019. */
  95020. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  95021. /**
  95022. * Called on pointer POINTERDOUBLETAP event.
  95023. */
  95024. protected onDoubleTap(type: string): void;
  95025. /**
  95026. * Called on pointer POINTERMOVE event if multiple touches are active.
  95027. */
  95028. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  95029. /**
  95030. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  95031. * press.
  95032. */
  95033. protected onButtonDown(evt: PointerEvent): void;
  95034. /**
  95035. * Called each time a new POINTERUP event occurs. Ie, for each button
  95036. * release.
  95037. */
  95038. protected onButtonUp(evt: PointerEvent): void;
  95039. /**
  95040. * Called when window becomes inactive.
  95041. */
  95042. protected onLostFocus(): void;
  95043. }
  95044. }
  95045. declare module BABYLON {
  95046. /**
  95047. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  95048. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95049. */
  95050. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  95051. /**
  95052. * Defines the camera the input is attached to.
  95053. */
  95054. camera: ArcRotateCamera;
  95055. /**
  95056. * Defines the list of key codes associated with the up action (increase alpha)
  95057. */
  95058. keysUp: number[];
  95059. /**
  95060. * Defines the list of key codes associated with the down action (decrease alpha)
  95061. */
  95062. keysDown: number[];
  95063. /**
  95064. * Defines the list of key codes associated with the left action (increase beta)
  95065. */
  95066. keysLeft: number[];
  95067. /**
  95068. * Defines the list of key codes associated with the right action (decrease beta)
  95069. */
  95070. keysRight: number[];
  95071. /**
  95072. * Defines the list of key codes associated with the reset action.
  95073. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  95074. */
  95075. keysReset: number[];
  95076. /**
  95077. * Defines the panning sensibility of the inputs.
  95078. * (How fast is the camera paning)
  95079. */
  95080. panningSensibility: number;
  95081. /**
  95082. * Defines the zooming sensibility of the inputs.
  95083. * (How fast is the camera zooming)
  95084. */
  95085. zoomingSensibility: number;
  95086. /**
  95087. * Defines wether maintaining the alt key down switch the movement mode from
  95088. * orientation to zoom.
  95089. */
  95090. useAltToZoom: boolean;
  95091. /**
  95092. * Rotation speed of the camera
  95093. */
  95094. angularSpeed: number;
  95095. private _keys;
  95096. private _ctrlPressed;
  95097. private _altPressed;
  95098. private _onCanvasBlurObserver;
  95099. private _onKeyboardObserver;
  95100. private _engine;
  95101. private _scene;
  95102. /**
  95103. * Attach the input controls to a specific dom element to get the input from.
  95104. * @param element Defines the element the controls should be listened from
  95105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95106. */
  95107. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95108. /**
  95109. * Detach the current controls from the specified dom element.
  95110. * @param element Defines the element to stop listening the inputs from
  95111. */
  95112. detachControl(element: Nullable<HTMLElement>): void;
  95113. /**
  95114. * Update the current camera state depending on the inputs that have been used this frame.
  95115. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95116. */
  95117. checkInputs(): void;
  95118. /**
  95119. * Gets the class name of the current intput.
  95120. * @returns the class name
  95121. */
  95122. getClassName(): string;
  95123. /**
  95124. * Get the friendly name associated with the input class.
  95125. * @returns the input friendly name
  95126. */
  95127. getSimpleName(): string;
  95128. }
  95129. }
  95130. declare module BABYLON {
  95131. /**
  95132. * Manage the mouse wheel inputs to control an arc rotate camera.
  95133. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95134. */
  95135. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  95136. /**
  95137. * Defines the camera the input is attached to.
  95138. */
  95139. camera: ArcRotateCamera;
  95140. /**
  95141. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  95142. */
  95143. wheelPrecision: number;
  95144. /**
  95145. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  95146. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  95147. */
  95148. wheelDeltaPercentage: number;
  95149. private _wheel;
  95150. private _observer;
  95151. private computeDeltaFromMouseWheelLegacyEvent;
  95152. /**
  95153. * Attach the input controls to a specific dom element to get the input from.
  95154. * @param element Defines the element the controls should be listened from
  95155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95156. */
  95157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95158. /**
  95159. * Detach the current controls from the specified dom element.
  95160. * @param element Defines the element to stop listening the inputs from
  95161. */
  95162. detachControl(element: Nullable<HTMLElement>): void;
  95163. /**
  95164. * Gets the class name of the current intput.
  95165. * @returns the class name
  95166. */
  95167. getClassName(): string;
  95168. /**
  95169. * Get the friendly name associated with the input class.
  95170. * @returns the input friendly name
  95171. */
  95172. getSimpleName(): string;
  95173. }
  95174. }
  95175. declare module BABYLON {
  95176. /**
  95177. * Default Inputs manager for the ArcRotateCamera.
  95178. * It groups all the default supported inputs for ease of use.
  95179. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95180. */
  95181. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  95182. /**
  95183. * Instantiates a new ArcRotateCameraInputsManager.
  95184. * @param camera Defines the camera the inputs belong to
  95185. */
  95186. constructor(camera: ArcRotateCamera);
  95187. /**
  95188. * Add mouse wheel input support to the input manager.
  95189. * @returns the current input manager
  95190. */
  95191. addMouseWheel(): ArcRotateCameraInputsManager;
  95192. /**
  95193. * Add pointers input support to the input manager.
  95194. * @returns the current input manager
  95195. */
  95196. addPointers(): ArcRotateCameraInputsManager;
  95197. /**
  95198. * Add keyboard input support to the input manager.
  95199. * @returns the current input manager
  95200. */
  95201. addKeyboard(): ArcRotateCameraInputsManager;
  95202. }
  95203. }
  95204. declare module BABYLON {
  95205. /**
  95206. * This represents an orbital type of camera.
  95207. *
  95208. * 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.
  95209. * 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.
  95210. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  95211. */
  95212. export class ArcRotateCamera extends TargetCamera {
  95213. /**
  95214. * Defines the rotation angle of the camera along the longitudinal axis.
  95215. */
  95216. alpha: number;
  95217. /**
  95218. * Defines the rotation angle of the camera along the latitudinal axis.
  95219. */
  95220. beta: number;
  95221. /**
  95222. * Defines the radius of the camera from it s target point.
  95223. */
  95224. radius: number;
  95225. protected _target: Vector3;
  95226. protected _targetHost: Nullable<AbstractMesh>;
  95227. /**
  95228. * Defines the target point of the camera.
  95229. * The camera looks towards it form the radius distance.
  95230. */
  95231. target: Vector3;
  95232. /**
  95233. * Define the current local position of the camera in the scene
  95234. */
  95235. position: Vector3;
  95236. protected _upVector: Vector3;
  95237. protected _upToYMatrix: Matrix;
  95238. protected _YToUpMatrix: Matrix;
  95239. /**
  95240. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  95241. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  95242. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  95243. */
  95244. upVector: Vector3;
  95245. /**
  95246. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  95247. */
  95248. setMatUp(): void;
  95249. /**
  95250. * Current inertia value on the longitudinal axis.
  95251. * The bigger this number the longer it will take for the camera to stop.
  95252. */
  95253. inertialAlphaOffset: number;
  95254. /**
  95255. * Current inertia value on the latitudinal axis.
  95256. * The bigger this number the longer it will take for the camera to stop.
  95257. */
  95258. inertialBetaOffset: number;
  95259. /**
  95260. * Current inertia value on the radius axis.
  95261. * The bigger this number the longer it will take for the camera to stop.
  95262. */
  95263. inertialRadiusOffset: number;
  95264. /**
  95265. * Minimum allowed angle on the longitudinal axis.
  95266. * This can help limiting how the Camera is able to move in the scene.
  95267. */
  95268. lowerAlphaLimit: Nullable<number>;
  95269. /**
  95270. * Maximum allowed angle on the longitudinal axis.
  95271. * This can help limiting how the Camera is able to move in the scene.
  95272. */
  95273. upperAlphaLimit: Nullable<number>;
  95274. /**
  95275. * Minimum allowed angle on the latitudinal axis.
  95276. * This can help limiting how the Camera is able to move in the scene.
  95277. */
  95278. lowerBetaLimit: number;
  95279. /**
  95280. * Maximum allowed angle on the latitudinal axis.
  95281. * This can help limiting how the Camera is able to move in the scene.
  95282. */
  95283. upperBetaLimit: number;
  95284. /**
  95285. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  95286. * This can help limiting how the Camera is able to move in the scene.
  95287. */
  95288. lowerRadiusLimit: Nullable<number>;
  95289. /**
  95290. * Maximum allowed distance of the camera to the target (The camera can not get further).
  95291. * This can help limiting how the Camera is able to move in the scene.
  95292. */
  95293. upperRadiusLimit: Nullable<number>;
  95294. /**
  95295. * Defines the current inertia value used during panning of the camera along the X axis.
  95296. */
  95297. inertialPanningX: number;
  95298. /**
  95299. * Defines the current inertia value used during panning of the camera along the Y axis.
  95300. */
  95301. inertialPanningY: number;
  95302. /**
  95303. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  95304. * Basically if your fingers moves away from more than this distance you will be considered
  95305. * in pinch mode.
  95306. */
  95307. pinchToPanMaxDistance: number;
  95308. /**
  95309. * Defines the maximum distance the camera can pan.
  95310. * This could help keeping the cammera always in your scene.
  95311. */
  95312. panningDistanceLimit: Nullable<number>;
  95313. /**
  95314. * Defines the target of the camera before paning.
  95315. */
  95316. panningOriginTarget: Vector3;
  95317. /**
  95318. * Defines the value of the inertia used during panning.
  95319. * 0 would mean stop inertia and one would mean no decelleration at all.
  95320. */
  95321. panningInertia: number;
  95322. /**
  95323. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  95324. */
  95325. angularSensibilityX: number;
  95326. /**
  95327. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  95328. */
  95329. angularSensibilityY: number;
  95330. /**
  95331. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  95332. */
  95333. pinchPrecision: number;
  95334. /**
  95335. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  95336. * It will be used instead of pinchDeltaPrecision if different from 0.
  95337. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95338. */
  95339. pinchDeltaPercentage: number;
  95340. /**
  95341. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  95342. */
  95343. panningSensibility: number;
  95344. /**
  95345. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  95346. */
  95347. keysUp: number[];
  95348. /**
  95349. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  95350. */
  95351. keysDown: number[];
  95352. /**
  95353. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  95354. */
  95355. keysLeft: number[];
  95356. /**
  95357. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  95358. */
  95359. keysRight: number[];
  95360. /**
  95361. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  95362. */
  95363. wheelPrecision: number;
  95364. /**
  95365. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  95366. * It will be used instead of pinchDeltaPrecision if different from 0.
  95367. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95368. */
  95369. wheelDeltaPercentage: number;
  95370. /**
  95371. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  95372. */
  95373. zoomOnFactor: number;
  95374. /**
  95375. * Defines a screen offset for the camera position.
  95376. */
  95377. targetScreenOffset: Vector2;
  95378. /**
  95379. * Allows the camera to be completely reversed.
  95380. * If false the camera can not arrive upside down.
  95381. */
  95382. allowUpsideDown: boolean;
  95383. /**
  95384. * Define if double tap/click is used to restore the previously saved state of the camera.
  95385. */
  95386. useInputToRestoreState: boolean;
  95387. /** @hidden */
  95388. _viewMatrix: Matrix;
  95389. /** @hidden */
  95390. _useCtrlForPanning: boolean;
  95391. /** @hidden */
  95392. _panningMouseButton: number;
  95393. /**
  95394. * Defines the input associated to the camera.
  95395. */
  95396. inputs: ArcRotateCameraInputsManager;
  95397. /** @hidden */
  95398. _reset: () => void;
  95399. /**
  95400. * Defines the allowed panning axis.
  95401. */
  95402. panningAxis: Vector3;
  95403. protected _localDirection: Vector3;
  95404. protected _transformedDirection: Vector3;
  95405. private _bouncingBehavior;
  95406. /**
  95407. * Gets the bouncing behavior of the camera if it has been enabled.
  95408. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95409. */
  95410. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  95411. /**
  95412. * Defines if the bouncing behavior of the camera is enabled on the camera.
  95413. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95414. */
  95415. useBouncingBehavior: boolean;
  95416. private _framingBehavior;
  95417. /**
  95418. * Gets the framing behavior of the camera if it has been enabled.
  95419. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95420. */
  95421. readonly framingBehavior: Nullable<FramingBehavior>;
  95422. /**
  95423. * Defines if the framing behavior of the camera is enabled on the camera.
  95424. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95425. */
  95426. useFramingBehavior: boolean;
  95427. private _autoRotationBehavior;
  95428. /**
  95429. * Gets the auto rotation behavior of the camera if it has been enabled.
  95430. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95431. */
  95432. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  95433. /**
  95434. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  95435. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95436. */
  95437. useAutoRotationBehavior: boolean;
  95438. /**
  95439. * Observable triggered when the mesh target has been changed on the camera.
  95440. */
  95441. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  95442. /**
  95443. * Event raised when the camera is colliding with a mesh.
  95444. */
  95445. onCollide: (collidedMesh: AbstractMesh) => void;
  95446. /**
  95447. * Defines whether the camera should check collision with the objects oh the scene.
  95448. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  95449. */
  95450. checkCollisions: boolean;
  95451. /**
  95452. * Defines the collision radius of the camera.
  95453. * This simulates a sphere around the camera.
  95454. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95455. */
  95456. collisionRadius: Vector3;
  95457. protected _collider: Collider;
  95458. protected _previousPosition: Vector3;
  95459. protected _collisionVelocity: Vector3;
  95460. protected _newPosition: Vector3;
  95461. protected _previousAlpha: number;
  95462. protected _previousBeta: number;
  95463. protected _previousRadius: number;
  95464. protected _collisionTriggered: boolean;
  95465. protected _targetBoundingCenter: Nullable<Vector3>;
  95466. private _computationVector;
  95467. /**
  95468. * Instantiates a new ArcRotateCamera in a given scene
  95469. * @param name Defines the name of the camera
  95470. * @param alpha Defines the camera rotation along the logitudinal axis
  95471. * @param beta Defines the camera rotation along the latitudinal axis
  95472. * @param radius Defines the camera distance from its target
  95473. * @param target Defines the camera target
  95474. * @param scene Defines the scene the camera belongs to
  95475. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95476. */
  95477. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95478. /** @hidden */
  95479. _initCache(): void;
  95480. /** @hidden */
  95481. _updateCache(ignoreParentClass?: boolean): void;
  95482. protected _getTargetPosition(): Vector3;
  95483. private _storedAlpha;
  95484. private _storedBeta;
  95485. private _storedRadius;
  95486. private _storedTarget;
  95487. /**
  95488. * Stores the current state of the camera (alpha, beta, radius and target)
  95489. * @returns the camera itself
  95490. */
  95491. storeState(): Camera;
  95492. /**
  95493. * @hidden
  95494. * Restored camera state. You must call storeState() first
  95495. */
  95496. _restoreStateValues(): boolean;
  95497. /** @hidden */
  95498. _isSynchronizedViewMatrix(): boolean;
  95499. /**
  95500. * Attached controls to the current camera.
  95501. * @param element Defines the element the controls should be listened from
  95502. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95503. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  95504. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  95505. */
  95506. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  95507. /**
  95508. * Detach the current controls from the camera.
  95509. * The camera will stop reacting to inputs.
  95510. * @param element Defines the element to stop listening the inputs from
  95511. */
  95512. detachControl(element: HTMLElement): void;
  95513. /** @hidden */
  95514. _checkInputs(): void;
  95515. protected _checkLimits(): void;
  95516. /**
  95517. * Rebuilds angles (alpha, beta) and radius from the give position and target
  95518. */
  95519. rebuildAnglesAndRadius(): void;
  95520. /**
  95521. * Use a position to define the current camera related information like aplha, beta and radius
  95522. * @param position Defines the position to set the camera at
  95523. */
  95524. setPosition(position: Vector3): void;
  95525. /**
  95526. * Defines the target the camera should look at.
  95527. * This will automatically adapt alpha beta and radius to fit within the new target.
  95528. * @param target Defines the new target as a Vector or a mesh
  95529. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  95530. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  95531. */
  95532. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  95533. /** @hidden */
  95534. _getViewMatrix(): Matrix;
  95535. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  95536. /**
  95537. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  95538. * @param meshes Defines the mesh to zoom on
  95539. * @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)
  95540. */
  95541. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  95542. /**
  95543. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  95544. * The target will be changed but the radius
  95545. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  95546. * @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)
  95547. */
  95548. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  95549. min: Vector3;
  95550. max: Vector3;
  95551. distance: number;
  95552. }, doNotUpdateMaxZ?: boolean): void;
  95553. /**
  95554. * @override
  95555. * Override Camera.createRigCamera
  95556. */
  95557. createRigCamera(name: string, cameraIndex: number): Camera;
  95558. /**
  95559. * @hidden
  95560. * @override
  95561. * Override Camera._updateRigCameras
  95562. */
  95563. _updateRigCameras(): void;
  95564. /**
  95565. * Destroy the camera and release the current resources hold by it.
  95566. */
  95567. dispose(): void;
  95568. /**
  95569. * Gets the current object class name.
  95570. * @return the class name
  95571. */
  95572. getClassName(): string;
  95573. }
  95574. }
  95575. declare module BABYLON {
  95576. /**
  95577. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  95578. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95579. */
  95580. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  95581. /**
  95582. * Gets the name of the behavior.
  95583. */
  95584. readonly name: string;
  95585. private _zoomStopsAnimation;
  95586. private _idleRotationSpeed;
  95587. private _idleRotationWaitTime;
  95588. private _idleRotationSpinupTime;
  95589. /**
  95590. * Sets the flag that indicates if user zooming should stop animation.
  95591. */
  95592. /**
  95593. * Gets the flag that indicates if user zooming should stop animation.
  95594. */
  95595. zoomStopsAnimation: boolean;
  95596. /**
  95597. * Sets the default speed at which the camera rotates around the model.
  95598. */
  95599. /**
  95600. * Gets the default speed at which the camera rotates around the model.
  95601. */
  95602. idleRotationSpeed: number;
  95603. /**
  95604. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  95605. */
  95606. /**
  95607. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  95608. */
  95609. idleRotationWaitTime: number;
  95610. /**
  95611. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95612. */
  95613. /**
  95614. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95615. */
  95616. idleRotationSpinupTime: number;
  95617. /**
  95618. * Gets a value indicating if the camera is currently rotating because of this behavior
  95619. */
  95620. readonly rotationInProgress: boolean;
  95621. private _onPrePointerObservableObserver;
  95622. private _onAfterCheckInputsObserver;
  95623. private _attachedCamera;
  95624. private _isPointerDown;
  95625. private _lastFrameTime;
  95626. private _lastInteractionTime;
  95627. private _cameraRotationSpeed;
  95628. /**
  95629. * Initializes the behavior.
  95630. */
  95631. init(): void;
  95632. /**
  95633. * Attaches the behavior to its arc rotate camera.
  95634. * @param camera Defines the camera to attach the behavior to
  95635. */
  95636. attach(camera: ArcRotateCamera): void;
  95637. /**
  95638. * Detaches the behavior from its current arc rotate camera.
  95639. */
  95640. detach(): void;
  95641. /**
  95642. * Returns true if user is scrolling.
  95643. * @return true if user is scrolling.
  95644. */
  95645. private _userIsZooming;
  95646. private _lastFrameRadius;
  95647. private _shouldAnimationStopForInteraction;
  95648. /**
  95649. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  95650. */
  95651. private _applyUserInteraction;
  95652. private _userIsMoving;
  95653. }
  95654. }
  95655. declare module BABYLON {
  95656. /**
  95657. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  95658. */
  95659. export class AttachToBoxBehavior implements Behavior<Mesh> {
  95660. private ui;
  95661. /**
  95662. * The name of the behavior
  95663. */
  95664. name: string;
  95665. /**
  95666. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  95667. */
  95668. distanceAwayFromFace: number;
  95669. /**
  95670. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  95671. */
  95672. distanceAwayFromBottomOfFace: number;
  95673. private _faceVectors;
  95674. private _target;
  95675. private _scene;
  95676. private _onRenderObserver;
  95677. private _tmpMatrix;
  95678. private _tmpVector;
  95679. /**
  95680. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  95681. * @param ui The transform node that should be attched to the mesh
  95682. */
  95683. constructor(ui: TransformNode);
  95684. /**
  95685. * Initializes the behavior
  95686. */
  95687. init(): void;
  95688. private _closestFace;
  95689. private _zeroVector;
  95690. private _lookAtTmpMatrix;
  95691. private _lookAtToRef;
  95692. /**
  95693. * Attaches the AttachToBoxBehavior to the passed in mesh
  95694. * @param target The mesh that the specified node will be attached to
  95695. */
  95696. attach(target: Mesh): void;
  95697. /**
  95698. * Detaches the behavior from the mesh
  95699. */
  95700. detach(): void;
  95701. }
  95702. }
  95703. declare module BABYLON {
  95704. /**
  95705. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  95706. */
  95707. export class FadeInOutBehavior implements Behavior<Mesh> {
  95708. /**
  95709. * Time in milliseconds to delay before fading in (Default: 0)
  95710. */
  95711. delay: number;
  95712. /**
  95713. * Time in milliseconds for the mesh to fade in (Default: 300)
  95714. */
  95715. fadeInTime: number;
  95716. private _millisecondsPerFrame;
  95717. private _hovered;
  95718. private _hoverValue;
  95719. private _ownerNode;
  95720. /**
  95721. * Instatiates the FadeInOutBehavior
  95722. */
  95723. constructor();
  95724. /**
  95725. * The name of the behavior
  95726. */
  95727. readonly name: string;
  95728. /**
  95729. * Initializes the behavior
  95730. */
  95731. init(): void;
  95732. /**
  95733. * Attaches the fade behavior on the passed in mesh
  95734. * @param ownerNode The mesh that will be faded in/out once attached
  95735. */
  95736. attach(ownerNode: Mesh): void;
  95737. /**
  95738. * Detaches the behavior from the mesh
  95739. */
  95740. detach(): void;
  95741. /**
  95742. * Triggers the mesh to begin fading in or out
  95743. * @param value if the object should fade in or out (true to fade in)
  95744. */
  95745. fadeIn(value: boolean): void;
  95746. private _update;
  95747. private _setAllVisibility;
  95748. }
  95749. }
  95750. declare module BABYLON {
  95751. /**
  95752. * Class containing a set of static utilities functions for managing Pivots
  95753. * @hidden
  95754. */
  95755. export class PivotTools {
  95756. private static _PivotCached;
  95757. private static _OldPivotPoint;
  95758. private static _PivotTranslation;
  95759. private static _PivotTmpVector;
  95760. /** @hidden */
  95761. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  95762. /** @hidden */
  95763. static _RestorePivotPoint(mesh: AbstractMesh): void;
  95764. }
  95765. }
  95766. declare module BABYLON {
  95767. /**
  95768. * Class containing static functions to help procedurally build meshes
  95769. */
  95770. export class PlaneBuilder {
  95771. /**
  95772. * Creates a plane mesh
  95773. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  95774. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  95775. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  95776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95777. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95779. * @param name defines the name of the mesh
  95780. * @param options defines the options used to create the mesh
  95781. * @param scene defines the hosting scene
  95782. * @returns the plane mesh
  95783. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  95784. */
  95785. static CreatePlane(name: string, options: {
  95786. size?: number;
  95787. width?: number;
  95788. height?: number;
  95789. sideOrientation?: number;
  95790. frontUVs?: Vector4;
  95791. backUVs?: Vector4;
  95792. updatable?: boolean;
  95793. sourcePlane?: Plane;
  95794. }, scene?: Nullable<Scene>): Mesh;
  95795. }
  95796. }
  95797. declare module BABYLON {
  95798. /**
  95799. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  95800. */
  95801. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  95802. private static _AnyMouseID;
  95803. private _attachedNode;
  95804. private _dragPlane;
  95805. private _scene;
  95806. private _pointerObserver;
  95807. private _beforeRenderObserver;
  95808. private static _planeScene;
  95809. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  95810. /**
  95811. * 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)
  95812. */
  95813. maxDragAngle: number;
  95814. /**
  95815. * @hidden
  95816. */
  95817. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  95818. /**
  95819. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95820. */
  95821. currentDraggingPointerID: number;
  95822. /**
  95823. * The last position where the pointer hit the drag plane in world space
  95824. */
  95825. lastDragPosition: Vector3;
  95826. /**
  95827. * If the behavior is currently in a dragging state
  95828. */
  95829. dragging: boolean;
  95830. /**
  95831. * 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)
  95832. */
  95833. dragDeltaRatio: number;
  95834. /**
  95835. * If the drag plane orientation should be updated during the dragging (Default: true)
  95836. */
  95837. updateDragPlane: boolean;
  95838. private _debugMode;
  95839. private _moving;
  95840. /**
  95841. * Fires each time the attached mesh is dragged with the pointer
  95842. * * delta between last drag position and current drag position in world space
  95843. * * dragDistance along the drag axis
  95844. * * dragPlaneNormal normal of the current drag plane used during the drag
  95845. * * dragPlanePoint in world space where the drag intersects the drag plane
  95846. */
  95847. onDragObservable: Observable<{
  95848. delta: Vector3;
  95849. dragPlanePoint: Vector3;
  95850. dragPlaneNormal: Vector3;
  95851. dragDistance: number;
  95852. pointerId: number;
  95853. }>;
  95854. /**
  95855. * Fires each time a drag begins (eg. mouse down on mesh)
  95856. */
  95857. onDragStartObservable: Observable<{
  95858. dragPlanePoint: Vector3;
  95859. pointerId: number;
  95860. }>;
  95861. /**
  95862. * Fires each time a drag ends (eg. mouse release after drag)
  95863. */
  95864. onDragEndObservable: Observable<{
  95865. dragPlanePoint: Vector3;
  95866. pointerId: number;
  95867. }>;
  95868. /**
  95869. * If the attached mesh should be moved when dragged
  95870. */
  95871. moveAttached: boolean;
  95872. /**
  95873. * If the drag behavior will react to drag events (Default: true)
  95874. */
  95875. enabled: boolean;
  95876. /**
  95877. * If camera controls should be detached during the drag
  95878. */
  95879. detachCameraControls: boolean;
  95880. /**
  95881. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  95882. */
  95883. useObjectOrienationForDragging: boolean;
  95884. private _options;
  95885. /**
  95886. * Creates a pointer drag behavior that can be attached to a mesh
  95887. * @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)
  95888. */
  95889. constructor(options?: {
  95890. dragAxis?: Vector3;
  95891. dragPlaneNormal?: Vector3;
  95892. });
  95893. /**
  95894. * Predicate to determine if it is valid to move the object to a new position when it is moved
  95895. */
  95896. validateDrag: (targetPosition: Vector3) => boolean;
  95897. /**
  95898. * The name of the behavior
  95899. */
  95900. readonly name: string;
  95901. /**
  95902. * Initializes the behavior
  95903. */
  95904. init(): void;
  95905. private _tmpVector;
  95906. private _alternatePickedPoint;
  95907. private _worldDragAxis;
  95908. private _targetPosition;
  95909. private _attachedElement;
  95910. /**
  95911. * Attaches the drag behavior the passed in mesh
  95912. * @param ownerNode The mesh that will be dragged around once attached
  95913. */
  95914. attach(ownerNode: AbstractMesh): void;
  95915. /**
  95916. * Force relase the drag action by code.
  95917. */
  95918. releaseDrag(): void;
  95919. private _startDragRay;
  95920. private _lastPointerRay;
  95921. /**
  95922. * Simulates the start of a pointer drag event on the behavior
  95923. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  95924. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  95925. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  95926. */
  95927. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  95928. private _startDrag;
  95929. private _dragDelta;
  95930. private _moveDrag;
  95931. private _pickWithRayOnDragPlane;
  95932. private _pointA;
  95933. private _pointB;
  95934. private _pointC;
  95935. private _lineA;
  95936. private _lineB;
  95937. private _localAxis;
  95938. private _lookAt;
  95939. private _updateDragPlanePosition;
  95940. /**
  95941. * Detaches the behavior from the mesh
  95942. */
  95943. detach(): void;
  95944. }
  95945. }
  95946. declare module BABYLON {
  95947. /**
  95948. * A behavior that when attached to a mesh will allow the mesh to be scaled
  95949. */
  95950. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  95951. private _dragBehaviorA;
  95952. private _dragBehaviorB;
  95953. private _startDistance;
  95954. private _initialScale;
  95955. private _targetScale;
  95956. private _ownerNode;
  95957. private _sceneRenderObserver;
  95958. /**
  95959. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  95960. */
  95961. constructor();
  95962. /**
  95963. * The name of the behavior
  95964. */
  95965. readonly name: string;
  95966. /**
  95967. * Initializes the behavior
  95968. */
  95969. init(): void;
  95970. private _getCurrentDistance;
  95971. /**
  95972. * Attaches the scale behavior the passed in mesh
  95973. * @param ownerNode The mesh that will be scaled around once attached
  95974. */
  95975. attach(ownerNode: Mesh): void;
  95976. /**
  95977. * Detaches the behavior from the mesh
  95978. */
  95979. detach(): void;
  95980. }
  95981. }
  95982. declare module BABYLON {
  95983. /**
  95984. * 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
  95985. */
  95986. export class SixDofDragBehavior implements Behavior<Mesh> {
  95987. private static _virtualScene;
  95988. private _ownerNode;
  95989. private _sceneRenderObserver;
  95990. private _scene;
  95991. private _targetPosition;
  95992. private _virtualOriginMesh;
  95993. private _virtualDragMesh;
  95994. private _pointerObserver;
  95995. private _moving;
  95996. private _startingOrientation;
  95997. /**
  95998. * 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)
  95999. */
  96000. private zDragFactor;
  96001. /**
  96002. * If the object should rotate to face the drag origin
  96003. */
  96004. rotateDraggedObject: boolean;
  96005. /**
  96006. * If the behavior is currently in a dragging state
  96007. */
  96008. dragging: boolean;
  96009. /**
  96010. * 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)
  96011. */
  96012. dragDeltaRatio: number;
  96013. /**
  96014. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  96015. */
  96016. currentDraggingPointerID: number;
  96017. /**
  96018. * If camera controls should be detached during the drag
  96019. */
  96020. detachCameraControls: boolean;
  96021. /**
  96022. * Fires each time a drag starts
  96023. */
  96024. onDragStartObservable: Observable<{}>;
  96025. /**
  96026. * Fires each time a drag ends (eg. mouse release after drag)
  96027. */
  96028. onDragEndObservable: Observable<{}>;
  96029. /**
  96030. * 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
  96031. */
  96032. constructor();
  96033. /**
  96034. * The name of the behavior
  96035. */
  96036. readonly name: string;
  96037. /**
  96038. * Initializes the behavior
  96039. */
  96040. init(): void;
  96041. /**
  96042. * Attaches the scale behavior the passed in mesh
  96043. * @param ownerNode The mesh that will be scaled around once attached
  96044. */
  96045. attach(ownerNode: Mesh): void;
  96046. /**
  96047. * Detaches the behavior from the mesh
  96048. */
  96049. detach(): void;
  96050. }
  96051. }
  96052. declare module BABYLON {
  96053. /**
  96054. * Class used to apply inverse kinematics to bones
  96055. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  96056. */
  96057. export class BoneIKController {
  96058. private static _tmpVecs;
  96059. private static _tmpQuat;
  96060. private static _tmpMats;
  96061. /**
  96062. * Gets or sets the target mesh
  96063. */
  96064. targetMesh: AbstractMesh;
  96065. /** Gets or sets the mesh used as pole */
  96066. poleTargetMesh: AbstractMesh;
  96067. /**
  96068. * Gets or sets the bone used as pole
  96069. */
  96070. poleTargetBone: Nullable<Bone>;
  96071. /**
  96072. * Gets or sets the target position
  96073. */
  96074. targetPosition: Vector3;
  96075. /**
  96076. * Gets or sets the pole target position
  96077. */
  96078. poleTargetPosition: Vector3;
  96079. /**
  96080. * Gets or sets the pole target local offset
  96081. */
  96082. poleTargetLocalOffset: Vector3;
  96083. /**
  96084. * Gets or sets the pole angle
  96085. */
  96086. poleAngle: number;
  96087. /**
  96088. * Gets or sets the mesh associated with the controller
  96089. */
  96090. mesh: AbstractMesh;
  96091. /**
  96092. * 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)
  96093. */
  96094. slerpAmount: number;
  96095. private _bone1Quat;
  96096. private _bone1Mat;
  96097. private _bone2Ang;
  96098. private _bone1;
  96099. private _bone2;
  96100. private _bone1Length;
  96101. private _bone2Length;
  96102. private _maxAngle;
  96103. private _maxReach;
  96104. private _rightHandedSystem;
  96105. private _bendAxis;
  96106. private _slerping;
  96107. private _adjustRoll;
  96108. /**
  96109. * Gets or sets maximum allowed angle
  96110. */
  96111. maxAngle: number;
  96112. /**
  96113. * Creates a new BoneIKController
  96114. * @param mesh defines the mesh to control
  96115. * @param bone defines the bone to control
  96116. * @param options defines options to set up the controller
  96117. */
  96118. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  96119. targetMesh?: AbstractMesh;
  96120. poleTargetMesh?: AbstractMesh;
  96121. poleTargetBone?: Bone;
  96122. poleTargetLocalOffset?: Vector3;
  96123. poleAngle?: number;
  96124. bendAxis?: Vector3;
  96125. maxAngle?: number;
  96126. slerpAmount?: number;
  96127. });
  96128. private _setMaxAngle;
  96129. /**
  96130. * Force the controller to update the bones
  96131. */
  96132. update(): void;
  96133. }
  96134. }
  96135. declare module BABYLON {
  96136. /**
  96137. * Class used to make a bone look toward a point in space
  96138. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  96139. */
  96140. export class BoneLookController {
  96141. private static _tmpVecs;
  96142. private static _tmpQuat;
  96143. private static _tmpMats;
  96144. /**
  96145. * The target Vector3 that the bone will look at
  96146. */
  96147. target: Vector3;
  96148. /**
  96149. * The mesh that the bone is attached to
  96150. */
  96151. mesh: AbstractMesh;
  96152. /**
  96153. * The bone that will be looking to the target
  96154. */
  96155. bone: Bone;
  96156. /**
  96157. * The up axis of the coordinate system that is used when the bone is rotated
  96158. */
  96159. upAxis: Vector3;
  96160. /**
  96161. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  96162. */
  96163. upAxisSpace: Space;
  96164. /**
  96165. * Used to make an adjustment to the yaw of the bone
  96166. */
  96167. adjustYaw: number;
  96168. /**
  96169. * Used to make an adjustment to the pitch of the bone
  96170. */
  96171. adjustPitch: number;
  96172. /**
  96173. * Used to make an adjustment to the roll of the bone
  96174. */
  96175. adjustRoll: number;
  96176. /**
  96177. * 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)
  96178. */
  96179. slerpAmount: number;
  96180. private _minYaw;
  96181. private _maxYaw;
  96182. private _minPitch;
  96183. private _maxPitch;
  96184. private _minYawSin;
  96185. private _minYawCos;
  96186. private _maxYawSin;
  96187. private _maxYawCos;
  96188. private _midYawConstraint;
  96189. private _minPitchTan;
  96190. private _maxPitchTan;
  96191. private _boneQuat;
  96192. private _slerping;
  96193. private _transformYawPitch;
  96194. private _transformYawPitchInv;
  96195. private _firstFrameSkipped;
  96196. private _yawRange;
  96197. private _fowardAxis;
  96198. /**
  96199. * Gets or sets the minimum yaw angle that the bone can look to
  96200. */
  96201. minYaw: number;
  96202. /**
  96203. * Gets or sets the maximum yaw angle that the bone can look to
  96204. */
  96205. maxYaw: number;
  96206. /**
  96207. * Gets or sets the minimum pitch angle that the bone can look to
  96208. */
  96209. minPitch: number;
  96210. /**
  96211. * Gets or sets the maximum pitch angle that the bone can look to
  96212. */
  96213. maxPitch: number;
  96214. /**
  96215. * Create a BoneLookController
  96216. * @param mesh the mesh that the bone belongs to
  96217. * @param bone the bone that will be looking to the target
  96218. * @param target the target Vector3 to look at
  96219. * @param options optional settings:
  96220. * * maxYaw: the maximum angle the bone will yaw to
  96221. * * minYaw: the minimum angle the bone will yaw to
  96222. * * maxPitch: the maximum angle the bone will pitch to
  96223. * * minPitch: the minimum angle the bone will yaw to
  96224. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  96225. * * upAxis: the up axis of the coordinate system
  96226. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  96227. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  96228. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  96229. * * adjustYaw: used to make an adjustment to the yaw of the bone
  96230. * * adjustPitch: used to make an adjustment to the pitch of the bone
  96231. * * adjustRoll: used to make an adjustment to the roll of the bone
  96232. **/
  96233. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  96234. maxYaw?: number;
  96235. minYaw?: number;
  96236. maxPitch?: number;
  96237. minPitch?: number;
  96238. slerpAmount?: number;
  96239. upAxis?: Vector3;
  96240. upAxisSpace?: Space;
  96241. yawAxis?: Vector3;
  96242. pitchAxis?: Vector3;
  96243. adjustYaw?: number;
  96244. adjustPitch?: number;
  96245. adjustRoll?: number;
  96246. });
  96247. /**
  96248. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  96249. */
  96250. update(): void;
  96251. private _getAngleDiff;
  96252. private _getAngleBetween;
  96253. private _isAngleBetween;
  96254. }
  96255. }
  96256. declare module BABYLON {
  96257. /**
  96258. * Manage the gamepad inputs to control an arc rotate camera.
  96259. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96260. */
  96261. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  96262. /**
  96263. * Defines the camera the input is attached to.
  96264. */
  96265. camera: ArcRotateCamera;
  96266. /**
  96267. * Defines the gamepad the input is gathering event from.
  96268. */
  96269. gamepad: Nullable<Gamepad>;
  96270. /**
  96271. * Defines the gamepad rotation sensiblity.
  96272. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96273. */
  96274. gamepadRotationSensibility: number;
  96275. /**
  96276. * Defines the gamepad move sensiblity.
  96277. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96278. */
  96279. gamepadMoveSensibility: number;
  96280. private _onGamepadConnectedObserver;
  96281. private _onGamepadDisconnectedObserver;
  96282. /**
  96283. * Attach the input controls to a specific dom element to get the input from.
  96284. * @param element Defines the element the controls should be listened from
  96285. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96286. */
  96287. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96288. /**
  96289. * Detach the current controls from the specified dom element.
  96290. * @param element Defines the element to stop listening the inputs from
  96291. */
  96292. detachControl(element: Nullable<HTMLElement>): void;
  96293. /**
  96294. * Update the current camera state depending on the inputs that have been used this frame.
  96295. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96296. */
  96297. checkInputs(): void;
  96298. /**
  96299. * Gets the class name of the current intput.
  96300. * @returns the class name
  96301. */
  96302. getClassName(): string;
  96303. /**
  96304. * Get the friendly name associated with the input class.
  96305. * @returns the input friendly name
  96306. */
  96307. getSimpleName(): string;
  96308. }
  96309. }
  96310. declare module BABYLON {
  96311. interface ArcRotateCameraInputsManager {
  96312. /**
  96313. * Add orientation input support to the input manager.
  96314. * @returns the current input manager
  96315. */
  96316. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  96317. }
  96318. /**
  96319. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  96320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96321. */
  96322. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  96323. /**
  96324. * Defines the camera the input is attached to.
  96325. */
  96326. camera: ArcRotateCamera;
  96327. /**
  96328. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  96329. */
  96330. alphaCorrection: number;
  96331. /**
  96332. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  96333. */
  96334. gammaCorrection: number;
  96335. private _alpha;
  96336. private _gamma;
  96337. private _dirty;
  96338. private _deviceOrientationHandler;
  96339. /**
  96340. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  96341. */
  96342. constructor();
  96343. /**
  96344. * Attach the input controls to a specific dom element to get the input from.
  96345. * @param element Defines the element the controls should be listened from
  96346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96347. */
  96348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96349. /** @hidden */
  96350. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  96351. /**
  96352. * Update the current camera state depending on the inputs that have been used this frame.
  96353. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96354. */
  96355. checkInputs(): void;
  96356. /**
  96357. * Detach the current controls from the specified dom element.
  96358. * @param element Defines the element to stop listening the inputs from
  96359. */
  96360. detachControl(element: Nullable<HTMLElement>): void;
  96361. /**
  96362. * Gets the class name of the current intput.
  96363. * @returns the class name
  96364. */
  96365. getClassName(): string;
  96366. /**
  96367. * Get the friendly name associated with the input class.
  96368. * @returns the input friendly name
  96369. */
  96370. getSimpleName(): string;
  96371. }
  96372. }
  96373. declare module BABYLON {
  96374. /**
  96375. * Listen to mouse events to control the camera.
  96376. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96377. */
  96378. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  96379. /**
  96380. * Defines the camera the input is attached to.
  96381. */
  96382. camera: FlyCamera;
  96383. /**
  96384. * Defines if touch is enabled. (Default is true.)
  96385. */
  96386. touchEnabled: boolean;
  96387. /**
  96388. * Defines the buttons associated with the input to handle camera rotation.
  96389. */
  96390. buttons: number[];
  96391. /**
  96392. * Assign buttons for Yaw control.
  96393. */
  96394. buttonsYaw: number[];
  96395. /**
  96396. * Assign buttons for Pitch control.
  96397. */
  96398. buttonsPitch: number[];
  96399. /**
  96400. * Assign buttons for Roll control.
  96401. */
  96402. buttonsRoll: number[];
  96403. /**
  96404. * Detect if any button is being pressed while mouse is moved.
  96405. * -1 = Mouse locked.
  96406. * 0 = Left button.
  96407. * 1 = Middle Button.
  96408. * 2 = Right Button.
  96409. */
  96410. activeButton: number;
  96411. /**
  96412. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  96413. * Higher values reduce its sensitivity.
  96414. */
  96415. angularSensibility: number;
  96416. private _mousemoveCallback;
  96417. private _observer;
  96418. private _rollObserver;
  96419. private previousPosition;
  96420. private noPreventDefault;
  96421. private element;
  96422. /**
  96423. * Listen to mouse events to control the camera.
  96424. * @param touchEnabled Define if touch is enabled. (Default is true.)
  96425. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96426. */
  96427. constructor(touchEnabled?: boolean);
  96428. /**
  96429. * Attach the mouse control to the HTML DOM element.
  96430. * @param element Defines the element that listens to the input events.
  96431. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  96432. */
  96433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96434. /**
  96435. * Detach the current controls from the specified dom element.
  96436. * @param element Defines the element to stop listening the inputs from
  96437. */
  96438. detachControl(element: Nullable<HTMLElement>): void;
  96439. /**
  96440. * Gets the class name of the current input.
  96441. * @returns the class name.
  96442. */
  96443. getClassName(): string;
  96444. /**
  96445. * Get the friendly name associated with the input class.
  96446. * @returns the input's friendly name.
  96447. */
  96448. getSimpleName(): string;
  96449. private _pointerInput;
  96450. private _onMouseMove;
  96451. /**
  96452. * Rotate camera by mouse offset.
  96453. */
  96454. private rotateCamera;
  96455. }
  96456. }
  96457. declare module BABYLON {
  96458. /**
  96459. * Default Inputs manager for the FlyCamera.
  96460. * It groups all the default supported inputs for ease of use.
  96461. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96462. */
  96463. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  96464. /**
  96465. * Instantiates a new FlyCameraInputsManager.
  96466. * @param camera Defines the camera the inputs belong to.
  96467. */
  96468. constructor(camera: FlyCamera);
  96469. /**
  96470. * Add keyboard input support to the input manager.
  96471. * @returns the new FlyCameraKeyboardMoveInput().
  96472. */
  96473. addKeyboard(): FlyCameraInputsManager;
  96474. /**
  96475. * Add mouse input support to the input manager.
  96476. * @param touchEnabled Enable touch screen support.
  96477. * @returns the new FlyCameraMouseInput().
  96478. */
  96479. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  96480. }
  96481. }
  96482. declare module BABYLON {
  96483. /**
  96484. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96485. * such as in a 3D Space Shooter or a Flight Simulator.
  96486. */
  96487. export class FlyCamera extends TargetCamera {
  96488. /**
  96489. * Define the collision ellipsoid of the camera.
  96490. * This is helpful for simulating a camera body, like a player's body.
  96491. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96492. */
  96493. ellipsoid: Vector3;
  96494. /**
  96495. * Define an offset for the position of the ellipsoid around the camera.
  96496. * This can be helpful if the camera is attached away from the player's body center,
  96497. * such as at its head.
  96498. */
  96499. ellipsoidOffset: Vector3;
  96500. /**
  96501. * Enable or disable collisions of the camera with the rest of the scene objects.
  96502. */
  96503. checkCollisions: boolean;
  96504. /**
  96505. * Enable or disable gravity on the camera.
  96506. */
  96507. applyGravity: boolean;
  96508. /**
  96509. * Define the current direction the camera is moving to.
  96510. */
  96511. cameraDirection: Vector3;
  96512. /**
  96513. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  96514. * This overrides and empties cameraRotation.
  96515. */
  96516. rotationQuaternion: Quaternion;
  96517. /**
  96518. * Track Roll to maintain the wanted Rolling when looking around.
  96519. */
  96520. _trackRoll: number;
  96521. /**
  96522. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  96523. */
  96524. rollCorrect: number;
  96525. /**
  96526. * Mimic a banked turn, Rolling the camera when Yawing.
  96527. * It's recommended to use rollCorrect = 10 for faster banking correction.
  96528. */
  96529. bankedTurn: boolean;
  96530. /**
  96531. * Limit in radians for how much Roll banking will add. (Default: 90°)
  96532. */
  96533. bankedTurnLimit: number;
  96534. /**
  96535. * Value of 0 disables the banked Roll.
  96536. * Value of 1 is equal to the Yaw angle in radians.
  96537. */
  96538. bankedTurnMultiplier: number;
  96539. /**
  96540. * The inputs manager loads all the input sources, such as keyboard and mouse.
  96541. */
  96542. inputs: FlyCameraInputsManager;
  96543. /**
  96544. * Gets the input sensibility for mouse input.
  96545. * Higher values reduce sensitivity.
  96546. */
  96547. /**
  96548. * Sets the input sensibility for a mouse input.
  96549. * Higher values reduce sensitivity.
  96550. */
  96551. angularSensibility: number;
  96552. /**
  96553. * Get the keys for camera movement forward.
  96554. */
  96555. /**
  96556. * Set the keys for camera movement forward.
  96557. */
  96558. keysForward: number[];
  96559. /**
  96560. * Get the keys for camera movement backward.
  96561. */
  96562. keysBackward: number[];
  96563. /**
  96564. * Get the keys for camera movement up.
  96565. */
  96566. /**
  96567. * Set the keys for camera movement up.
  96568. */
  96569. keysUp: number[];
  96570. /**
  96571. * Get the keys for camera movement down.
  96572. */
  96573. /**
  96574. * Set the keys for camera movement down.
  96575. */
  96576. keysDown: number[];
  96577. /**
  96578. * Get the keys for camera movement left.
  96579. */
  96580. /**
  96581. * Set the keys for camera movement left.
  96582. */
  96583. keysLeft: number[];
  96584. /**
  96585. * Set the keys for camera movement right.
  96586. */
  96587. /**
  96588. * Set the keys for camera movement right.
  96589. */
  96590. keysRight: number[];
  96591. /**
  96592. * Event raised when the camera collides with a mesh in the scene.
  96593. */
  96594. onCollide: (collidedMesh: AbstractMesh) => void;
  96595. private _collider;
  96596. private _needMoveForGravity;
  96597. private _oldPosition;
  96598. private _diffPosition;
  96599. private _newPosition;
  96600. /** @hidden */
  96601. _localDirection: Vector3;
  96602. /** @hidden */
  96603. _transformedDirection: Vector3;
  96604. /**
  96605. * Instantiates a FlyCamera.
  96606. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96607. * such as in a 3D Space Shooter or a Flight Simulator.
  96608. * @param name Define the name of the camera in the scene.
  96609. * @param position Define the starting position of the camera in the scene.
  96610. * @param scene Define the scene the camera belongs to.
  96611. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  96612. */
  96613. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96614. /**
  96615. * Attach a control to the HTML DOM element.
  96616. * @param element Defines the element that listens to the input events.
  96617. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  96618. */
  96619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96620. /**
  96621. * Detach a control from the HTML DOM element.
  96622. * The camera will stop reacting to that input.
  96623. * @param element Defines the element that listens to the input events.
  96624. */
  96625. detachControl(element: HTMLElement): void;
  96626. private _collisionMask;
  96627. /**
  96628. * Get the mask that the camera ignores in collision events.
  96629. */
  96630. /**
  96631. * Set the mask that the camera ignores in collision events.
  96632. */
  96633. collisionMask: number;
  96634. /** @hidden */
  96635. _collideWithWorld(displacement: Vector3): void;
  96636. /** @hidden */
  96637. private _onCollisionPositionChange;
  96638. /** @hidden */
  96639. _checkInputs(): void;
  96640. /** @hidden */
  96641. _decideIfNeedsToMove(): boolean;
  96642. /** @hidden */
  96643. _updatePosition(): void;
  96644. /**
  96645. * Restore the Roll to its target value at the rate specified.
  96646. * @param rate - Higher means slower restoring.
  96647. * @hidden
  96648. */
  96649. restoreRoll(rate: number): void;
  96650. /**
  96651. * Destroy the camera and release the current resources held by it.
  96652. */
  96653. dispose(): void;
  96654. /**
  96655. * Get the current object class name.
  96656. * @returns the class name.
  96657. */
  96658. getClassName(): string;
  96659. }
  96660. }
  96661. declare module BABYLON {
  96662. /**
  96663. * Listen to keyboard events to control the camera.
  96664. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96665. */
  96666. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  96667. /**
  96668. * Defines the camera the input is attached to.
  96669. */
  96670. camera: FlyCamera;
  96671. /**
  96672. * The list of keyboard keys used to control the forward move of the camera.
  96673. */
  96674. keysForward: number[];
  96675. /**
  96676. * The list of keyboard keys used to control the backward move of the camera.
  96677. */
  96678. keysBackward: number[];
  96679. /**
  96680. * The list of keyboard keys used to control the forward move of the camera.
  96681. */
  96682. keysUp: number[];
  96683. /**
  96684. * The list of keyboard keys used to control the backward move of the camera.
  96685. */
  96686. keysDown: number[];
  96687. /**
  96688. * The list of keyboard keys used to control the right strafe move of the camera.
  96689. */
  96690. keysRight: number[];
  96691. /**
  96692. * The list of keyboard keys used to control the left strafe move of the camera.
  96693. */
  96694. keysLeft: number[];
  96695. private _keys;
  96696. private _onCanvasBlurObserver;
  96697. private _onKeyboardObserver;
  96698. private _engine;
  96699. private _scene;
  96700. /**
  96701. * Attach the input controls to a specific dom element to get the input from.
  96702. * @param element Defines the element the controls should be listened from
  96703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96704. */
  96705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96706. /**
  96707. * Detach the current controls from the specified dom element.
  96708. * @param element Defines the element to stop listening the inputs from
  96709. */
  96710. detachControl(element: Nullable<HTMLElement>): void;
  96711. /**
  96712. * Gets the class name of the current intput.
  96713. * @returns the class name
  96714. */
  96715. getClassName(): string;
  96716. /** @hidden */
  96717. _onLostFocus(e: FocusEvent): void;
  96718. /**
  96719. * Get the friendly name associated with the input class.
  96720. * @returns the input friendly name
  96721. */
  96722. getSimpleName(): string;
  96723. /**
  96724. * Update the current camera state depending on the inputs that have been used this frame.
  96725. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96726. */
  96727. checkInputs(): void;
  96728. }
  96729. }
  96730. declare module BABYLON {
  96731. /**
  96732. * Manage the mouse wheel inputs to control a follow camera.
  96733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96734. */
  96735. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  96736. /**
  96737. * Defines the camera the input is attached to.
  96738. */
  96739. camera: FollowCamera;
  96740. /**
  96741. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  96742. */
  96743. axisControlRadius: boolean;
  96744. /**
  96745. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  96746. */
  96747. axisControlHeight: boolean;
  96748. /**
  96749. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  96750. */
  96751. axisControlRotation: boolean;
  96752. /**
  96753. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  96754. * relation to mouseWheel events.
  96755. */
  96756. wheelPrecision: number;
  96757. /**
  96758. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  96759. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  96760. */
  96761. wheelDeltaPercentage: number;
  96762. private _wheel;
  96763. private _observer;
  96764. /**
  96765. * Attach the input controls to a specific dom element to get the input from.
  96766. * @param element Defines the element the controls should be listened from
  96767. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96768. */
  96769. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96770. /**
  96771. * Detach the current controls from the specified dom element.
  96772. * @param element Defines the element to stop listening the inputs from
  96773. */
  96774. detachControl(element: Nullable<HTMLElement>): void;
  96775. /**
  96776. * Gets the class name of the current intput.
  96777. * @returns the class name
  96778. */
  96779. getClassName(): string;
  96780. /**
  96781. * Get the friendly name associated with the input class.
  96782. * @returns the input friendly name
  96783. */
  96784. getSimpleName(): string;
  96785. }
  96786. }
  96787. declare module BABYLON {
  96788. /**
  96789. * Manage the pointers inputs to control an follow camera.
  96790. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96791. */
  96792. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  96793. /**
  96794. * Defines the camera the input is attached to.
  96795. */
  96796. camera: FollowCamera;
  96797. /**
  96798. * Gets the class name of the current input.
  96799. * @returns the class name
  96800. */
  96801. getClassName(): string;
  96802. /**
  96803. * Defines the pointer angular sensibility along the X axis or how fast is
  96804. * the camera rotating.
  96805. * A negative number will reverse the axis direction.
  96806. */
  96807. angularSensibilityX: number;
  96808. /**
  96809. * Defines the pointer angular sensibility along the Y axis or how fast is
  96810. * the camera rotating.
  96811. * A negative number will reverse the axis direction.
  96812. */
  96813. angularSensibilityY: number;
  96814. /**
  96815. * Defines the pointer pinch precision or how fast is the camera zooming.
  96816. * A negative number will reverse the axis direction.
  96817. */
  96818. pinchPrecision: number;
  96819. /**
  96820. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  96821. * from 0.
  96822. * It defines the percentage of current camera.radius to use as delta when
  96823. * pinch zoom is used.
  96824. */
  96825. pinchDeltaPercentage: number;
  96826. /**
  96827. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  96828. */
  96829. axisXControlRadius: boolean;
  96830. /**
  96831. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  96832. */
  96833. axisXControlHeight: boolean;
  96834. /**
  96835. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  96836. */
  96837. axisXControlRotation: boolean;
  96838. /**
  96839. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  96840. */
  96841. axisYControlRadius: boolean;
  96842. /**
  96843. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  96844. */
  96845. axisYControlHeight: boolean;
  96846. /**
  96847. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  96848. */
  96849. axisYControlRotation: boolean;
  96850. /**
  96851. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  96852. */
  96853. axisPinchControlRadius: boolean;
  96854. /**
  96855. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  96856. */
  96857. axisPinchControlHeight: boolean;
  96858. /**
  96859. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  96860. */
  96861. axisPinchControlRotation: boolean;
  96862. /**
  96863. * Log error messages if basic misconfiguration has occurred.
  96864. */
  96865. warningEnable: boolean;
  96866. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  96867. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  96868. private _warningCounter;
  96869. private _warning;
  96870. }
  96871. }
  96872. declare module BABYLON {
  96873. /**
  96874. * Default Inputs manager for the FollowCamera.
  96875. * It groups all the default supported inputs for ease of use.
  96876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96877. */
  96878. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  96879. /**
  96880. * Instantiates a new FollowCameraInputsManager.
  96881. * @param camera Defines the camera the inputs belong to
  96882. */
  96883. constructor(camera: FollowCamera);
  96884. /**
  96885. * Add keyboard input support to the input manager.
  96886. * @returns the current input manager
  96887. */
  96888. addKeyboard(): FollowCameraInputsManager;
  96889. /**
  96890. * Add mouse wheel input support to the input manager.
  96891. * @returns the current input manager
  96892. */
  96893. addMouseWheel(): FollowCameraInputsManager;
  96894. /**
  96895. * Add pointers input support to the input manager.
  96896. * @returns the current input manager
  96897. */
  96898. addPointers(): FollowCameraInputsManager;
  96899. /**
  96900. * Add orientation input support to the input manager.
  96901. * @returns the current input manager
  96902. */
  96903. addVRDeviceOrientation(): FollowCameraInputsManager;
  96904. }
  96905. }
  96906. declare module BABYLON {
  96907. /**
  96908. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  96909. * an arc rotate version arcFollowCamera are available.
  96910. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96911. */
  96912. export class FollowCamera extends TargetCamera {
  96913. /**
  96914. * Distance the follow camera should follow an object at
  96915. */
  96916. radius: number;
  96917. /**
  96918. * Minimum allowed distance of the camera to the axis of rotation
  96919. * (The camera can not get closer).
  96920. * This can help limiting how the Camera is able to move in the scene.
  96921. */
  96922. lowerRadiusLimit: Nullable<number>;
  96923. /**
  96924. * Maximum allowed distance of the camera to the axis of rotation
  96925. * (The camera can not get further).
  96926. * This can help limiting how the Camera is able to move in the scene.
  96927. */
  96928. upperRadiusLimit: Nullable<number>;
  96929. /**
  96930. * Define a rotation offset between the camera and the object it follows
  96931. */
  96932. rotationOffset: number;
  96933. /**
  96934. * Minimum allowed angle to camera position relative to target object.
  96935. * This can help limiting how the Camera is able to move in the scene.
  96936. */
  96937. lowerRotationOffsetLimit: Nullable<number>;
  96938. /**
  96939. * Maximum allowed angle to camera position relative to target object.
  96940. * This can help limiting how the Camera is able to move in the scene.
  96941. */
  96942. upperRotationOffsetLimit: Nullable<number>;
  96943. /**
  96944. * Define a height offset between the camera and the object it follows.
  96945. * It can help following an object from the top (like a car chaing a plane)
  96946. */
  96947. heightOffset: number;
  96948. /**
  96949. * Minimum allowed height of camera position relative to target object.
  96950. * This can help limiting how the Camera is able to move in the scene.
  96951. */
  96952. lowerHeightOffsetLimit: Nullable<number>;
  96953. /**
  96954. * Maximum allowed height of camera position relative to target object.
  96955. * This can help limiting how the Camera is able to move in the scene.
  96956. */
  96957. upperHeightOffsetLimit: Nullable<number>;
  96958. /**
  96959. * Define how fast the camera can accelerate to follow it s target.
  96960. */
  96961. cameraAcceleration: number;
  96962. /**
  96963. * Define the speed limit of the camera following an object.
  96964. */
  96965. maxCameraSpeed: number;
  96966. /**
  96967. * Define the target of the camera.
  96968. */
  96969. lockedTarget: Nullable<AbstractMesh>;
  96970. /**
  96971. * Defines the input associated with the camera.
  96972. */
  96973. inputs: FollowCameraInputsManager;
  96974. /**
  96975. * Instantiates the follow camera.
  96976. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96977. * @param name Define the name of the camera in the scene
  96978. * @param position Define the position of the camera
  96979. * @param scene Define the scene the camera belong to
  96980. * @param lockedTarget Define the target of the camera
  96981. */
  96982. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96983. private _follow;
  96984. /**
  96985. * Attached controls to the current camera.
  96986. * @param element Defines the element the controls should be listened from
  96987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96988. */
  96989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96990. /**
  96991. * Detach the current controls from the camera.
  96992. * The camera will stop reacting to inputs.
  96993. * @param element Defines the element to stop listening the inputs from
  96994. */
  96995. detachControl(element: HTMLElement): void;
  96996. /** @hidden */
  96997. _checkInputs(): void;
  96998. private _checkLimits;
  96999. /**
  97000. * Gets the camera class name.
  97001. * @returns the class name
  97002. */
  97003. getClassName(): string;
  97004. }
  97005. /**
  97006. * Arc Rotate version of the follow camera.
  97007. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  97008. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  97009. */
  97010. export class ArcFollowCamera extends TargetCamera {
  97011. /** The longitudinal angle of the camera */
  97012. alpha: number;
  97013. /** The latitudinal angle of the camera */
  97014. beta: number;
  97015. /** The radius of the camera from its target */
  97016. radius: number;
  97017. /** Define the camera target (the messh it should follow) */
  97018. target: Nullable<AbstractMesh>;
  97019. private _cartesianCoordinates;
  97020. /**
  97021. * Instantiates a new ArcFollowCamera
  97022. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  97023. * @param name Define the name of the camera
  97024. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  97025. * @param beta Define the rotation angle of the camera around the elevation axis
  97026. * @param radius Define the radius of the camera from its target point
  97027. * @param target Define the target of the camera
  97028. * @param scene Define the scene the camera belongs to
  97029. */
  97030. constructor(name: string,
  97031. /** The longitudinal angle of the camera */
  97032. alpha: number,
  97033. /** The latitudinal angle of the camera */
  97034. beta: number,
  97035. /** The radius of the camera from its target */
  97036. radius: number,
  97037. /** Define the camera target (the messh it should follow) */
  97038. target: Nullable<AbstractMesh>, scene: Scene);
  97039. private _follow;
  97040. /** @hidden */
  97041. _checkInputs(): void;
  97042. /**
  97043. * Returns the class name of the object.
  97044. * It is mostly used internally for serialization purposes.
  97045. */
  97046. getClassName(): string;
  97047. }
  97048. }
  97049. declare module BABYLON {
  97050. /**
  97051. * Manage the keyboard inputs to control the movement of a follow camera.
  97052. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97053. */
  97054. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  97055. /**
  97056. * Defines the camera the input is attached to.
  97057. */
  97058. camera: FollowCamera;
  97059. /**
  97060. * Defines the list of key codes associated with the up action (increase heightOffset)
  97061. */
  97062. keysHeightOffsetIncr: number[];
  97063. /**
  97064. * Defines the list of key codes associated with the down action (decrease heightOffset)
  97065. */
  97066. keysHeightOffsetDecr: number[];
  97067. /**
  97068. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  97069. */
  97070. keysHeightOffsetModifierAlt: boolean;
  97071. /**
  97072. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  97073. */
  97074. keysHeightOffsetModifierCtrl: boolean;
  97075. /**
  97076. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  97077. */
  97078. keysHeightOffsetModifierShift: boolean;
  97079. /**
  97080. * Defines the list of key codes associated with the left action (increase rotationOffset)
  97081. */
  97082. keysRotationOffsetIncr: number[];
  97083. /**
  97084. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  97085. */
  97086. keysRotationOffsetDecr: number[];
  97087. /**
  97088. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  97089. */
  97090. keysRotationOffsetModifierAlt: boolean;
  97091. /**
  97092. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  97093. */
  97094. keysRotationOffsetModifierCtrl: boolean;
  97095. /**
  97096. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  97097. */
  97098. keysRotationOffsetModifierShift: boolean;
  97099. /**
  97100. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  97101. */
  97102. keysRadiusIncr: number[];
  97103. /**
  97104. * Defines the list of key codes associated with the zoom-out action (increase radius)
  97105. */
  97106. keysRadiusDecr: number[];
  97107. /**
  97108. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  97109. */
  97110. keysRadiusModifierAlt: boolean;
  97111. /**
  97112. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  97113. */
  97114. keysRadiusModifierCtrl: boolean;
  97115. /**
  97116. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  97117. */
  97118. keysRadiusModifierShift: boolean;
  97119. /**
  97120. * Defines the rate of change of heightOffset.
  97121. */
  97122. heightSensibility: number;
  97123. /**
  97124. * Defines the rate of change of rotationOffset.
  97125. */
  97126. rotationSensibility: number;
  97127. /**
  97128. * Defines the rate of change of radius.
  97129. */
  97130. radiusSensibility: number;
  97131. private _keys;
  97132. private _ctrlPressed;
  97133. private _altPressed;
  97134. private _shiftPressed;
  97135. private _onCanvasBlurObserver;
  97136. private _onKeyboardObserver;
  97137. private _engine;
  97138. private _scene;
  97139. /**
  97140. * Attach the input controls to a specific dom element to get the input from.
  97141. * @param element Defines the element the controls should be listened from
  97142. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97143. */
  97144. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97145. /**
  97146. * Detach the current controls from the specified dom element.
  97147. * @param element Defines the element to stop listening the inputs from
  97148. */
  97149. detachControl(element: Nullable<HTMLElement>): void;
  97150. /**
  97151. * Update the current camera state depending on the inputs that have been used this frame.
  97152. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97153. */
  97154. checkInputs(): void;
  97155. /**
  97156. * Gets the class name of the current input.
  97157. * @returns the class name
  97158. */
  97159. getClassName(): string;
  97160. /**
  97161. * Get the friendly name associated with the input class.
  97162. * @returns the input friendly name
  97163. */
  97164. getSimpleName(): string;
  97165. /**
  97166. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97167. * allow modification of the heightOffset value.
  97168. */
  97169. private _modifierHeightOffset;
  97170. /**
  97171. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97172. * allow modification of the rotationOffset value.
  97173. */
  97174. private _modifierRotationOffset;
  97175. /**
  97176. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97177. * allow modification of the radius value.
  97178. */
  97179. private _modifierRadius;
  97180. }
  97181. }
  97182. declare module BABYLON {
  97183. interface FreeCameraInputsManager {
  97184. /**
  97185. * @hidden
  97186. */
  97187. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  97188. /**
  97189. * Add orientation input support to the input manager.
  97190. * @returns the current input manager
  97191. */
  97192. addDeviceOrientation(): FreeCameraInputsManager;
  97193. }
  97194. /**
  97195. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  97196. * Screen rotation is taken into account.
  97197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97198. */
  97199. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  97200. private _camera;
  97201. private _screenOrientationAngle;
  97202. private _constantTranform;
  97203. private _screenQuaternion;
  97204. private _alpha;
  97205. private _beta;
  97206. private _gamma;
  97207. /**
  97208. * @hidden
  97209. */
  97210. _onDeviceOrientationChangedObservable: Observable<void>;
  97211. /**
  97212. * Instantiates a new input
  97213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97214. */
  97215. constructor();
  97216. /**
  97217. * Define the camera controlled by the input.
  97218. */
  97219. camera: FreeCamera;
  97220. /**
  97221. * Attach the input controls to a specific dom element to get the input from.
  97222. * @param element Defines the element the controls should be listened from
  97223. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97224. */
  97225. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97226. private _orientationChanged;
  97227. private _deviceOrientation;
  97228. /**
  97229. * Detach the current controls from the specified dom element.
  97230. * @param element Defines the element to stop listening the inputs from
  97231. */
  97232. detachControl(element: Nullable<HTMLElement>): void;
  97233. /**
  97234. * Update the current camera state depending on the inputs that have been used this frame.
  97235. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97236. */
  97237. checkInputs(): void;
  97238. /**
  97239. * Gets the class name of the current intput.
  97240. * @returns the class name
  97241. */
  97242. getClassName(): string;
  97243. /**
  97244. * Get the friendly name associated with the input class.
  97245. * @returns the input friendly name
  97246. */
  97247. getSimpleName(): string;
  97248. }
  97249. }
  97250. declare module BABYLON {
  97251. /**
  97252. * Manage the gamepad inputs to control a free camera.
  97253. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97254. */
  97255. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  97256. /**
  97257. * Define the camera the input is attached to.
  97258. */
  97259. camera: FreeCamera;
  97260. /**
  97261. * Define the Gamepad controlling the input
  97262. */
  97263. gamepad: Nullable<Gamepad>;
  97264. /**
  97265. * Defines the gamepad rotation sensiblity.
  97266. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97267. */
  97268. gamepadAngularSensibility: number;
  97269. /**
  97270. * Defines the gamepad move sensiblity.
  97271. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97272. */
  97273. gamepadMoveSensibility: number;
  97274. private _onGamepadConnectedObserver;
  97275. private _onGamepadDisconnectedObserver;
  97276. private _cameraTransform;
  97277. private _deltaTransform;
  97278. private _vector3;
  97279. private _vector2;
  97280. /**
  97281. * Attach the input controls to a specific dom element to get the input from.
  97282. * @param element Defines the element the controls should be listened from
  97283. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97284. */
  97285. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97286. /**
  97287. * Detach the current controls from the specified dom element.
  97288. * @param element Defines the element to stop listening the inputs from
  97289. */
  97290. detachControl(element: Nullable<HTMLElement>): void;
  97291. /**
  97292. * Update the current camera state depending on the inputs that have been used this frame.
  97293. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97294. */
  97295. checkInputs(): void;
  97296. /**
  97297. * Gets the class name of the current intput.
  97298. * @returns the class name
  97299. */
  97300. getClassName(): string;
  97301. /**
  97302. * Get the friendly name associated with the input class.
  97303. * @returns the input friendly name
  97304. */
  97305. getSimpleName(): string;
  97306. }
  97307. }
  97308. declare module BABYLON {
  97309. /**
  97310. * Defines the potential axis of a Joystick
  97311. */
  97312. export enum JoystickAxis {
  97313. /** X axis */
  97314. X = 0,
  97315. /** Y axis */
  97316. Y = 1,
  97317. /** Z axis */
  97318. Z = 2
  97319. }
  97320. /**
  97321. * Class used to define virtual joystick (used in touch mode)
  97322. */
  97323. export class VirtualJoystick {
  97324. /**
  97325. * Gets or sets a boolean indicating that left and right values must be inverted
  97326. */
  97327. reverseLeftRight: boolean;
  97328. /**
  97329. * Gets or sets a boolean indicating that up and down values must be inverted
  97330. */
  97331. reverseUpDown: boolean;
  97332. /**
  97333. * Gets the offset value for the position (ie. the change of the position value)
  97334. */
  97335. deltaPosition: Vector3;
  97336. /**
  97337. * Gets a boolean indicating if the virtual joystick was pressed
  97338. */
  97339. pressed: boolean;
  97340. /**
  97341. * Canvas the virtual joystick will render onto, default z-index of this is 5
  97342. */
  97343. static Canvas: Nullable<HTMLCanvasElement>;
  97344. private static _globalJoystickIndex;
  97345. private static vjCanvasContext;
  97346. private static vjCanvasWidth;
  97347. private static vjCanvasHeight;
  97348. private static halfWidth;
  97349. private _action;
  97350. private _axisTargetedByLeftAndRight;
  97351. private _axisTargetedByUpAndDown;
  97352. private _joystickSensibility;
  97353. private _inversedSensibility;
  97354. private _joystickPointerID;
  97355. private _joystickColor;
  97356. private _joystickPointerPos;
  97357. private _joystickPreviousPointerPos;
  97358. private _joystickPointerStartPos;
  97359. private _deltaJoystickVector;
  97360. private _leftJoystick;
  97361. private _touches;
  97362. private _onPointerDownHandlerRef;
  97363. private _onPointerMoveHandlerRef;
  97364. private _onPointerUpHandlerRef;
  97365. private _onResize;
  97366. /**
  97367. * Creates a new virtual joystick
  97368. * @param leftJoystick defines that the joystick is for left hand (false by default)
  97369. */
  97370. constructor(leftJoystick?: boolean);
  97371. /**
  97372. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  97373. * @param newJoystickSensibility defines the new sensibility
  97374. */
  97375. setJoystickSensibility(newJoystickSensibility: number): void;
  97376. private _onPointerDown;
  97377. private _onPointerMove;
  97378. private _onPointerUp;
  97379. /**
  97380. * Change the color of the virtual joystick
  97381. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  97382. */
  97383. setJoystickColor(newColor: string): void;
  97384. /**
  97385. * Defines a callback to call when the joystick is touched
  97386. * @param action defines the callback
  97387. */
  97388. setActionOnTouch(action: () => any): void;
  97389. /**
  97390. * Defines which axis you'd like to control for left & right
  97391. * @param axis defines the axis to use
  97392. */
  97393. setAxisForLeftRight(axis: JoystickAxis): void;
  97394. /**
  97395. * Defines which axis you'd like to control for up & down
  97396. * @param axis defines the axis to use
  97397. */
  97398. setAxisForUpDown(axis: JoystickAxis): void;
  97399. private _drawVirtualJoystick;
  97400. /**
  97401. * Release internal HTML canvas
  97402. */
  97403. releaseCanvas(): void;
  97404. }
  97405. }
  97406. declare module BABYLON {
  97407. interface FreeCameraInputsManager {
  97408. /**
  97409. * Add virtual joystick input support to the input manager.
  97410. * @returns the current input manager
  97411. */
  97412. addVirtualJoystick(): FreeCameraInputsManager;
  97413. }
  97414. /**
  97415. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  97416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97417. */
  97418. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  97419. /**
  97420. * Defines the camera the input is attached to.
  97421. */
  97422. camera: FreeCamera;
  97423. private _leftjoystick;
  97424. private _rightjoystick;
  97425. /**
  97426. * Gets the left stick of the virtual joystick.
  97427. * @returns The virtual Joystick
  97428. */
  97429. getLeftJoystick(): VirtualJoystick;
  97430. /**
  97431. * Gets the right stick of the virtual joystick.
  97432. * @returns The virtual Joystick
  97433. */
  97434. getRightJoystick(): VirtualJoystick;
  97435. /**
  97436. * Update the current camera state depending on the inputs that have been used this frame.
  97437. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97438. */
  97439. checkInputs(): void;
  97440. /**
  97441. * Attach the input controls to a specific dom element to get the input from.
  97442. * @param element Defines the element the controls should be listened from
  97443. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97444. */
  97445. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97446. /**
  97447. * Detach the current controls from the specified dom element.
  97448. * @param element Defines the element to stop listening the inputs from
  97449. */
  97450. detachControl(element: Nullable<HTMLElement>): void;
  97451. /**
  97452. * Gets the class name of the current intput.
  97453. * @returns the class name
  97454. */
  97455. getClassName(): string;
  97456. /**
  97457. * Get the friendly name associated with the input class.
  97458. * @returns the input friendly name
  97459. */
  97460. getSimpleName(): string;
  97461. }
  97462. }
  97463. declare module BABYLON {
  97464. /**
  97465. * This represents a FPS type of camera controlled by touch.
  97466. * This is like a universal camera minus the Gamepad controls.
  97467. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97468. */
  97469. export class TouchCamera extends FreeCamera {
  97470. /**
  97471. * Defines the touch sensibility for rotation.
  97472. * The higher the faster.
  97473. */
  97474. touchAngularSensibility: number;
  97475. /**
  97476. * Defines the touch sensibility for move.
  97477. * The higher the faster.
  97478. */
  97479. touchMoveSensibility: number;
  97480. /**
  97481. * Instantiates a new touch camera.
  97482. * This represents a FPS type of camera controlled by touch.
  97483. * This is like a universal camera minus the Gamepad controls.
  97484. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97485. * @param name Define the name of the camera in the scene
  97486. * @param position Define the start position of the camera in the scene
  97487. * @param scene Define the scene the camera belongs to
  97488. */
  97489. constructor(name: string, position: Vector3, scene: Scene);
  97490. /**
  97491. * Gets the current object class name.
  97492. * @return the class name
  97493. */
  97494. getClassName(): string;
  97495. /** @hidden */
  97496. _setupInputs(): void;
  97497. }
  97498. }
  97499. declare module BABYLON {
  97500. /**
  97501. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  97502. * being tilted forward or back and left or right.
  97503. */
  97504. export class DeviceOrientationCamera extends FreeCamera {
  97505. private _initialQuaternion;
  97506. private _quaternionCache;
  97507. private _tmpDragQuaternion;
  97508. /**
  97509. * Creates a new device orientation camera
  97510. * @param name The name of the camera
  97511. * @param position The start position camera
  97512. * @param scene The scene the camera belongs to
  97513. */
  97514. constructor(name: string, position: Vector3, scene: Scene);
  97515. /**
  97516. * @hidden
  97517. * Disabled pointer input on first orientation sensor update (Default: true)
  97518. */
  97519. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  97520. private _dragFactor;
  97521. /**
  97522. * Enabled turning on the y axis when the orientation sensor is active
  97523. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  97524. */
  97525. enableHorizontalDragging(dragFactor?: number): void;
  97526. /**
  97527. * Gets the current instance class name ("DeviceOrientationCamera").
  97528. * This helps avoiding instanceof at run time.
  97529. * @returns the class name
  97530. */
  97531. getClassName(): string;
  97532. /**
  97533. * @hidden
  97534. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  97535. */
  97536. _checkInputs(): void;
  97537. /**
  97538. * Reset the camera to its default orientation on the specified axis only.
  97539. * @param axis The axis to reset
  97540. */
  97541. resetToCurrentRotation(axis?: Axis): void;
  97542. }
  97543. }
  97544. declare module BABYLON {
  97545. /**
  97546. * Defines supported buttons for XBox360 compatible gamepads
  97547. */
  97548. export enum Xbox360Button {
  97549. /** A */
  97550. A = 0,
  97551. /** B */
  97552. B = 1,
  97553. /** X */
  97554. X = 2,
  97555. /** Y */
  97556. Y = 3,
  97557. /** Start */
  97558. Start = 4,
  97559. /** Back */
  97560. Back = 5,
  97561. /** Left button */
  97562. LB = 6,
  97563. /** Right button */
  97564. RB = 7,
  97565. /** Left stick */
  97566. LeftStick = 8,
  97567. /** Right stick */
  97568. RightStick = 9
  97569. }
  97570. /** Defines values for XBox360 DPad */
  97571. export enum Xbox360Dpad {
  97572. /** Up */
  97573. Up = 0,
  97574. /** Down */
  97575. Down = 1,
  97576. /** Left */
  97577. Left = 2,
  97578. /** Right */
  97579. Right = 3
  97580. }
  97581. /**
  97582. * Defines a XBox360 gamepad
  97583. */
  97584. export class Xbox360Pad extends Gamepad {
  97585. private _leftTrigger;
  97586. private _rightTrigger;
  97587. private _onlefttriggerchanged;
  97588. private _onrighttriggerchanged;
  97589. private _onbuttondown;
  97590. private _onbuttonup;
  97591. private _ondpaddown;
  97592. private _ondpadup;
  97593. /** Observable raised when a button is pressed */
  97594. onButtonDownObservable: Observable<Xbox360Button>;
  97595. /** Observable raised when a button is released */
  97596. onButtonUpObservable: Observable<Xbox360Button>;
  97597. /** Observable raised when a pad is pressed */
  97598. onPadDownObservable: Observable<Xbox360Dpad>;
  97599. /** Observable raised when a pad is released */
  97600. onPadUpObservable: Observable<Xbox360Dpad>;
  97601. private _buttonA;
  97602. private _buttonB;
  97603. private _buttonX;
  97604. private _buttonY;
  97605. private _buttonBack;
  97606. private _buttonStart;
  97607. private _buttonLB;
  97608. private _buttonRB;
  97609. private _buttonLeftStick;
  97610. private _buttonRightStick;
  97611. private _dPadUp;
  97612. private _dPadDown;
  97613. private _dPadLeft;
  97614. private _dPadRight;
  97615. private _isXboxOnePad;
  97616. /**
  97617. * Creates a new XBox360 gamepad object
  97618. * @param id defines the id of this gamepad
  97619. * @param index defines its index
  97620. * @param gamepad defines the internal HTML gamepad object
  97621. * @param xboxOne defines if it is a XBox One gamepad
  97622. */
  97623. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  97624. /**
  97625. * Defines the callback to call when left trigger is pressed
  97626. * @param callback defines the callback to use
  97627. */
  97628. onlefttriggerchanged(callback: (value: number) => void): void;
  97629. /**
  97630. * Defines the callback to call when right trigger is pressed
  97631. * @param callback defines the callback to use
  97632. */
  97633. onrighttriggerchanged(callback: (value: number) => void): void;
  97634. /**
  97635. * Gets the left trigger value
  97636. */
  97637. /**
  97638. * Sets the left trigger value
  97639. */
  97640. leftTrigger: number;
  97641. /**
  97642. * Gets the right trigger value
  97643. */
  97644. /**
  97645. * Sets the right trigger value
  97646. */
  97647. rightTrigger: number;
  97648. /**
  97649. * Defines the callback to call when a button is pressed
  97650. * @param callback defines the callback to use
  97651. */
  97652. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  97653. /**
  97654. * Defines the callback to call when a button is released
  97655. * @param callback defines the callback to use
  97656. */
  97657. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  97658. /**
  97659. * Defines the callback to call when a pad is pressed
  97660. * @param callback defines the callback to use
  97661. */
  97662. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  97663. /**
  97664. * Defines the callback to call when a pad is released
  97665. * @param callback defines the callback to use
  97666. */
  97667. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  97668. private _setButtonValue;
  97669. private _setDPadValue;
  97670. /**
  97671. * Gets the value of the `A` button
  97672. */
  97673. /**
  97674. * Sets the value of the `A` button
  97675. */
  97676. buttonA: number;
  97677. /**
  97678. * Gets the value of the `B` button
  97679. */
  97680. /**
  97681. * Sets the value of the `B` button
  97682. */
  97683. buttonB: number;
  97684. /**
  97685. * Gets the value of the `X` button
  97686. */
  97687. /**
  97688. * Sets the value of the `X` button
  97689. */
  97690. buttonX: number;
  97691. /**
  97692. * Gets the value of the `Y` button
  97693. */
  97694. /**
  97695. * Sets the value of the `Y` button
  97696. */
  97697. buttonY: number;
  97698. /**
  97699. * Gets the value of the `Start` button
  97700. */
  97701. /**
  97702. * Sets the value of the `Start` button
  97703. */
  97704. buttonStart: number;
  97705. /**
  97706. * Gets the value of the `Back` button
  97707. */
  97708. /**
  97709. * Sets the value of the `Back` button
  97710. */
  97711. buttonBack: number;
  97712. /**
  97713. * Gets the value of the `Left` button
  97714. */
  97715. /**
  97716. * Sets the value of the `Left` button
  97717. */
  97718. buttonLB: number;
  97719. /**
  97720. * Gets the value of the `Right` button
  97721. */
  97722. /**
  97723. * Sets the value of the `Right` button
  97724. */
  97725. buttonRB: number;
  97726. /**
  97727. * Gets the value of the Left joystick
  97728. */
  97729. /**
  97730. * Sets the value of the Left joystick
  97731. */
  97732. buttonLeftStick: number;
  97733. /**
  97734. * Gets the value of the Right joystick
  97735. */
  97736. /**
  97737. * Sets the value of the Right joystick
  97738. */
  97739. buttonRightStick: number;
  97740. /**
  97741. * Gets the value of D-pad up
  97742. */
  97743. /**
  97744. * Sets the value of D-pad up
  97745. */
  97746. dPadUp: number;
  97747. /**
  97748. * Gets the value of D-pad down
  97749. */
  97750. /**
  97751. * Sets the value of D-pad down
  97752. */
  97753. dPadDown: number;
  97754. /**
  97755. * Gets the value of D-pad left
  97756. */
  97757. /**
  97758. * Sets the value of D-pad left
  97759. */
  97760. dPadLeft: number;
  97761. /**
  97762. * Gets the value of D-pad right
  97763. */
  97764. /**
  97765. * Sets the value of D-pad right
  97766. */
  97767. dPadRight: number;
  97768. /**
  97769. * Force the gamepad to synchronize with device values
  97770. */
  97771. update(): void;
  97772. /**
  97773. * Disposes the gamepad
  97774. */
  97775. dispose(): void;
  97776. }
  97777. }
  97778. declare module BABYLON {
  97779. /**
  97780. * Manager for handling gamepads
  97781. */
  97782. export class GamepadManager {
  97783. private _scene?;
  97784. private _babylonGamepads;
  97785. private _oneGamepadConnected;
  97786. /** @hidden */
  97787. _isMonitoring: boolean;
  97788. private _gamepadEventSupported;
  97789. private _gamepadSupport;
  97790. /**
  97791. * observable to be triggered when the gamepad controller has been connected
  97792. */
  97793. onGamepadConnectedObservable: Observable<Gamepad>;
  97794. /**
  97795. * observable to be triggered when the gamepad controller has been disconnected
  97796. */
  97797. onGamepadDisconnectedObservable: Observable<Gamepad>;
  97798. private _onGamepadConnectedEvent;
  97799. private _onGamepadDisconnectedEvent;
  97800. /**
  97801. * Initializes the gamepad manager
  97802. * @param _scene BabylonJS scene
  97803. */
  97804. constructor(_scene?: Scene | undefined);
  97805. /**
  97806. * The gamepads in the game pad manager
  97807. */
  97808. readonly gamepads: Gamepad[];
  97809. /**
  97810. * Get the gamepad controllers based on type
  97811. * @param type The type of gamepad controller
  97812. * @returns Nullable gamepad
  97813. */
  97814. getGamepadByType(type?: number): Nullable<Gamepad>;
  97815. /**
  97816. * Disposes the gamepad manager
  97817. */
  97818. dispose(): void;
  97819. private _addNewGamepad;
  97820. private _startMonitoringGamepads;
  97821. private _stopMonitoringGamepads;
  97822. /** @hidden */
  97823. _checkGamepadsStatus(): void;
  97824. private _updateGamepadObjects;
  97825. }
  97826. }
  97827. declare module BABYLON {
  97828. interface Scene {
  97829. /** @hidden */
  97830. _gamepadManager: Nullable<GamepadManager>;
  97831. /**
  97832. * Gets the gamepad manager associated with the scene
  97833. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  97834. */
  97835. gamepadManager: GamepadManager;
  97836. }
  97837. /**
  97838. * Interface representing a free camera inputs manager
  97839. */
  97840. interface FreeCameraInputsManager {
  97841. /**
  97842. * Adds gamepad input support to the FreeCameraInputsManager.
  97843. * @returns the FreeCameraInputsManager
  97844. */
  97845. addGamepad(): FreeCameraInputsManager;
  97846. }
  97847. /**
  97848. * Interface representing an arc rotate camera inputs manager
  97849. */
  97850. interface ArcRotateCameraInputsManager {
  97851. /**
  97852. * Adds gamepad input support to the ArcRotateCamera InputManager.
  97853. * @returns the camera inputs manager
  97854. */
  97855. addGamepad(): ArcRotateCameraInputsManager;
  97856. }
  97857. /**
  97858. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  97859. */
  97860. export class GamepadSystemSceneComponent implements ISceneComponent {
  97861. /**
  97862. * The component name helpfull to identify the component in the list of scene components.
  97863. */
  97864. readonly name: string;
  97865. /**
  97866. * The scene the component belongs to.
  97867. */
  97868. scene: Scene;
  97869. /**
  97870. * Creates a new instance of the component for the given scene
  97871. * @param scene Defines the scene to register the component in
  97872. */
  97873. constructor(scene: Scene);
  97874. /**
  97875. * Registers the component in a given scene
  97876. */
  97877. register(): void;
  97878. /**
  97879. * Rebuilds the elements related to this component in case of
  97880. * context lost for instance.
  97881. */
  97882. rebuild(): void;
  97883. /**
  97884. * Disposes the component and the associated ressources
  97885. */
  97886. dispose(): void;
  97887. private _beforeCameraUpdate;
  97888. }
  97889. }
  97890. declare module BABYLON {
  97891. /**
  97892. * 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,
  97893. * which still works and will still be found in many Playgrounds.
  97894. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97895. */
  97896. export class UniversalCamera extends TouchCamera {
  97897. /**
  97898. * Defines the gamepad rotation sensiblity.
  97899. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97900. */
  97901. gamepadAngularSensibility: number;
  97902. /**
  97903. * Defines the gamepad move sensiblity.
  97904. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97905. */
  97906. gamepadMoveSensibility: number;
  97907. /**
  97908. * 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,
  97909. * which still works and will still be found in many Playgrounds.
  97910. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97911. * @param name Define the name of the camera in the scene
  97912. * @param position Define the start position of the camera in the scene
  97913. * @param scene Define the scene the camera belongs to
  97914. */
  97915. constructor(name: string, position: Vector3, scene: Scene);
  97916. /**
  97917. * Gets the current object class name.
  97918. * @return the class name
  97919. */
  97920. getClassName(): string;
  97921. }
  97922. }
  97923. declare module BABYLON {
  97924. /**
  97925. * This represents a FPS type of camera. This is only here for back compat purpose.
  97926. * Please use the UniversalCamera instead as both are identical.
  97927. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97928. */
  97929. export class GamepadCamera extends UniversalCamera {
  97930. /**
  97931. * Instantiates a new Gamepad Camera
  97932. * This represents a FPS type of camera. This is only here for back compat purpose.
  97933. * Please use the UniversalCamera instead as both are identical.
  97934. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97935. * @param name Define the name of the camera in the scene
  97936. * @param position Define the start position of the camera in the scene
  97937. * @param scene Define the scene the camera belongs to
  97938. */
  97939. constructor(name: string, position: Vector3, scene: Scene);
  97940. /**
  97941. * Gets the current object class name.
  97942. * @return the class name
  97943. */
  97944. getClassName(): string;
  97945. }
  97946. }
  97947. declare module BABYLON {
  97948. /** @hidden */
  97949. export var passPixelShader: {
  97950. name: string;
  97951. shader: string;
  97952. };
  97953. }
  97954. declare module BABYLON {
  97955. /** @hidden */
  97956. export var passCubePixelShader: {
  97957. name: string;
  97958. shader: string;
  97959. };
  97960. }
  97961. declare module BABYLON {
  97962. /**
  97963. * PassPostProcess which produces an output the same as it's input
  97964. */
  97965. export class PassPostProcess extends PostProcess {
  97966. /**
  97967. * Creates the PassPostProcess
  97968. * @param name The name of the effect.
  97969. * @param options The required width/height ratio to downsize to before computing the render pass.
  97970. * @param camera The camera to apply the render pass to.
  97971. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97972. * @param engine The engine which the post process will be applied. (default: current engine)
  97973. * @param reusable If the post process can be reused on the same frame. (default: false)
  97974. * @param textureType The type of texture to be used when performing the post processing.
  97975. * @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)
  97976. */
  97977. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97978. }
  97979. /**
  97980. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  97981. */
  97982. export class PassCubePostProcess extends PostProcess {
  97983. private _face;
  97984. /**
  97985. * Gets or sets the cube face to display.
  97986. * * 0 is +X
  97987. * * 1 is -X
  97988. * * 2 is +Y
  97989. * * 3 is -Y
  97990. * * 4 is +Z
  97991. * * 5 is -Z
  97992. */
  97993. face: number;
  97994. /**
  97995. * Creates the PassCubePostProcess
  97996. * @param name The name of the effect.
  97997. * @param options The required width/height ratio to downsize to before computing the render pass.
  97998. * @param camera The camera to apply the render pass to.
  97999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  98000. * @param engine The engine which the post process will be applied. (default: current engine)
  98001. * @param reusable If the post process can be reused on the same frame. (default: false)
  98002. * @param textureType The type of texture to be used when performing the post processing.
  98003. * @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)
  98004. */
  98005. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  98006. }
  98007. }
  98008. declare module BABYLON {
  98009. /** @hidden */
  98010. export var anaglyphPixelShader: {
  98011. name: string;
  98012. shader: string;
  98013. };
  98014. }
  98015. declare module BABYLON {
  98016. /**
  98017. * Postprocess used to generate anaglyphic rendering
  98018. */
  98019. export class AnaglyphPostProcess extends PostProcess {
  98020. private _passedProcess;
  98021. /**
  98022. * Creates a new AnaglyphPostProcess
  98023. * @param name defines postprocess name
  98024. * @param options defines creation options or target ratio scale
  98025. * @param rigCameras defines cameras using this postprocess
  98026. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  98027. * @param engine defines hosting engine
  98028. * @param reusable defines if the postprocess will be reused multiple times per frame
  98029. */
  98030. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  98031. }
  98032. }
  98033. declare module BABYLON {
  98034. /**
  98035. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  98036. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  98037. */
  98038. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  98039. /**
  98040. * Creates a new AnaglyphArcRotateCamera
  98041. * @param name defines camera name
  98042. * @param alpha defines alpha angle (in radians)
  98043. * @param beta defines beta angle (in radians)
  98044. * @param radius defines radius
  98045. * @param target defines camera target
  98046. * @param interaxialDistance defines distance between each color axis
  98047. * @param scene defines the hosting scene
  98048. */
  98049. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  98050. /**
  98051. * Gets camera class name
  98052. * @returns AnaglyphArcRotateCamera
  98053. */
  98054. getClassName(): string;
  98055. }
  98056. }
  98057. declare module BABYLON {
  98058. /**
  98059. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  98060. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  98061. */
  98062. export class AnaglyphFreeCamera extends FreeCamera {
  98063. /**
  98064. * Creates a new AnaglyphFreeCamera
  98065. * @param name defines camera name
  98066. * @param position defines initial position
  98067. * @param interaxialDistance defines distance between each color axis
  98068. * @param scene defines the hosting scene
  98069. */
  98070. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  98071. /**
  98072. * Gets camera class name
  98073. * @returns AnaglyphFreeCamera
  98074. */
  98075. getClassName(): string;
  98076. }
  98077. }
  98078. declare module BABYLON {
  98079. /**
  98080. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  98081. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  98082. */
  98083. export class AnaglyphGamepadCamera extends GamepadCamera {
  98084. /**
  98085. * Creates a new AnaglyphGamepadCamera
  98086. * @param name defines camera name
  98087. * @param position defines initial position
  98088. * @param interaxialDistance defines distance between each color axis
  98089. * @param scene defines the hosting scene
  98090. */
  98091. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  98092. /**
  98093. * Gets camera class name
  98094. * @returns AnaglyphGamepadCamera
  98095. */
  98096. getClassName(): string;
  98097. }
  98098. }
  98099. declare module BABYLON {
  98100. /**
  98101. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  98102. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  98103. */
  98104. export class AnaglyphUniversalCamera extends UniversalCamera {
  98105. /**
  98106. * Creates a new AnaglyphUniversalCamera
  98107. * @param name defines camera name
  98108. * @param position defines initial position
  98109. * @param interaxialDistance defines distance between each color axis
  98110. * @param scene defines the hosting scene
  98111. */
  98112. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  98113. /**
  98114. * Gets camera class name
  98115. * @returns AnaglyphUniversalCamera
  98116. */
  98117. getClassName(): string;
  98118. }
  98119. }
  98120. declare module BABYLON {
  98121. /** @hidden */
  98122. export var stereoscopicInterlacePixelShader: {
  98123. name: string;
  98124. shader: string;
  98125. };
  98126. }
  98127. declare module BABYLON {
  98128. /**
  98129. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  98130. */
  98131. export class StereoscopicInterlacePostProcess extends PostProcess {
  98132. private _stepSize;
  98133. private _passedProcess;
  98134. /**
  98135. * Initializes a StereoscopicInterlacePostProcess
  98136. * @param name The name of the effect.
  98137. * @param rigCameras The rig cameras to be appled to the post process
  98138. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  98139. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  98140. * @param engine The engine which the post process will be applied. (default: current engine)
  98141. * @param reusable If the post process can be reused on the same frame. (default: false)
  98142. */
  98143. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  98144. }
  98145. }
  98146. declare module BABYLON {
  98147. /**
  98148. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  98149. * @see http://doc.babylonjs.com/features/cameras
  98150. */
  98151. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  98152. /**
  98153. * Creates a new StereoscopicArcRotateCamera
  98154. * @param name defines camera name
  98155. * @param alpha defines alpha angle (in radians)
  98156. * @param beta defines beta angle (in radians)
  98157. * @param radius defines radius
  98158. * @param target defines camera target
  98159. * @param interaxialDistance defines distance between each color axis
  98160. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  98161. * @param scene defines the hosting scene
  98162. */
  98163. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  98164. /**
  98165. * Gets camera class name
  98166. * @returns StereoscopicArcRotateCamera
  98167. */
  98168. getClassName(): string;
  98169. }
  98170. }
  98171. declare module BABYLON {
  98172. /**
  98173. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  98174. * @see http://doc.babylonjs.com/features/cameras
  98175. */
  98176. export class StereoscopicFreeCamera extends FreeCamera {
  98177. /**
  98178. * Creates a new StereoscopicFreeCamera
  98179. * @param name defines camera name
  98180. * @param position defines initial position
  98181. * @param interaxialDistance defines distance between each color axis
  98182. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  98183. * @param scene defines the hosting scene
  98184. */
  98185. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  98186. /**
  98187. * Gets camera class name
  98188. * @returns StereoscopicFreeCamera
  98189. */
  98190. getClassName(): string;
  98191. }
  98192. }
  98193. declare module BABYLON {
  98194. /**
  98195. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  98196. * @see http://doc.babylonjs.com/features/cameras
  98197. */
  98198. export class StereoscopicGamepadCamera extends GamepadCamera {
  98199. /**
  98200. * Creates a new StereoscopicGamepadCamera
  98201. * @param name defines camera name
  98202. * @param position defines initial position
  98203. * @param interaxialDistance defines distance between each color axis
  98204. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  98205. * @param scene defines the hosting scene
  98206. */
  98207. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  98208. /**
  98209. * Gets camera class name
  98210. * @returns StereoscopicGamepadCamera
  98211. */
  98212. getClassName(): string;
  98213. }
  98214. }
  98215. declare module BABYLON {
  98216. /**
  98217. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  98218. * @see http://doc.babylonjs.com/features/cameras
  98219. */
  98220. export class StereoscopicUniversalCamera extends UniversalCamera {
  98221. /**
  98222. * Creates a new StereoscopicUniversalCamera
  98223. * @param name defines camera name
  98224. * @param position defines initial position
  98225. * @param interaxialDistance defines distance between each color axis
  98226. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  98227. * @param scene defines the hosting scene
  98228. */
  98229. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  98230. /**
  98231. * Gets camera class name
  98232. * @returns StereoscopicUniversalCamera
  98233. */
  98234. getClassName(): string;
  98235. }
  98236. }
  98237. declare module BABYLON {
  98238. /**
  98239. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98240. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  98241. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  98242. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  98243. */
  98244. export class VirtualJoysticksCamera extends FreeCamera {
  98245. /**
  98246. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  98247. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  98248. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  98249. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  98250. * @param name Define the name of the camera in the scene
  98251. * @param position Define the start position of the camera in the scene
  98252. * @param scene Define the scene the camera belongs to
  98253. */
  98254. constructor(name: string, position: Vector3, scene: Scene);
  98255. /**
  98256. * Gets the current object class name.
  98257. * @return the class name
  98258. */
  98259. getClassName(): string;
  98260. }
  98261. }
  98262. declare module BABYLON {
  98263. /**
  98264. * This represents all the required metrics to create a VR camera.
  98265. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  98266. */
  98267. export class VRCameraMetrics {
  98268. /**
  98269. * Define the horizontal resolution off the screen.
  98270. */
  98271. hResolution: number;
  98272. /**
  98273. * Define the vertical resolution off the screen.
  98274. */
  98275. vResolution: number;
  98276. /**
  98277. * Define the horizontal screen size.
  98278. */
  98279. hScreenSize: number;
  98280. /**
  98281. * Define the vertical screen size.
  98282. */
  98283. vScreenSize: number;
  98284. /**
  98285. * Define the vertical screen center position.
  98286. */
  98287. vScreenCenter: number;
  98288. /**
  98289. * Define the distance of the eyes to the screen.
  98290. */
  98291. eyeToScreenDistance: number;
  98292. /**
  98293. * Define the distance between both lenses
  98294. */
  98295. lensSeparationDistance: number;
  98296. /**
  98297. * Define the distance between both viewer's eyes.
  98298. */
  98299. interpupillaryDistance: number;
  98300. /**
  98301. * Define the distortion factor of the VR postprocess.
  98302. * Please, touch with care.
  98303. */
  98304. distortionK: number[];
  98305. /**
  98306. * Define the chromatic aberration correction factors for the VR post process.
  98307. */
  98308. chromaAbCorrection: number[];
  98309. /**
  98310. * Define the scale factor of the post process.
  98311. * The smaller the better but the slower.
  98312. */
  98313. postProcessScaleFactor: number;
  98314. /**
  98315. * Define an offset for the lens center.
  98316. */
  98317. lensCenterOffset: number;
  98318. /**
  98319. * Define if the current vr camera should compensate the distortion of the lense or not.
  98320. */
  98321. compensateDistortion: boolean;
  98322. /**
  98323. * Defines if multiview should be enabled when rendering (Default: false)
  98324. */
  98325. multiviewEnabled: boolean;
  98326. /**
  98327. * Gets the rendering aspect ratio based on the provided resolutions.
  98328. */
  98329. readonly aspectRatio: number;
  98330. /**
  98331. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  98332. */
  98333. readonly aspectRatioFov: number;
  98334. /**
  98335. * @hidden
  98336. */
  98337. readonly leftHMatrix: Matrix;
  98338. /**
  98339. * @hidden
  98340. */
  98341. readonly rightHMatrix: Matrix;
  98342. /**
  98343. * @hidden
  98344. */
  98345. readonly leftPreViewMatrix: Matrix;
  98346. /**
  98347. * @hidden
  98348. */
  98349. readonly rightPreViewMatrix: Matrix;
  98350. /**
  98351. * Get the default VRMetrics based on the most generic setup.
  98352. * @returns the default vr metrics
  98353. */
  98354. static GetDefault(): VRCameraMetrics;
  98355. }
  98356. }
  98357. declare module BABYLON {
  98358. /** @hidden */
  98359. export var vrDistortionCorrectionPixelShader: {
  98360. name: string;
  98361. shader: string;
  98362. };
  98363. }
  98364. declare module BABYLON {
  98365. /**
  98366. * VRDistortionCorrectionPostProcess used for mobile VR
  98367. */
  98368. export class VRDistortionCorrectionPostProcess extends PostProcess {
  98369. private _isRightEye;
  98370. private _distortionFactors;
  98371. private _postProcessScaleFactor;
  98372. private _lensCenterOffset;
  98373. private _scaleIn;
  98374. private _scaleFactor;
  98375. private _lensCenter;
  98376. /**
  98377. * Initializes the VRDistortionCorrectionPostProcess
  98378. * @param name The name of the effect.
  98379. * @param camera The camera to apply the render pass to.
  98380. * @param isRightEye If this is for the right eye distortion
  98381. * @param vrMetrics All the required metrics for the VR camera
  98382. */
  98383. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  98384. }
  98385. }
  98386. declare module BABYLON {
  98387. /**
  98388. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  98389. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  98390. */
  98391. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  98392. /**
  98393. * Creates a new VRDeviceOrientationArcRotateCamera
  98394. * @param name defines camera name
  98395. * @param alpha defines the camera rotation along the logitudinal axis
  98396. * @param beta defines the camera rotation along the latitudinal axis
  98397. * @param radius defines the camera distance from its target
  98398. * @param target defines the camera target
  98399. * @param scene defines the scene the camera belongs to
  98400. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  98401. * @param vrCameraMetrics defines the vr metrics associated to the camera
  98402. */
  98403. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  98404. /**
  98405. * Gets camera class name
  98406. * @returns VRDeviceOrientationArcRotateCamera
  98407. */
  98408. getClassName(): string;
  98409. }
  98410. }
  98411. declare module BABYLON {
  98412. /**
  98413. * Camera used to simulate VR rendering (based on FreeCamera)
  98414. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  98415. */
  98416. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  98417. /**
  98418. * Creates a new VRDeviceOrientationFreeCamera
  98419. * @param name defines camera name
  98420. * @param position defines the start position of the camera
  98421. * @param scene defines the scene the camera belongs to
  98422. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  98423. * @param vrCameraMetrics defines the vr metrics associated to the camera
  98424. */
  98425. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  98426. /**
  98427. * Gets camera class name
  98428. * @returns VRDeviceOrientationFreeCamera
  98429. */
  98430. getClassName(): string;
  98431. }
  98432. }
  98433. declare module BABYLON {
  98434. /**
  98435. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  98436. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  98437. */
  98438. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  98439. /**
  98440. * Creates a new VRDeviceOrientationGamepadCamera
  98441. * @param name defines camera name
  98442. * @param position defines the start position of the camera
  98443. * @param scene defines the scene the camera belongs to
  98444. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  98445. * @param vrCameraMetrics defines the vr metrics associated to the camera
  98446. */
  98447. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  98448. /**
  98449. * Gets camera class name
  98450. * @returns VRDeviceOrientationGamepadCamera
  98451. */
  98452. getClassName(): string;
  98453. }
  98454. }
  98455. declare module BABYLON {
  98456. /**
  98457. * Base class of materials working in push mode in babylon JS
  98458. * @hidden
  98459. */
  98460. export class PushMaterial extends Material {
  98461. protected _activeEffect: Effect;
  98462. protected _normalMatrix: Matrix;
  98463. /**
  98464. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98465. * This means that the material can keep using a previous shader while a new one is being compiled.
  98466. * This is mostly used when shader parallel compilation is supported (true by default)
  98467. */
  98468. allowShaderHotSwapping: boolean;
  98469. constructor(name: string, scene: Scene);
  98470. getEffect(): Effect;
  98471. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98472. /**
  98473. * Binds the given world matrix to the active effect
  98474. *
  98475. * @param world the matrix to bind
  98476. */
  98477. bindOnlyWorldMatrix(world: Matrix): void;
  98478. /**
  98479. * Binds the given normal matrix to the active effect
  98480. *
  98481. * @param normalMatrix the matrix to bind
  98482. */
  98483. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98484. bind(world: Matrix, mesh?: Mesh): void;
  98485. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98486. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98487. }
  98488. }
  98489. declare module BABYLON {
  98490. /**
  98491. * This groups all the flags used to control the materials channel.
  98492. */
  98493. export class MaterialFlags {
  98494. private static _DiffuseTextureEnabled;
  98495. /**
  98496. * Are diffuse textures enabled in the application.
  98497. */
  98498. static DiffuseTextureEnabled: boolean;
  98499. private static _AmbientTextureEnabled;
  98500. /**
  98501. * Are ambient textures enabled in the application.
  98502. */
  98503. static AmbientTextureEnabled: boolean;
  98504. private static _OpacityTextureEnabled;
  98505. /**
  98506. * Are opacity textures enabled in the application.
  98507. */
  98508. static OpacityTextureEnabled: boolean;
  98509. private static _ReflectionTextureEnabled;
  98510. /**
  98511. * Are reflection textures enabled in the application.
  98512. */
  98513. static ReflectionTextureEnabled: boolean;
  98514. private static _EmissiveTextureEnabled;
  98515. /**
  98516. * Are emissive textures enabled in the application.
  98517. */
  98518. static EmissiveTextureEnabled: boolean;
  98519. private static _SpecularTextureEnabled;
  98520. /**
  98521. * Are specular textures enabled in the application.
  98522. */
  98523. static SpecularTextureEnabled: boolean;
  98524. private static _BumpTextureEnabled;
  98525. /**
  98526. * Are bump textures enabled in the application.
  98527. */
  98528. static BumpTextureEnabled: boolean;
  98529. private static _LightmapTextureEnabled;
  98530. /**
  98531. * Are lightmap textures enabled in the application.
  98532. */
  98533. static LightmapTextureEnabled: boolean;
  98534. private static _RefractionTextureEnabled;
  98535. /**
  98536. * Are refraction textures enabled in the application.
  98537. */
  98538. static RefractionTextureEnabled: boolean;
  98539. private static _ColorGradingTextureEnabled;
  98540. /**
  98541. * Are color grading textures enabled in the application.
  98542. */
  98543. static ColorGradingTextureEnabled: boolean;
  98544. private static _FresnelEnabled;
  98545. /**
  98546. * Are fresnels enabled in the application.
  98547. */
  98548. static FresnelEnabled: boolean;
  98549. private static _ClearCoatTextureEnabled;
  98550. /**
  98551. * Are clear coat textures enabled in the application.
  98552. */
  98553. static ClearCoatTextureEnabled: boolean;
  98554. private static _ClearCoatBumpTextureEnabled;
  98555. /**
  98556. * Are clear coat bump textures enabled in the application.
  98557. */
  98558. static ClearCoatBumpTextureEnabled: boolean;
  98559. private static _ClearCoatTintTextureEnabled;
  98560. /**
  98561. * Are clear coat tint textures enabled in the application.
  98562. */
  98563. static ClearCoatTintTextureEnabled: boolean;
  98564. private static _SheenTextureEnabled;
  98565. /**
  98566. * Are sheen textures enabled in the application.
  98567. */
  98568. static SheenTextureEnabled: boolean;
  98569. private static _AnisotropicTextureEnabled;
  98570. /**
  98571. * Are anisotropic textures enabled in the application.
  98572. */
  98573. static AnisotropicTextureEnabled: boolean;
  98574. private static _ThicknessTextureEnabled;
  98575. /**
  98576. * Are thickness textures enabled in the application.
  98577. */
  98578. static ThicknessTextureEnabled: boolean;
  98579. }
  98580. }
  98581. declare module BABYLON {
  98582. /** @hidden */
  98583. export var defaultFragmentDeclaration: {
  98584. name: string;
  98585. shader: string;
  98586. };
  98587. }
  98588. declare module BABYLON {
  98589. /** @hidden */
  98590. export var defaultUboDeclaration: {
  98591. name: string;
  98592. shader: string;
  98593. };
  98594. }
  98595. declare module BABYLON {
  98596. /** @hidden */
  98597. export var lightFragmentDeclaration: {
  98598. name: string;
  98599. shader: string;
  98600. };
  98601. }
  98602. declare module BABYLON {
  98603. /** @hidden */
  98604. export var lightUboDeclaration: {
  98605. name: string;
  98606. shader: string;
  98607. };
  98608. }
  98609. declare module BABYLON {
  98610. /** @hidden */
  98611. export var lightsFragmentFunctions: {
  98612. name: string;
  98613. shader: string;
  98614. };
  98615. }
  98616. declare module BABYLON {
  98617. /** @hidden */
  98618. export var shadowsFragmentFunctions: {
  98619. name: string;
  98620. shader: string;
  98621. };
  98622. }
  98623. declare module BABYLON {
  98624. /** @hidden */
  98625. export var fresnelFunction: {
  98626. name: string;
  98627. shader: string;
  98628. };
  98629. }
  98630. declare module BABYLON {
  98631. /** @hidden */
  98632. export var reflectionFunction: {
  98633. name: string;
  98634. shader: string;
  98635. };
  98636. }
  98637. declare module BABYLON {
  98638. /** @hidden */
  98639. export var bumpFragmentFunctions: {
  98640. name: string;
  98641. shader: string;
  98642. };
  98643. }
  98644. declare module BABYLON {
  98645. /** @hidden */
  98646. export var logDepthDeclaration: {
  98647. name: string;
  98648. shader: string;
  98649. };
  98650. }
  98651. declare module BABYLON {
  98652. /** @hidden */
  98653. export var bumpFragment: {
  98654. name: string;
  98655. shader: string;
  98656. };
  98657. }
  98658. declare module BABYLON {
  98659. /** @hidden */
  98660. export var depthPrePass: {
  98661. name: string;
  98662. shader: string;
  98663. };
  98664. }
  98665. declare module BABYLON {
  98666. /** @hidden */
  98667. export var lightFragment: {
  98668. name: string;
  98669. shader: string;
  98670. };
  98671. }
  98672. declare module BABYLON {
  98673. /** @hidden */
  98674. export var logDepthFragment: {
  98675. name: string;
  98676. shader: string;
  98677. };
  98678. }
  98679. declare module BABYLON {
  98680. /** @hidden */
  98681. export var defaultPixelShader: {
  98682. name: string;
  98683. shader: string;
  98684. };
  98685. }
  98686. declare module BABYLON {
  98687. /** @hidden */
  98688. export var defaultVertexDeclaration: {
  98689. name: string;
  98690. shader: string;
  98691. };
  98692. }
  98693. declare module BABYLON {
  98694. /** @hidden */
  98695. export var bumpVertexDeclaration: {
  98696. name: string;
  98697. shader: string;
  98698. };
  98699. }
  98700. declare module BABYLON {
  98701. /** @hidden */
  98702. export var bumpVertex: {
  98703. name: string;
  98704. shader: string;
  98705. };
  98706. }
  98707. declare module BABYLON {
  98708. /** @hidden */
  98709. export var fogVertex: {
  98710. name: string;
  98711. shader: string;
  98712. };
  98713. }
  98714. declare module BABYLON {
  98715. /** @hidden */
  98716. export var shadowsVertex: {
  98717. name: string;
  98718. shader: string;
  98719. };
  98720. }
  98721. declare module BABYLON {
  98722. /** @hidden */
  98723. export var pointCloudVertex: {
  98724. name: string;
  98725. shader: string;
  98726. };
  98727. }
  98728. declare module BABYLON {
  98729. /** @hidden */
  98730. export var logDepthVertex: {
  98731. name: string;
  98732. shader: string;
  98733. };
  98734. }
  98735. declare module BABYLON {
  98736. /** @hidden */
  98737. export var defaultVertexShader: {
  98738. name: string;
  98739. shader: string;
  98740. };
  98741. }
  98742. declare module BABYLON {
  98743. /** @hidden */
  98744. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98745. MAINUV1: boolean;
  98746. MAINUV2: boolean;
  98747. DIFFUSE: boolean;
  98748. DIFFUSEDIRECTUV: number;
  98749. AMBIENT: boolean;
  98750. AMBIENTDIRECTUV: number;
  98751. OPACITY: boolean;
  98752. OPACITYDIRECTUV: number;
  98753. OPACITYRGB: boolean;
  98754. REFLECTION: boolean;
  98755. EMISSIVE: boolean;
  98756. EMISSIVEDIRECTUV: number;
  98757. SPECULAR: boolean;
  98758. SPECULARDIRECTUV: number;
  98759. BUMP: boolean;
  98760. BUMPDIRECTUV: number;
  98761. PARALLAX: boolean;
  98762. PARALLAXOCCLUSION: boolean;
  98763. SPECULAROVERALPHA: boolean;
  98764. CLIPPLANE: boolean;
  98765. CLIPPLANE2: boolean;
  98766. CLIPPLANE3: boolean;
  98767. CLIPPLANE4: boolean;
  98768. ALPHATEST: boolean;
  98769. DEPTHPREPASS: boolean;
  98770. ALPHAFROMDIFFUSE: boolean;
  98771. POINTSIZE: boolean;
  98772. FOG: boolean;
  98773. SPECULARTERM: boolean;
  98774. DIFFUSEFRESNEL: boolean;
  98775. OPACITYFRESNEL: boolean;
  98776. REFLECTIONFRESNEL: boolean;
  98777. REFRACTIONFRESNEL: boolean;
  98778. EMISSIVEFRESNEL: boolean;
  98779. FRESNEL: boolean;
  98780. NORMAL: boolean;
  98781. UV1: boolean;
  98782. UV2: boolean;
  98783. VERTEXCOLOR: boolean;
  98784. VERTEXALPHA: boolean;
  98785. NUM_BONE_INFLUENCERS: number;
  98786. BonesPerMesh: number;
  98787. BONETEXTURE: boolean;
  98788. INSTANCES: boolean;
  98789. GLOSSINESS: boolean;
  98790. ROUGHNESS: boolean;
  98791. EMISSIVEASILLUMINATION: boolean;
  98792. LINKEMISSIVEWITHDIFFUSE: boolean;
  98793. REFLECTIONFRESNELFROMSPECULAR: boolean;
  98794. LIGHTMAP: boolean;
  98795. LIGHTMAPDIRECTUV: number;
  98796. OBJECTSPACE_NORMALMAP: boolean;
  98797. USELIGHTMAPASSHADOWMAP: boolean;
  98798. REFLECTIONMAP_3D: boolean;
  98799. REFLECTIONMAP_SPHERICAL: boolean;
  98800. REFLECTIONMAP_PLANAR: boolean;
  98801. REFLECTIONMAP_CUBIC: boolean;
  98802. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  98803. REFLECTIONMAP_PROJECTION: boolean;
  98804. REFLECTIONMAP_SKYBOX: boolean;
  98805. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  98806. REFLECTIONMAP_EXPLICIT: boolean;
  98807. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  98808. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  98809. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  98810. INVERTCUBICMAP: boolean;
  98811. LOGARITHMICDEPTH: boolean;
  98812. REFRACTION: boolean;
  98813. REFRACTIONMAP_3D: boolean;
  98814. REFLECTIONOVERALPHA: boolean;
  98815. TWOSIDEDLIGHTING: boolean;
  98816. SHADOWFLOAT: boolean;
  98817. MORPHTARGETS: boolean;
  98818. MORPHTARGETS_NORMAL: boolean;
  98819. MORPHTARGETS_TANGENT: boolean;
  98820. NUM_MORPH_INFLUENCERS: number;
  98821. NONUNIFORMSCALING: boolean;
  98822. PREMULTIPLYALPHA: boolean;
  98823. IMAGEPROCESSING: boolean;
  98824. VIGNETTE: boolean;
  98825. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98826. VIGNETTEBLENDMODEOPAQUE: boolean;
  98827. TONEMAPPING: boolean;
  98828. TONEMAPPING_ACES: boolean;
  98829. CONTRAST: boolean;
  98830. COLORCURVES: boolean;
  98831. COLORGRADING: boolean;
  98832. COLORGRADING3D: boolean;
  98833. SAMPLER3DGREENDEPTH: boolean;
  98834. SAMPLER3DBGRMAP: boolean;
  98835. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98836. MULTIVIEW: boolean;
  98837. /**
  98838. * If the reflection texture on this material is in linear color space
  98839. * @hidden
  98840. */
  98841. IS_REFLECTION_LINEAR: boolean;
  98842. /**
  98843. * If the refraction texture on this material is in linear color space
  98844. * @hidden
  98845. */
  98846. IS_REFRACTION_LINEAR: boolean;
  98847. EXPOSURE: boolean;
  98848. constructor();
  98849. setReflectionMode(modeToEnable: string): void;
  98850. }
  98851. /**
  98852. * This is the default material used in Babylon. It is the best trade off between quality
  98853. * and performances.
  98854. * @see http://doc.babylonjs.com/babylon101/materials
  98855. */
  98856. export class StandardMaterial extends PushMaterial {
  98857. private _diffuseTexture;
  98858. /**
  98859. * The basic texture of the material as viewed under a light.
  98860. */
  98861. diffuseTexture: Nullable<BaseTexture>;
  98862. private _ambientTexture;
  98863. /**
  98864. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  98865. */
  98866. ambientTexture: Nullable<BaseTexture>;
  98867. private _opacityTexture;
  98868. /**
  98869. * Define the transparency of the material from a texture.
  98870. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  98871. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  98872. */
  98873. opacityTexture: Nullable<BaseTexture>;
  98874. private _reflectionTexture;
  98875. /**
  98876. * Define the texture used to display the reflection.
  98877. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98878. */
  98879. reflectionTexture: Nullable<BaseTexture>;
  98880. private _emissiveTexture;
  98881. /**
  98882. * Define texture of the material as if self lit.
  98883. * This will be mixed in the final result even in the absence of light.
  98884. */
  98885. emissiveTexture: Nullable<BaseTexture>;
  98886. private _specularTexture;
  98887. /**
  98888. * Define how the color and intensity of the highlight given by the light in the material.
  98889. */
  98890. specularTexture: Nullable<BaseTexture>;
  98891. private _bumpTexture;
  98892. /**
  98893. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  98894. * 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.
  98895. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  98896. */
  98897. bumpTexture: Nullable<BaseTexture>;
  98898. private _lightmapTexture;
  98899. /**
  98900. * Complex lighting can be computationally expensive to compute at runtime.
  98901. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  98902. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  98903. */
  98904. lightmapTexture: Nullable<BaseTexture>;
  98905. private _refractionTexture;
  98906. /**
  98907. * Define the texture used to display the refraction.
  98908. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98909. */
  98910. refractionTexture: Nullable<BaseTexture>;
  98911. /**
  98912. * The color of the material lit by the environmental background lighting.
  98913. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  98914. */
  98915. ambientColor: Color3;
  98916. /**
  98917. * The basic color of the material as viewed under a light.
  98918. */
  98919. diffuseColor: Color3;
  98920. /**
  98921. * Define how the color and intensity of the highlight given by the light in the material.
  98922. */
  98923. specularColor: Color3;
  98924. /**
  98925. * Define the color of the material as if self lit.
  98926. * This will be mixed in the final result even in the absence of light.
  98927. */
  98928. emissiveColor: Color3;
  98929. /**
  98930. * Defines how sharp are the highlights in the material.
  98931. * The bigger the value the sharper giving a more glossy feeling to the result.
  98932. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  98933. */
  98934. specularPower: number;
  98935. private _useAlphaFromDiffuseTexture;
  98936. /**
  98937. * Does the transparency come from the diffuse texture alpha channel.
  98938. */
  98939. useAlphaFromDiffuseTexture: boolean;
  98940. private _useEmissiveAsIllumination;
  98941. /**
  98942. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  98943. */
  98944. useEmissiveAsIllumination: boolean;
  98945. private _linkEmissiveWithDiffuse;
  98946. /**
  98947. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  98948. * the emissive level when the final color is close to one.
  98949. */
  98950. linkEmissiveWithDiffuse: boolean;
  98951. private _useSpecularOverAlpha;
  98952. /**
  98953. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  98954. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98955. */
  98956. useSpecularOverAlpha: boolean;
  98957. private _useReflectionOverAlpha;
  98958. /**
  98959. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98960. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98961. */
  98962. useReflectionOverAlpha: boolean;
  98963. private _disableLighting;
  98964. /**
  98965. * Does lights from the scene impacts this material.
  98966. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  98967. */
  98968. disableLighting: boolean;
  98969. private _useObjectSpaceNormalMap;
  98970. /**
  98971. * Allows using an object space normal map (instead of tangent space).
  98972. */
  98973. useObjectSpaceNormalMap: boolean;
  98974. private _useParallax;
  98975. /**
  98976. * Is parallax enabled or not.
  98977. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98978. */
  98979. useParallax: boolean;
  98980. private _useParallaxOcclusion;
  98981. /**
  98982. * Is parallax occlusion enabled or not.
  98983. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  98984. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98985. */
  98986. useParallaxOcclusion: boolean;
  98987. /**
  98988. * 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.
  98989. */
  98990. parallaxScaleBias: number;
  98991. private _roughness;
  98992. /**
  98993. * Helps to define how blurry the reflections should appears in the material.
  98994. */
  98995. roughness: number;
  98996. /**
  98997. * In case of refraction, define the value of the indice of refraction.
  98998. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98999. */
  99000. indexOfRefraction: number;
  99001. /**
  99002. * Invert the refraction texture alongside the y axis.
  99003. * It can be useful with procedural textures or probe for instance.
  99004. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99005. */
  99006. invertRefractionY: boolean;
  99007. /**
  99008. * Defines the alpha limits in alpha test mode.
  99009. */
  99010. alphaCutOff: number;
  99011. private _useLightmapAsShadowmap;
  99012. /**
  99013. * In case of light mapping, define whether the map contains light or shadow informations.
  99014. */
  99015. useLightmapAsShadowmap: boolean;
  99016. private _diffuseFresnelParameters;
  99017. /**
  99018. * Define the diffuse fresnel parameters of the material.
  99019. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99020. */
  99021. diffuseFresnelParameters: FresnelParameters;
  99022. private _opacityFresnelParameters;
  99023. /**
  99024. * Define the opacity fresnel parameters of the material.
  99025. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99026. */
  99027. opacityFresnelParameters: FresnelParameters;
  99028. private _reflectionFresnelParameters;
  99029. /**
  99030. * Define the reflection fresnel parameters of the material.
  99031. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99032. */
  99033. reflectionFresnelParameters: FresnelParameters;
  99034. private _refractionFresnelParameters;
  99035. /**
  99036. * Define the refraction fresnel parameters of the material.
  99037. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99038. */
  99039. refractionFresnelParameters: FresnelParameters;
  99040. private _emissiveFresnelParameters;
  99041. /**
  99042. * Define the emissive fresnel parameters of the material.
  99043. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99044. */
  99045. emissiveFresnelParameters: FresnelParameters;
  99046. private _useReflectionFresnelFromSpecular;
  99047. /**
  99048. * If true automatically deducts the fresnels values from the material specularity.
  99049. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99050. */
  99051. useReflectionFresnelFromSpecular: boolean;
  99052. private _useGlossinessFromSpecularMapAlpha;
  99053. /**
  99054. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  99055. */
  99056. useGlossinessFromSpecularMapAlpha: boolean;
  99057. private _maxSimultaneousLights;
  99058. /**
  99059. * Defines the maximum number of lights that can be used in the material
  99060. */
  99061. maxSimultaneousLights: number;
  99062. private _invertNormalMapX;
  99063. /**
  99064. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99065. */
  99066. invertNormalMapX: boolean;
  99067. private _invertNormalMapY;
  99068. /**
  99069. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99070. */
  99071. invertNormalMapY: boolean;
  99072. private _twoSidedLighting;
  99073. /**
  99074. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99075. */
  99076. twoSidedLighting: boolean;
  99077. /**
  99078. * Default configuration related to image processing available in the standard Material.
  99079. */
  99080. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99081. /**
  99082. * Gets the image processing configuration used either in this material.
  99083. */
  99084. /**
  99085. * Sets the Default image processing configuration used either in the this material.
  99086. *
  99087. * If sets to null, the scene one is in use.
  99088. */
  99089. imageProcessingConfiguration: ImageProcessingConfiguration;
  99090. /**
  99091. * Keep track of the image processing observer to allow dispose and replace.
  99092. */
  99093. private _imageProcessingObserver;
  99094. /**
  99095. * Attaches a new image processing configuration to the Standard Material.
  99096. * @param configuration
  99097. */
  99098. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99099. /**
  99100. * Gets wether the color curves effect is enabled.
  99101. */
  99102. /**
  99103. * Sets wether the color curves effect is enabled.
  99104. */
  99105. cameraColorCurvesEnabled: boolean;
  99106. /**
  99107. * Gets wether the color grading effect is enabled.
  99108. */
  99109. /**
  99110. * Gets wether the color grading effect is enabled.
  99111. */
  99112. cameraColorGradingEnabled: boolean;
  99113. /**
  99114. * Gets wether tonemapping is enabled or not.
  99115. */
  99116. /**
  99117. * Sets wether tonemapping is enabled or not
  99118. */
  99119. cameraToneMappingEnabled: boolean;
  99120. /**
  99121. * The camera exposure used on this material.
  99122. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99123. * This corresponds to a photographic exposure.
  99124. */
  99125. /**
  99126. * The camera exposure used on this material.
  99127. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99128. * This corresponds to a photographic exposure.
  99129. */
  99130. cameraExposure: number;
  99131. /**
  99132. * Gets The camera contrast used on this material.
  99133. */
  99134. /**
  99135. * Sets The camera contrast used on this material.
  99136. */
  99137. cameraContrast: number;
  99138. /**
  99139. * Gets the Color Grading 2D Lookup Texture.
  99140. */
  99141. /**
  99142. * Sets the Color Grading 2D Lookup Texture.
  99143. */
  99144. cameraColorGradingTexture: Nullable<BaseTexture>;
  99145. /**
  99146. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99147. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99148. * 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;
  99149. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99150. */
  99151. /**
  99152. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99153. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99154. * 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;
  99155. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99156. */
  99157. cameraColorCurves: Nullable<ColorCurves>;
  99158. /**
  99159. * Custom callback helping to override the default shader used in the material.
  99160. */
  99161. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  99162. protected _renderTargets: SmartArray<RenderTargetTexture>;
  99163. protected _worldViewProjectionMatrix: Matrix;
  99164. protected _globalAmbientColor: Color3;
  99165. protected _useLogarithmicDepth: boolean;
  99166. /**
  99167. * Instantiates a new standard material.
  99168. * This is the default material used in Babylon. It is the best trade off between quality
  99169. * and performances.
  99170. * @see http://doc.babylonjs.com/babylon101/materials
  99171. * @param name Define the name of the material in the scene
  99172. * @param scene Define the scene the material belong to
  99173. */
  99174. constructor(name: string, scene: Scene);
  99175. /**
  99176. * Gets a boolean indicating that current material needs to register RTT
  99177. */
  99178. readonly hasRenderTargetTextures: boolean;
  99179. /**
  99180. * Gets the current class name of the material e.g. "StandardMaterial"
  99181. * Mainly use in serialization.
  99182. * @returns the class name
  99183. */
  99184. getClassName(): string;
  99185. /**
  99186. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  99187. * You can try switching to logarithmic depth.
  99188. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  99189. */
  99190. useLogarithmicDepth: boolean;
  99191. /**
  99192. * Specifies if the material will require alpha blending
  99193. * @returns a boolean specifying if alpha blending is needed
  99194. */
  99195. needAlphaBlending(): boolean;
  99196. /**
  99197. * Specifies if this material should be rendered in alpha test mode
  99198. * @returns a boolean specifying if an alpha test is needed.
  99199. */
  99200. needAlphaTesting(): boolean;
  99201. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  99202. /**
  99203. * Get the texture used for alpha test purpose.
  99204. * @returns the diffuse texture in case of the standard material.
  99205. */
  99206. getAlphaTestTexture(): Nullable<BaseTexture>;
  99207. /**
  99208. * Get if the submesh is ready to be used and all its information available.
  99209. * Child classes can use it to update shaders
  99210. * @param mesh defines the mesh to check
  99211. * @param subMesh defines which submesh to check
  99212. * @param useInstances specifies that instances should be used
  99213. * @returns a boolean indicating that the submesh is ready or not
  99214. */
  99215. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99216. /**
  99217. * Builds the material UBO layouts.
  99218. * Used internally during the effect preparation.
  99219. */
  99220. buildUniformLayout(): void;
  99221. /**
  99222. * Unbinds the material from the mesh
  99223. */
  99224. unbind(): void;
  99225. /**
  99226. * Binds the submesh to this material by preparing the effect and shader to draw
  99227. * @param world defines the world transformation matrix
  99228. * @param mesh defines the mesh containing the submesh
  99229. * @param subMesh defines the submesh to bind the material to
  99230. */
  99231. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99232. /**
  99233. * Get the list of animatables in the material.
  99234. * @returns the list of animatables object used in the material
  99235. */
  99236. getAnimatables(): IAnimatable[];
  99237. /**
  99238. * Gets the active textures from the material
  99239. * @returns an array of textures
  99240. */
  99241. getActiveTextures(): BaseTexture[];
  99242. /**
  99243. * Specifies if the material uses a texture
  99244. * @param texture defines the texture to check against the material
  99245. * @returns a boolean specifying if the material uses the texture
  99246. */
  99247. hasTexture(texture: BaseTexture): boolean;
  99248. /**
  99249. * Disposes the material
  99250. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99251. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99252. */
  99253. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99254. /**
  99255. * Makes a duplicate of the material, and gives it a new name
  99256. * @param name defines the new name for the duplicated material
  99257. * @returns the cloned material
  99258. */
  99259. clone(name: string): StandardMaterial;
  99260. /**
  99261. * Serializes this material in a JSON representation
  99262. * @returns the serialized material object
  99263. */
  99264. serialize(): any;
  99265. /**
  99266. * Creates a standard material from parsed material data
  99267. * @param source defines the JSON representation of the material
  99268. * @param scene defines the hosting scene
  99269. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99270. * @returns a new standard material
  99271. */
  99272. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  99273. /**
  99274. * Are diffuse textures enabled in the application.
  99275. */
  99276. static DiffuseTextureEnabled: boolean;
  99277. /**
  99278. * Are ambient textures enabled in the application.
  99279. */
  99280. static AmbientTextureEnabled: boolean;
  99281. /**
  99282. * Are opacity textures enabled in the application.
  99283. */
  99284. static OpacityTextureEnabled: boolean;
  99285. /**
  99286. * Are reflection textures enabled in the application.
  99287. */
  99288. static ReflectionTextureEnabled: boolean;
  99289. /**
  99290. * Are emissive textures enabled in the application.
  99291. */
  99292. static EmissiveTextureEnabled: boolean;
  99293. /**
  99294. * Are specular textures enabled in the application.
  99295. */
  99296. static SpecularTextureEnabled: boolean;
  99297. /**
  99298. * Are bump textures enabled in the application.
  99299. */
  99300. static BumpTextureEnabled: boolean;
  99301. /**
  99302. * Are lightmap textures enabled in the application.
  99303. */
  99304. static LightmapTextureEnabled: boolean;
  99305. /**
  99306. * Are refraction textures enabled in the application.
  99307. */
  99308. static RefractionTextureEnabled: boolean;
  99309. /**
  99310. * Are color grading textures enabled in the application.
  99311. */
  99312. static ColorGradingTextureEnabled: boolean;
  99313. /**
  99314. * Are fresnels enabled in the application.
  99315. */
  99316. static FresnelEnabled: boolean;
  99317. }
  99318. }
  99319. declare module BABYLON {
  99320. /**
  99321. * A class extending Texture allowing drawing on a texture
  99322. * @see http://doc.babylonjs.com/how_to/dynamictexture
  99323. */
  99324. export class DynamicTexture extends Texture {
  99325. private _generateMipMaps;
  99326. private _canvas;
  99327. private _context;
  99328. private _engine;
  99329. /**
  99330. * Creates a DynamicTexture
  99331. * @param name defines the name of the texture
  99332. * @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
  99333. * @param scene defines the scene where you want the texture
  99334. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  99335. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  99336. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  99337. */
  99338. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  99339. /**
  99340. * Get the current class name of the texture useful for serialization or dynamic coding.
  99341. * @returns "DynamicTexture"
  99342. */
  99343. getClassName(): string;
  99344. /**
  99345. * Gets the current state of canRescale
  99346. */
  99347. readonly canRescale: boolean;
  99348. private _recreate;
  99349. /**
  99350. * Scales the texture
  99351. * @param ratio the scale factor to apply to both width and height
  99352. */
  99353. scale(ratio: number): void;
  99354. /**
  99355. * Resizes the texture
  99356. * @param width the new width
  99357. * @param height the new height
  99358. */
  99359. scaleTo(width: number, height: number): void;
  99360. /**
  99361. * Gets the context of the canvas used by the texture
  99362. * @returns the canvas context of the dynamic texture
  99363. */
  99364. getContext(): CanvasRenderingContext2D;
  99365. /**
  99366. * Clears the texture
  99367. */
  99368. clear(): void;
  99369. /**
  99370. * Updates the texture
  99371. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99372. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  99373. */
  99374. update(invertY?: boolean, premulAlpha?: boolean): void;
  99375. /**
  99376. * Draws text onto the texture
  99377. * @param text defines the text to be drawn
  99378. * @param x defines the placement of the text from the left
  99379. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  99380. * @param font defines the font to be used with font-style, font-size, font-name
  99381. * @param color defines the color used for the text
  99382. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  99383. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99384. * @param update defines whether texture is immediately update (default is true)
  99385. */
  99386. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  99387. /**
  99388. * Clones the texture
  99389. * @returns the clone of the texture.
  99390. */
  99391. clone(): DynamicTexture;
  99392. /**
  99393. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  99394. * @returns a serialized dynamic texture object
  99395. */
  99396. serialize(): any;
  99397. /** @hidden */
  99398. _rebuild(): void;
  99399. }
  99400. }
  99401. declare module BABYLON {
  99402. /** @hidden */
  99403. export var imageProcessingPixelShader: {
  99404. name: string;
  99405. shader: string;
  99406. };
  99407. }
  99408. declare module BABYLON {
  99409. /**
  99410. * ImageProcessingPostProcess
  99411. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  99412. */
  99413. export class ImageProcessingPostProcess extends PostProcess {
  99414. /**
  99415. * Default configuration related to image processing available in the PBR Material.
  99416. */
  99417. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99418. /**
  99419. * Gets the image processing configuration used either in this material.
  99420. */
  99421. /**
  99422. * Sets the Default image processing configuration used either in the this material.
  99423. *
  99424. * If sets to null, the scene one is in use.
  99425. */
  99426. imageProcessingConfiguration: ImageProcessingConfiguration;
  99427. /**
  99428. * Keep track of the image processing observer to allow dispose and replace.
  99429. */
  99430. private _imageProcessingObserver;
  99431. /**
  99432. * Attaches a new image processing configuration to the PBR Material.
  99433. * @param configuration
  99434. */
  99435. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  99436. /**
  99437. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99438. */
  99439. /**
  99440. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99441. */
  99442. colorCurves: Nullable<ColorCurves>;
  99443. /**
  99444. * Gets wether the color curves effect is enabled.
  99445. */
  99446. /**
  99447. * Sets wether the color curves effect is enabled.
  99448. */
  99449. colorCurvesEnabled: boolean;
  99450. /**
  99451. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99452. */
  99453. /**
  99454. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99455. */
  99456. colorGradingTexture: Nullable<BaseTexture>;
  99457. /**
  99458. * Gets wether the color grading effect is enabled.
  99459. */
  99460. /**
  99461. * Gets wether the color grading effect is enabled.
  99462. */
  99463. colorGradingEnabled: boolean;
  99464. /**
  99465. * Gets exposure used in the effect.
  99466. */
  99467. /**
  99468. * Sets exposure used in the effect.
  99469. */
  99470. exposure: number;
  99471. /**
  99472. * Gets wether tonemapping is enabled or not.
  99473. */
  99474. /**
  99475. * Sets wether tonemapping is enabled or not
  99476. */
  99477. toneMappingEnabled: boolean;
  99478. /**
  99479. * Gets the type of tone mapping effect.
  99480. */
  99481. /**
  99482. * Sets the type of tone mapping effect.
  99483. */
  99484. toneMappingType: number;
  99485. /**
  99486. * Gets contrast used in the effect.
  99487. */
  99488. /**
  99489. * Sets contrast used in the effect.
  99490. */
  99491. contrast: number;
  99492. /**
  99493. * Gets Vignette stretch size.
  99494. */
  99495. /**
  99496. * Sets Vignette stretch size.
  99497. */
  99498. vignetteStretch: number;
  99499. /**
  99500. * Gets Vignette centre X Offset.
  99501. */
  99502. /**
  99503. * Sets Vignette centre X Offset.
  99504. */
  99505. vignetteCentreX: number;
  99506. /**
  99507. * Gets Vignette centre Y Offset.
  99508. */
  99509. /**
  99510. * Sets Vignette centre Y Offset.
  99511. */
  99512. vignetteCentreY: number;
  99513. /**
  99514. * Gets Vignette weight or intensity of the vignette effect.
  99515. */
  99516. /**
  99517. * Sets Vignette weight or intensity of the vignette effect.
  99518. */
  99519. vignetteWeight: number;
  99520. /**
  99521. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99522. * if vignetteEnabled is set to true.
  99523. */
  99524. /**
  99525. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99526. * if vignetteEnabled is set to true.
  99527. */
  99528. vignetteColor: Color4;
  99529. /**
  99530. * Gets Camera field of view used by the Vignette effect.
  99531. */
  99532. /**
  99533. * Sets Camera field of view used by the Vignette effect.
  99534. */
  99535. vignetteCameraFov: number;
  99536. /**
  99537. * Gets the vignette blend mode allowing different kind of effect.
  99538. */
  99539. /**
  99540. * Sets the vignette blend mode allowing different kind of effect.
  99541. */
  99542. vignetteBlendMode: number;
  99543. /**
  99544. * Gets wether the vignette effect is enabled.
  99545. */
  99546. /**
  99547. * Sets wether the vignette effect is enabled.
  99548. */
  99549. vignetteEnabled: boolean;
  99550. private _fromLinearSpace;
  99551. /**
  99552. * Gets wether the input of the processing is in Gamma or Linear Space.
  99553. */
  99554. /**
  99555. * Sets wether the input of the processing is in Gamma or Linear Space.
  99556. */
  99557. fromLinearSpace: boolean;
  99558. /**
  99559. * Defines cache preventing GC.
  99560. */
  99561. private _defines;
  99562. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  99563. /**
  99564. * "ImageProcessingPostProcess"
  99565. * @returns "ImageProcessingPostProcess"
  99566. */
  99567. getClassName(): string;
  99568. protected _updateParameters(): void;
  99569. dispose(camera?: Camera): void;
  99570. }
  99571. }
  99572. declare module BABYLON {
  99573. /**
  99574. * Class containing static functions to help procedurally build meshes
  99575. */
  99576. export class GroundBuilder {
  99577. /**
  99578. * Creates a ground mesh
  99579. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  99580. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  99581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99582. * @param name defines the name of the mesh
  99583. * @param options defines the options used to create the mesh
  99584. * @param scene defines the hosting scene
  99585. * @returns the ground mesh
  99586. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  99587. */
  99588. static CreateGround(name: string, options: {
  99589. width?: number;
  99590. height?: number;
  99591. subdivisions?: number;
  99592. subdivisionsX?: number;
  99593. subdivisionsY?: number;
  99594. updatable?: boolean;
  99595. }, scene: any): Mesh;
  99596. /**
  99597. * Creates a tiled ground mesh
  99598. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  99599. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  99600. * * 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
  99601. * * 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
  99602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99603. * @param name defines the name of the mesh
  99604. * @param options defines the options used to create the mesh
  99605. * @param scene defines the hosting scene
  99606. * @returns the tiled ground mesh
  99607. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  99608. */
  99609. static CreateTiledGround(name: string, options: {
  99610. xmin: number;
  99611. zmin: number;
  99612. xmax: number;
  99613. zmax: number;
  99614. subdivisions?: {
  99615. w: number;
  99616. h: number;
  99617. };
  99618. precision?: {
  99619. w: number;
  99620. h: number;
  99621. };
  99622. updatable?: boolean;
  99623. }, scene?: Nullable<Scene>): Mesh;
  99624. /**
  99625. * Creates a ground mesh from a height map
  99626. * * The parameter `url` sets the URL of the height map image resource.
  99627. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  99628. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  99629. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  99630. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  99631. * * 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.
  99632. * * 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).
  99633. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99635. * @param name defines the name of the mesh
  99636. * @param url defines the url to the height map
  99637. * @param options defines the options used to create the mesh
  99638. * @param scene defines the hosting scene
  99639. * @returns the ground mesh
  99640. * @see https://doc.babylonjs.com/babylon101/height_map
  99641. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  99642. */
  99643. static CreateGroundFromHeightMap(name: string, url: string, options: {
  99644. width?: number;
  99645. height?: number;
  99646. subdivisions?: number;
  99647. minHeight?: number;
  99648. maxHeight?: number;
  99649. colorFilter?: Color3;
  99650. alphaFilter?: number;
  99651. updatable?: boolean;
  99652. onReady?: (mesh: GroundMesh) => void;
  99653. }, scene?: Nullable<Scene>): GroundMesh;
  99654. }
  99655. }
  99656. declare module BABYLON {
  99657. /**
  99658. * Class containing static functions to help procedurally build meshes
  99659. */
  99660. export class TorusBuilder {
  99661. /**
  99662. * Creates a torus mesh
  99663. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  99664. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  99665. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  99666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99667. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99669. * @param name defines the name of the mesh
  99670. * @param options defines the options used to create the mesh
  99671. * @param scene defines the hosting scene
  99672. * @returns the torus mesh
  99673. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  99674. */
  99675. static CreateTorus(name: string, options: {
  99676. diameter?: number;
  99677. thickness?: number;
  99678. tessellation?: number;
  99679. updatable?: boolean;
  99680. sideOrientation?: number;
  99681. frontUVs?: Vector4;
  99682. backUVs?: Vector4;
  99683. }, scene: any): Mesh;
  99684. }
  99685. }
  99686. declare module BABYLON {
  99687. /**
  99688. * Class containing static functions to help procedurally build meshes
  99689. */
  99690. export class CylinderBuilder {
  99691. /**
  99692. * Creates a cylinder or a cone mesh
  99693. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  99694. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  99695. * * 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.
  99696. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  99697. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  99698. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  99699. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  99700. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  99701. * * 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).
  99702. * * 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
  99703. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  99704. * * 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
  99705. * * 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.
  99706. * * If `enclose` is false, a ring surface is one element.
  99707. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  99708. * * 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
  99709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99710. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99712. * @param name defines the name of the mesh
  99713. * @param options defines the options used to create the mesh
  99714. * @param scene defines the hosting scene
  99715. * @returns the cylinder mesh
  99716. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  99717. */
  99718. static CreateCylinder(name: string, options: {
  99719. height?: number;
  99720. diameterTop?: number;
  99721. diameterBottom?: number;
  99722. diameter?: number;
  99723. tessellation?: number;
  99724. subdivisions?: number;
  99725. arc?: number;
  99726. faceColors?: Color4[];
  99727. faceUV?: Vector4[];
  99728. updatable?: boolean;
  99729. hasRings?: boolean;
  99730. enclose?: boolean;
  99731. sideOrientation?: number;
  99732. frontUVs?: Vector4;
  99733. backUVs?: Vector4;
  99734. }, scene: any): Mesh;
  99735. }
  99736. }
  99737. declare module BABYLON {
  99738. /**
  99739. * Options to modify the vr teleportation behavior.
  99740. */
  99741. export interface VRTeleportationOptions {
  99742. /**
  99743. * The name of the mesh which should be used as the teleportation floor. (default: null)
  99744. */
  99745. floorMeshName?: string;
  99746. /**
  99747. * A list of meshes to be used as the teleportation floor. (default: empty)
  99748. */
  99749. floorMeshes?: Mesh[];
  99750. }
  99751. /**
  99752. * Options to modify the vr experience helper's behavior.
  99753. */
  99754. export interface VRExperienceHelperOptions extends WebVROptions {
  99755. /**
  99756. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  99757. */
  99758. createDeviceOrientationCamera?: boolean;
  99759. /**
  99760. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  99761. */
  99762. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  99763. /**
  99764. * Uses the main button on the controller to toggle the laser casted. (default: true)
  99765. */
  99766. laserToggle?: boolean;
  99767. /**
  99768. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  99769. */
  99770. floorMeshes?: Mesh[];
  99771. /**
  99772. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  99773. */
  99774. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  99775. }
  99776. /**
  99777. * Event containing information after VR has been entered
  99778. */
  99779. export class OnAfterEnteringVRObservableEvent {
  99780. /**
  99781. * If entering vr was successful
  99782. */
  99783. success: boolean;
  99784. }
  99785. /**
  99786. * Helps to quickly add VR support to an existing scene.
  99787. * See http://doc.babylonjs.com/how_to/webvr_helper
  99788. */
  99789. export class VRExperienceHelper {
  99790. /** Options to modify the vr experience helper's behavior. */
  99791. webVROptions: VRExperienceHelperOptions;
  99792. private _scene;
  99793. private _position;
  99794. private _btnVR;
  99795. private _btnVRDisplayed;
  99796. private _webVRsupported;
  99797. private _webVRready;
  99798. private _webVRrequesting;
  99799. private _webVRpresenting;
  99800. private _hasEnteredVR;
  99801. private _fullscreenVRpresenting;
  99802. private _canvas;
  99803. private _webVRCamera;
  99804. private _vrDeviceOrientationCamera;
  99805. private _deviceOrientationCamera;
  99806. private _existingCamera;
  99807. private _onKeyDown;
  99808. private _onVrDisplayPresentChange;
  99809. private _onVRDisplayChanged;
  99810. private _onVRRequestPresentStart;
  99811. private _onVRRequestPresentComplete;
  99812. /**
  99813. * Observable raised right before entering VR.
  99814. */
  99815. onEnteringVRObservable: Observable<VRExperienceHelper>;
  99816. /**
  99817. * Observable raised when entering VR has completed.
  99818. */
  99819. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  99820. /**
  99821. * Observable raised when exiting VR.
  99822. */
  99823. onExitingVRObservable: Observable<VRExperienceHelper>;
  99824. /**
  99825. * Observable raised when controller mesh is loaded.
  99826. */
  99827. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99828. /** Return this.onEnteringVRObservable
  99829. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  99830. */
  99831. readonly onEnteringVR: Observable<VRExperienceHelper>;
  99832. /** Return this.onExitingVRObservable
  99833. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  99834. */
  99835. readonly onExitingVR: Observable<VRExperienceHelper>;
  99836. /** Return this.onControllerMeshLoadedObservable
  99837. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  99838. */
  99839. readonly onControllerMeshLoaded: Observable<WebVRController>;
  99840. private _rayLength;
  99841. private _useCustomVRButton;
  99842. private _teleportationRequested;
  99843. private _teleportActive;
  99844. private _floorMeshName;
  99845. private _floorMeshesCollection;
  99846. private _rotationAllowed;
  99847. private _teleportBackwardsVector;
  99848. private _teleportationTarget;
  99849. private _isDefaultTeleportationTarget;
  99850. private _postProcessMove;
  99851. private _teleportationFillColor;
  99852. private _teleportationBorderColor;
  99853. private _rotationAngle;
  99854. private _haloCenter;
  99855. private _cameraGazer;
  99856. private _padSensibilityUp;
  99857. private _padSensibilityDown;
  99858. private _leftController;
  99859. private _rightController;
  99860. /**
  99861. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  99862. */
  99863. onNewMeshSelected: Observable<AbstractMesh>;
  99864. /**
  99865. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  99866. */
  99867. onNewMeshPicked: Observable<PickingInfo>;
  99868. private _circleEase;
  99869. /**
  99870. * Observable raised before camera teleportation
  99871. */
  99872. onBeforeCameraTeleport: Observable<Vector3>;
  99873. /**
  99874. * Observable raised after camera teleportation
  99875. */
  99876. onAfterCameraTeleport: Observable<Vector3>;
  99877. /**
  99878. * Observable raised when current selected mesh gets unselected
  99879. */
  99880. onSelectedMeshUnselected: Observable<AbstractMesh>;
  99881. private _raySelectionPredicate;
  99882. /**
  99883. * To be optionaly changed by user to define custom ray selection
  99884. */
  99885. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  99886. /**
  99887. * To be optionaly changed by user to define custom selection logic (after ray selection)
  99888. */
  99889. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  99890. /**
  99891. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  99892. */
  99893. teleportationEnabled: boolean;
  99894. private _defaultHeight;
  99895. private _teleportationInitialized;
  99896. private _interactionsEnabled;
  99897. private _interactionsRequested;
  99898. private _displayGaze;
  99899. private _displayLaserPointer;
  99900. /**
  99901. * The mesh used to display where the user is going to teleport.
  99902. */
  99903. /**
  99904. * Sets the mesh to be used to display where the user is going to teleport.
  99905. */
  99906. teleportationTarget: Mesh;
  99907. /**
  99908. * 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
  99909. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  99910. * See http://doc.babylonjs.com/resources/baking_transformations
  99911. */
  99912. gazeTrackerMesh: Mesh;
  99913. /**
  99914. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  99915. */
  99916. updateGazeTrackerScale: boolean;
  99917. /**
  99918. * If the gaze trackers color should be updated when selecting meshes
  99919. */
  99920. updateGazeTrackerColor: boolean;
  99921. /**
  99922. * The gaze tracking mesh corresponding to the left controller
  99923. */
  99924. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  99925. /**
  99926. * The gaze tracking mesh corresponding to the right controller
  99927. */
  99928. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  99929. /**
  99930. * If the ray of the gaze should be displayed.
  99931. */
  99932. /**
  99933. * Sets if the ray of the gaze should be displayed.
  99934. */
  99935. displayGaze: boolean;
  99936. /**
  99937. * If the ray of the LaserPointer should be displayed.
  99938. */
  99939. /**
  99940. * Sets if the ray of the LaserPointer should be displayed.
  99941. */
  99942. displayLaserPointer: boolean;
  99943. /**
  99944. * The deviceOrientationCamera used as the camera when not in VR.
  99945. */
  99946. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  99947. /**
  99948. * Based on the current WebVR support, returns the current VR camera used.
  99949. */
  99950. readonly currentVRCamera: Nullable<Camera>;
  99951. /**
  99952. * The webVRCamera which is used when in VR.
  99953. */
  99954. readonly webVRCamera: WebVRFreeCamera;
  99955. /**
  99956. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  99957. */
  99958. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  99959. private readonly _teleportationRequestInitiated;
  99960. /**
  99961. * Defines wether or not Pointer lock should be requested when switching to
  99962. * full screen.
  99963. */
  99964. requestPointerLockOnFullScreen: boolean;
  99965. /**
  99966. * Instantiates a VRExperienceHelper.
  99967. * Helps to quickly add VR support to an existing scene.
  99968. * @param scene The scene the VRExperienceHelper belongs to.
  99969. * @param webVROptions Options to modify the vr experience helper's behavior.
  99970. */
  99971. constructor(scene: Scene,
  99972. /** Options to modify the vr experience helper's behavior. */
  99973. webVROptions?: VRExperienceHelperOptions);
  99974. private _onDefaultMeshLoaded;
  99975. private _onResize;
  99976. private _onFullscreenChange;
  99977. /**
  99978. * Gets a value indicating if we are currently in VR mode.
  99979. */
  99980. readonly isInVRMode: boolean;
  99981. private onVrDisplayPresentChange;
  99982. private onVRDisplayChanged;
  99983. private moveButtonToBottomRight;
  99984. private displayVRButton;
  99985. private updateButtonVisibility;
  99986. private _cachedAngularSensibility;
  99987. /**
  99988. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99989. * Otherwise, will use the fullscreen API.
  99990. */
  99991. enterVR(): void;
  99992. /**
  99993. * Attempt to exit VR, or fullscreen.
  99994. */
  99995. exitVR(): void;
  99996. /**
  99997. * The position of the vr experience helper.
  99998. */
  99999. /**
  100000. * Sets the position of the vr experience helper.
  100001. */
  100002. position: Vector3;
  100003. /**
  100004. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  100005. */
  100006. enableInteractions(): void;
  100007. private readonly _noControllerIsActive;
  100008. private beforeRender;
  100009. private _isTeleportationFloor;
  100010. /**
  100011. * Adds a floor mesh to be used for teleportation.
  100012. * @param floorMesh the mesh to be used for teleportation.
  100013. */
  100014. addFloorMesh(floorMesh: Mesh): void;
  100015. /**
  100016. * Removes a floor mesh from being used for teleportation.
  100017. * @param floorMesh the mesh to be removed.
  100018. */
  100019. removeFloorMesh(floorMesh: Mesh): void;
  100020. /**
  100021. * Enables interactions and teleportation using the VR controllers and gaze.
  100022. * @param vrTeleportationOptions options to modify teleportation behavior.
  100023. */
  100024. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  100025. private _onNewGamepadConnected;
  100026. private _tryEnableInteractionOnController;
  100027. private _onNewGamepadDisconnected;
  100028. private _enableInteractionOnController;
  100029. private _checkTeleportWithRay;
  100030. private _checkRotate;
  100031. private _checkTeleportBackwards;
  100032. private _enableTeleportationOnController;
  100033. private _createTeleportationCircles;
  100034. private _displayTeleportationTarget;
  100035. private _hideTeleportationTarget;
  100036. private _rotateCamera;
  100037. private _moveTeleportationSelectorTo;
  100038. private _workingVector;
  100039. private _workingQuaternion;
  100040. private _workingMatrix;
  100041. /**
  100042. * Teleports the users feet to the desired location
  100043. * @param location The location where the user's feet should be placed
  100044. */
  100045. teleportCamera(location: Vector3): void;
  100046. private _convertNormalToDirectionOfRay;
  100047. private _castRayAndSelectObject;
  100048. private _notifySelectedMeshUnselected;
  100049. /**
  100050. * Sets the color of the laser ray from the vr controllers.
  100051. * @param color new color for the ray.
  100052. */
  100053. changeLaserColor(color: Color3): void;
  100054. /**
  100055. * Sets the color of the ray from the vr headsets gaze.
  100056. * @param color new color for the ray.
  100057. */
  100058. changeGazeColor(color: Color3): void;
  100059. /**
  100060. * Exits VR and disposes of the vr experience helper
  100061. */
  100062. dispose(): void;
  100063. /**
  100064. * Gets the name of the VRExperienceHelper class
  100065. * @returns "VRExperienceHelper"
  100066. */
  100067. getClassName(): string;
  100068. }
  100069. }
  100070. declare module BABYLON {
  100071. /**
  100072. * Manages an XRSession
  100073. * @see https://doc.babylonjs.com/how_to/webxr
  100074. */
  100075. export class WebXRSessionManager implements IDisposable {
  100076. private scene;
  100077. /**
  100078. * Fires every time a new xrFrame arrives which can be used to update the camera
  100079. */
  100080. onXRFrameObservable: Observable<any>;
  100081. /**
  100082. * Fires when the xr session is ended either by the device or manually done
  100083. */
  100084. onXRSessionEnded: Observable<any>;
  100085. /** @hidden */
  100086. _xrSession: XRSession;
  100087. /** @hidden */
  100088. _frameOfReference: XRFrameOfReference;
  100089. /** @hidden */
  100090. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  100091. /** @hidden */
  100092. _currentXRFrame: Nullable<XRFrame>;
  100093. private _xrNavigator;
  100094. private _xrDevice;
  100095. private _tmpMatrix;
  100096. /**
  100097. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  100098. * @param scene The scene which the session should be created for
  100099. */
  100100. constructor(scene: Scene);
  100101. /**
  100102. * Initializes the manager
  100103. * After initialization enterXR can be called to start an XR session
  100104. * @returns Promise which resolves after it is initialized
  100105. */
  100106. initializeAsync(): Promise<void>;
  100107. /**
  100108. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  100109. * @param sessionCreationOptions xr options to create the session with
  100110. * @param frameOfReferenceType option to configure how the xr pose is expressed
  100111. * @returns Promise which resolves after it enters XR
  100112. */
  100113. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  100114. /**
  100115. * Stops the xrSession and restores the renderloop
  100116. * @returns Promise which resolves after it exits XR
  100117. */
  100118. exitXRAsync(): Promise<void>;
  100119. /**
  100120. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  100121. * @param ray ray to cast into the environment
  100122. * @returns Promise which resolves with a collision point in the environment if it exists
  100123. */
  100124. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  100125. /**
  100126. * Checks if a session would be supported for the creation options specified
  100127. * @param options creation options to check if they are supported
  100128. * @returns true if supported
  100129. */
  100130. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  100131. /**
  100132. * @hidden
  100133. * Converts the render layer of xrSession to a render target
  100134. * @param session session to create render target for
  100135. * @param scene scene the new render target should be created for
  100136. */
  100137. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  100138. /**
  100139. * Disposes of the session manager
  100140. */
  100141. dispose(): void;
  100142. }
  100143. }
  100144. declare module BABYLON {
  100145. /**
  100146. * WebXR Camera which holds the views for the xrSession
  100147. * @see https://doc.babylonjs.com/how_to/webxr
  100148. */
  100149. export class WebXRCamera extends FreeCamera {
  100150. private static _TmpMatrix;
  100151. /**
  100152. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  100153. * @param name the name of the camera
  100154. * @param scene the scene to add the camera to
  100155. */
  100156. constructor(name: string, scene: Scene);
  100157. private _updateNumberOfRigCameras;
  100158. /** @hidden */
  100159. _updateForDualEyeDebugging(pupilDistance?: number): void;
  100160. /**
  100161. * Updates the cameras position from the current pose information of the XR session
  100162. * @param xrSessionManager the session containing pose information
  100163. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  100164. */
  100165. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  100166. }
  100167. }
  100168. declare module BABYLON {
  100169. /**
  100170. * States of the webXR experience
  100171. */
  100172. export enum WebXRState {
  100173. /**
  100174. * Transitioning to being in XR mode
  100175. */
  100176. ENTERING_XR = 0,
  100177. /**
  100178. * Transitioning to non XR mode
  100179. */
  100180. EXITING_XR = 1,
  100181. /**
  100182. * In XR mode and presenting
  100183. */
  100184. IN_XR = 2,
  100185. /**
  100186. * Not entered XR mode
  100187. */
  100188. NOT_IN_XR = 3
  100189. }
  100190. /**
  100191. * Helper class used to enable XR
  100192. * @see https://doc.babylonjs.com/how_to/webxr
  100193. */
  100194. export class WebXRExperienceHelper implements IDisposable {
  100195. private scene;
  100196. /**
  100197. * 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
  100198. */
  100199. container: AbstractMesh;
  100200. /**
  100201. * Camera used to render xr content
  100202. */
  100203. camera: WebXRCamera;
  100204. /**
  100205. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  100206. */
  100207. state: WebXRState;
  100208. private _setState;
  100209. private static _TmpVector;
  100210. /**
  100211. * Fires when the state of the experience helper has changed
  100212. */
  100213. onStateChangedObservable: Observable<WebXRState>;
  100214. /** @hidden */
  100215. _sessionManager: WebXRSessionManager;
  100216. private _nonVRCamera;
  100217. private _originalSceneAutoClear;
  100218. private _supported;
  100219. /**
  100220. * Creates the experience helper
  100221. * @param scene the scene to attach the experience helper to
  100222. * @returns a promise for the experience helper
  100223. */
  100224. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  100225. /**
  100226. * Creates a WebXRExperienceHelper
  100227. * @param scene The scene the helper should be created in
  100228. */
  100229. private constructor();
  100230. /**
  100231. * Exits XR mode and returns the scene to its original state
  100232. * @returns promise that resolves after xr mode has exited
  100233. */
  100234. exitXRAsync(): Promise<void>;
  100235. /**
  100236. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  100237. * @param sessionCreationOptions options for the XR session
  100238. * @param frameOfReference frame of reference of the XR session
  100239. * @returns promise that resolves after xr mode has entered
  100240. */
  100241. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  100242. /**
  100243. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  100244. * @param ray ray to cast into the environment
  100245. * @returns Promise which resolves with a collision point in the environment if it exists
  100246. */
  100247. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  100248. /**
  100249. * Updates the global position of the camera by moving the camera's container
  100250. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  100251. * @param position The desired global position of the camera
  100252. */
  100253. setPositionOfCameraUsingContainer(position: Vector3): void;
  100254. /**
  100255. * Rotates the xr camera by rotating the camera's container around the camera's position
  100256. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  100257. * @param rotation the desired quaternion rotation to apply to the camera
  100258. */
  100259. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  100260. /**
  100261. * Checks if the creation options are supported by the xr session
  100262. * @param options creation options
  100263. * @returns true if supported
  100264. */
  100265. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  100266. /**
  100267. * Disposes of the experience helper
  100268. */
  100269. dispose(): void;
  100270. }
  100271. }
  100272. declare module BABYLON {
  100273. /**
  100274. * Button which can be used to enter a different mode of XR
  100275. */
  100276. export class WebXREnterExitUIButton {
  100277. /** button element */
  100278. element: HTMLElement;
  100279. /** XR initialization options for the button */
  100280. initializationOptions: XRSessionCreationOptions;
  100281. /**
  100282. * Creates a WebXREnterExitUIButton
  100283. * @param element button element
  100284. * @param initializationOptions XR initialization options for the button
  100285. */
  100286. constructor(
  100287. /** button element */
  100288. element: HTMLElement,
  100289. /** XR initialization options for the button */
  100290. initializationOptions: XRSessionCreationOptions);
  100291. /**
  100292. * Overwritable function which can be used to update the button's visuals when the state changes
  100293. * @param activeButton the current active button in the UI
  100294. */
  100295. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  100296. }
  100297. /**
  100298. * Options to create the webXR UI
  100299. */
  100300. export class WebXREnterExitUIOptions {
  100301. /**
  100302. * Context to enter xr with
  100303. */
  100304. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  100305. /**
  100306. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  100307. */
  100308. customButtons?: Array<WebXREnterExitUIButton>;
  100309. }
  100310. /**
  100311. * UI to allow the user to enter/exit XR mode
  100312. */
  100313. export class WebXREnterExitUI implements IDisposable {
  100314. private scene;
  100315. private _overlay;
  100316. private _buttons;
  100317. private _activeButton;
  100318. /**
  100319. * Fired every time the active button is changed.
  100320. *
  100321. * When xr is entered via a button that launches xr that button will be the callback parameter
  100322. *
  100323. * When exiting xr the callback parameter will be null)
  100324. */
  100325. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  100326. /**
  100327. * Creates UI to allow the user to enter/exit XR mode
  100328. * @param scene the scene to add the ui to
  100329. * @param helper the xr experience helper to enter/exit xr with
  100330. * @param options options to configure the UI
  100331. * @returns the created ui
  100332. */
  100333. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  100334. private constructor();
  100335. private _updateButtons;
  100336. /**
  100337. * Disposes of the object
  100338. */
  100339. dispose(): void;
  100340. }
  100341. }
  100342. declare module BABYLON {
  100343. /**
  100344. * Represents an XR input
  100345. */
  100346. export class WebXRController {
  100347. /**
  100348. * 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
  100349. */
  100350. grip?: AbstractMesh;
  100351. /**
  100352. * Pointer which can be used to select objects or attach a visible laser to
  100353. */
  100354. pointer: AbstractMesh;
  100355. /**
  100356. * Creates the controller
  100357. * @see https://doc.babylonjs.com/how_to/webxr
  100358. * @param scene the scene which the controller should be associated to
  100359. */
  100360. constructor(scene: Scene);
  100361. /**
  100362. * Disposes of the object
  100363. */
  100364. dispose(): void;
  100365. }
  100366. /**
  100367. * XR input used to track XR inputs such as controllers/rays
  100368. */
  100369. export class WebXRInput implements IDisposable {
  100370. private helper;
  100371. /**
  100372. * XR controllers being tracked
  100373. */
  100374. controllers: Array<WebXRController>;
  100375. private _tmpMatrix;
  100376. private _frameObserver;
  100377. /**
  100378. * Initializes the WebXRInput
  100379. * @param helper experience helper which the input should be created for
  100380. */
  100381. constructor(helper: WebXRExperienceHelper);
  100382. /**
  100383. * Disposes of the object
  100384. */
  100385. dispose(): void;
  100386. }
  100387. }
  100388. declare module BABYLON {
  100389. /**
  100390. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  100391. */
  100392. export class WebXRManagedOutputCanvas implements IDisposable {
  100393. private _canvas;
  100394. /**
  100395. * xrpresent context of the canvas which can be used to display/mirror xr content
  100396. */
  100397. canvasContext: Nullable<WebGLRenderingContext>;
  100398. /**
  100399. * Initializes the canvas to be added/removed upon entering/exiting xr
  100400. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  100401. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  100402. */
  100403. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  100404. /**
  100405. * Disposes of the object
  100406. */
  100407. dispose(): void;
  100408. private _setManagedOutputCanvas;
  100409. private _addCanvas;
  100410. private _removeCanvas;
  100411. }
  100412. }
  100413. declare module BABYLON {
  100414. /**
  100415. * Contains an array of blocks representing the octree
  100416. */
  100417. export interface IOctreeContainer<T> {
  100418. /**
  100419. * Blocks within the octree
  100420. */
  100421. blocks: Array<OctreeBlock<T>>;
  100422. }
  100423. /**
  100424. * Class used to store a cell in an octree
  100425. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100426. */
  100427. export class OctreeBlock<T> {
  100428. /**
  100429. * Gets the content of the current block
  100430. */
  100431. entries: T[];
  100432. /**
  100433. * Gets the list of block children
  100434. */
  100435. blocks: Array<OctreeBlock<T>>;
  100436. private _depth;
  100437. private _maxDepth;
  100438. private _capacity;
  100439. private _minPoint;
  100440. private _maxPoint;
  100441. private _boundingVectors;
  100442. private _creationFunc;
  100443. /**
  100444. * Creates a new block
  100445. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  100446. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  100447. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100448. * @param depth defines the current depth of this block in the octree
  100449. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  100450. * @param creationFunc defines a callback to call when an element is added to the block
  100451. */
  100452. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  100453. /**
  100454. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100455. */
  100456. readonly capacity: number;
  100457. /**
  100458. * Gets the minimum vector (in world space) of the block's bounding box
  100459. */
  100460. readonly minPoint: Vector3;
  100461. /**
  100462. * Gets the maximum vector (in world space) of the block's bounding box
  100463. */
  100464. readonly maxPoint: Vector3;
  100465. /**
  100466. * Add a new element to this block
  100467. * @param entry defines the element to add
  100468. */
  100469. addEntry(entry: T): void;
  100470. /**
  100471. * Remove an element from this block
  100472. * @param entry defines the element to remove
  100473. */
  100474. removeEntry(entry: T): void;
  100475. /**
  100476. * Add an array of elements to this block
  100477. * @param entries defines the array of elements to add
  100478. */
  100479. addEntries(entries: T[]): void;
  100480. /**
  100481. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  100482. * @param frustumPlanes defines the frustum planes to test
  100483. * @param selection defines the array to store current content if selection is positive
  100484. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100485. */
  100486. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100487. /**
  100488. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  100489. * @param sphereCenter defines the bounding sphere center
  100490. * @param sphereRadius defines the bounding sphere radius
  100491. * @param selection defines the array to store current content if selection is positive
  100492. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100493. */
  100494. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100495. /**
  100496. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  100497. * @param ray defines the ray to test with
  100498. * @param selection defines the array to store current content if selection is positive
  100499. */
  100500. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  100501. /**
  100502. * Subdivide the content into child blocks (this block will then be empty)
  100503. */
  100504. createInnerBlocks(): void;
  100505. /**
  100506. * @hidden
  100507. */
  100508. 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;
  100509. }
  100510. }
  100511. declare module BABYLON {
  100512. /**
  100513. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  100514. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100515. */
  100516. export class Octree<T> {
  100517. /** 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.) */
  100518. maxDepth: number;
  100519. /**
  100520. * Blocks within the octree containing objects
  100521. */
  100522. blocks: Array<OctreeBlock<T>>;
  100523. /**
  100524. * Content stored in the octree
  100525. */
  100526. dynamicContent: T[];
  100527. private _maxBlockCapacity;
  100528. private _selectionContent;
  100529. private _creationFunc;
  100530. /**
  100531. * Creates a octree
  100532. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100533. * @param creationFunc function to be used to instatiate the octree
  100534. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  100535. * @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.)
  100536. */
  100537. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  100538. /** 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.) */
  100539. maxDepth?: number);
  100540. /**
  100541. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  100542. * @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);
  100543. * @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);
  100544. * @param entries meshes to be added to the octree blocks
  100545. */
  100546. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  100547. /**
  100548. * Adds a mesh to the octree
  100549. * @param entry Mesh to add to the octree
  100550. */
  100551. addMesh(entry: T): void;
  100552. /**
  100553. * Remove an element from the octree
  100554. * @param entry defines the element to remove
  100555. */
  100556. removeMesh(entry: T): void;
  100557. /**
  100558. * Selects an array of meshes within the frustum
  100559. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  100560. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  100561. * @returns array of meshes within the frustum
  100562. */
  100563. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  100564. /**
  100565. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  100566. * @param sphereCenter defines the bounding sphere center
  100567. * @param sphereRadius defines the bounding sphere radius
  100568. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100569. * @returns an array of objects that intersect the sphere
  100570. */
  100571. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  100572. /**
  100573. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  100574. * @param ray defines the ray to test with
  100575. * @returns array of intersected objects
  100576. */
  100577. intersectsRay(ray: Ray): SmartArray<T>;
  100578. /**
  100579. * Adds a mesh into the octree block if it intersects the block
  100580. */
  100581. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  100582. /**
  100583. * Adds a submesh into the octree block if it intersects the block
  100584. */
  100585. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  100586. }
  100587. }
  100588. declare module BABYLON {
  100589. interface Scene {
  100590. /**
  100591. * @hidden
  100592. * Backing Filed
  100593. */
  100594. _selectionOctree: Octree<AbstractMesh>;
  100595. /**
  100596. * Gets the octree used to boost mesh selection (picking)
  100597. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100598. */
  100599. selectionOctree: Octree<AbstractMesh>;
  100600. /**
  100601. * Creates or updates the octree used to boost selection (picking)
  100602. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100603. * @param maxCapacity defines the maximum capacity per leaf
  100604. * @param maxDepth defines the maximum depth of the octree
  100605. * @returns an octree of AbstractMesh
  100606. */
  100607. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  100608. }
  100609. interface AbstractMesh {
  100610. /**
  100611. * @hidden
  100612. * Backing Field
  100613. */
  100614. _submeshesOctree: Octree<SubMesh>;
  100615. /**
  100616. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  100617. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  100618. * @param maxCapacity defines the maximum size of each block (64 by default)
  100619. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  100620. * @returns the new octree
  100621. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  100622. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100623. */
  100624. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  100625. }
  100626. /**
  100627. * Defines the octree scene component responsible to manage any octrees
  100628. * in a given scene.
  100629. */
  100630. export class OctreeSceneComponent {
  100631. /**
  100632. * The component name help to identify the component in the list of scene components.
  100633. */
  100634. readonly name: string;
  100635. /**
  100636. * The scene the component belongs to.
  100637. */
  100638. scene: Scene;
  100639. /**
  100640. * Indicates if the meshes have been checked to make sure they are isEnabled()
  100641. */
  100642. readonly checksIsEnabled: boolean;
  100643. /**
  100644. * Creates a new instance of the component for the given scene
  100645. * @param scene Defines the scene to register the component in
  100646. */
  100647. constructor(scene: Scene);
  100648. /**
  100649. * Registers the component in a given scene
  100650. */
  100651. register(): void;
  100652. /**
  100653. * Return the list of active meshes
  100654. * @returns the list of active meshes
  100655. */
  100656. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100657. /**
  100658. * Return the list of active sub meshes
  100659. * @param mesh The mesh to get the candidates sub meshes from
  100660. * @returns the list of active sub meshes
  100661. */
  100662. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100663. private _tempRay;
  100664. /**
  100665. * Return the list of sub meshes intersecting with a given local ray
  100666. * @param mesh defines the mesh to find the submesh for
  100667. * @param localRay defines the ray in local space
  100668. * @returns the list of intersecting sub meshes
  100669. */
  100670. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  100671. /**
  100672. * Return the list of sub meshes colliding with a collider
  100673. * @param mesh defines the mesh to find the submesh for
  100674. * @param collider defines the collider to evaluate the collision against
  100675. * @returns the list of colliding sub meshes
  100676. */
  100677. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  100678. /**
  100679. * Rebuilds the elements related to this component in case of
  100680. * context lost for instance.
  100681. */
  100682. rebuild(): void;
  100683. /**
  100684. * Disposes the component and the associated ressources.
  100685. */
  100686. dispose(): void;
  100687. }
  100688. }
  100689. declare module BABYLON {
  100690. /**
  100691. * Renders a layer on top of an existing scene
  100692. */
  100693. export class UtilityLayerRenderer implements IDisposable {
  100694. /** the original scene that will be rendered on top of */
  100695. originalScene: Scene;
  100696. private _pointerCaptures;
  100697. private _lastPointerEvents;
  100698. private static _DefaultUtilityLayer;
  100699. private static _DefaultKeepDepthUtilityLayer;
  100700. private _sharedGizmoLight;
  100701. /**
  100702. * @hidden
  100703. * Light which used by gizmos to get light shading
  100704. */
  100705. _getSharedGizmoLight(): HemisphericLight;
  100706. /**
  100707. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  100708. */
  100709. pickUtilitySceneFirst: boolean;
  100710. /**
  100711. * 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)
  100712. */
  100713. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  100714. /**
  100715. * 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)
  100716. */
  100717. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  100718. /**
  100719. * The scene that is rendered on top of the original scene
  100720. */
  100721. utilityLayerScene: Scene;
  100722. /**
  100723. * If the utility layer should automatically be rendered on top of existing scene
  100724. */
  100725. shouldRender: boolean;
  100726. /**
  100727. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  100728. */
  100729. onlyCheckPointerDownEvents: boolean;
  100730. /**
  100731. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  100732. */
  100733. processAllEvents: boolean;
  100734. /**
  100735. * Observable raised when the pointer move from the utility layer scene to the main scene
  100736. */
  100737. onPointerOutObservable: Observable<number>;
  100738. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  100739. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  100740. private _afterRenderObserver;
  100741. private _sceneDisposeObserver;
  100742. private _originalPointerObserver;
  100743. /**
  100744. * Instantiates a UtilityLayerRenderer
  100745. * @param originalScene the original scene that will be rendered on top of
  100746. * @param handleEvents boolean indicating if the utility layer should handle events
  100747. */
  100748. constructor(
  100749. /** the original scene that will be rendered on top of */
  100750. originalScene: Scene, handleEvents?: boolean);
  100751. private _notifyObservers;
  100752. /**
  100753. * Renders the utility layers scene on top of the original scene
  100754. */
  100755. render(): void;
  100756. /**
  100757. * Disposes of the renderer
  100758. */
  100759. dispose(): void;
  100760. private _updateCamera;
  100761. }
  100762. }
  100763. declare module BABYLON {
  100764. /**
  100765. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  100766. */
  100767. export class Gizmo implements IDisposable {
  100768. /** The utility layer the gizmo will be added to */
  100769. gizmoLayer: UtilityLayerRenderer;
  100770. /**
  100771. * The root mesh of the gizmo
  100772. */
  100773. _rootMesh: Mesh;
  100774. private _attachedMesh;
  100775. /**
  100776. * Ratio for the scale of the gizmo (Default: 1)
  100777. */
  100778. scaleRatio: number;
  100779. /**
  100780. * If a custom mesh has been set (Default: false)
  100781. */
  100782. protected _customMeshSet: boolean;
  100783. /**
  100784. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  100785. * * When set, interactions will be enabled
  100786. */
  100787. attachedMesh: Nullable<AbstractMesh>;
  100788. /**
  100789. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100790. * @param mesh The mesh to replace the default mesh of the gizmo
  100791. */
  100792. setCustomMesh(mesh: Mesh): void;
  100793. /**
  100794. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  100795. */
  100796. updateGizmoRotationToMatchAttachedMesh: boolean;
  100797. /**
  100798. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  100799. */
  100800. updateGizmoPositionToMatchAttachedMesh: boolean;
  100801. /**
  100802. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  100803. */
  100804. protected _updateScale: boolean;
  100805. protected _interactionsEnabled: boolean;
  100806. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100807. private _beforeRenderObserver;
  100808. private _tempVector;
  100809. /**
  100810. * Creates a gizmo
  100811. * @param gizmoLayer The utility layer the gizmo will be added to
  100812. */
  100813. constructor(
  100814. /** The utility layer the gizmo will be added to */
  100815. gizmoLayer?: UtilityLayerRenderer);
  100816. /**
  100817. * Updates the gizmo to match the attached mesh's position/rotation
  100818. */
  100819. protected _update(): void;
  100820. /**
  100821. * Disposes of the gizmo
  100822. */
  100823. dispose(): void;
  100824. }
  100825. }
  100826. declare module BABYLON {
  100827. /**
  100828. * Single axis drag gizmo
  100829. */
  100830. export class AxisDragGizmo extends Gizmo {
  100831. /**
  100832. * Drag behavior responsible for the gizmos dragging interactions
  100833. */
  100834. dragBehavior: PointerDragBehavior;
  100835. private _pointerObserver;
  100836. /**
  100837. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100838. */
  100839. snapDistance: number;
  100840. /**
  100841. * Event that fires each time the gizmo snaps to a new location.
  100842. * * snapDistance is the the change in distance
  100843. */
  100844. onSnapObservable: Observable<{
  100845. snapDistance: number;
  100846. }>;
  100847. /** @hidden */
  100848. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  100849. /** @hidden */
  100850. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  100851. /**
  100852. * Creates an AxisDragGizmo
  100853. * @param gizmoLayer The utility layer the gizmo will be added to
  100854. * @param dragAxis The axis which the gizmo will be able to drag on
  100855. * @param color The color of the gizmo
  100856. */
  100857. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100858. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100859. /**
  100860. * Disposes of the gizmo
  100861. */
  100862. dispose(): void;
  100863. }
  100864. }
  100865. declare module BABYLON.Debug {
  100866. /**
  100867. * The Axes viewer will show 3 axes in a specific point in space
  100868. */
  100869. export class AxesViewer {
  100870. private _xAxis;
  100871. private _yAxis;
  100872. private _zAxis;
  100873. private _scaleLinesFactor;
  100874. private _instanced;
  100875. /**
  100876. * Gets the hosting scene
  100877. */
  100878. scene: Scene;
  100879. /**
  100880. * Gets or sets a number used to scale line length
  100881. */
  100882. scaleLines: number;
  100883. /** Gets the node hierarchy used to render x-axis */
  100884. readonly xAxis: TransformNode;
  100885. /** Gets the node hierarchy used to render y-axis */
  100886. readonly yAxis: TransformNode;
  100887. /** Gets the node hierarchy used to render z-axis */
  100888. readonly zAxis: TransformNode;
  100889. /**
  100890. * Creates a new AxesViewer
  100891. * @param scene defines the hosting scene
  100892. * @param scaleLines defines a number used to scale line length (1 by default)
  100893. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  100894. * @param xAxis defines the node hierarchy used to render the x-axis
  100895. * @param yAxis defines the node hierarchy used to render the y-axis
  100896. * @param zAxis defines the node hierarchy used to render the z-axis
  100897. */
  100898. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  100899. /**
  100900. * Force the viewer to update
  100901. * @param position defines the position of the viewer
  100902. * @param xaxis defines the x axis of the viewer
  100903. * @param yaxis defines the y axis of the viewer
  100904. * @param zaxis defines the z axis of the viewer
  100905. */
  100906. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  100907. /**
  100908. * Creates an instance of this axes viewer.
  100909. * @returns a new axes viewer with instanced meshes
  100910. */
  100911. createInstance(): AxesViewer;
  100912. /** Releases resources */
  100913. dispose(): void;
  100914. private static _SetRenderingGroupId;
  100915. }
  100916. }
  100917. declare module BABYLON.Debug {
  100918. /**
  100919. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  100920. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  100921. */
  100922. export class BoneAxesViewer extends AxesViewer {
  100923. /**
  100924. * Gets or sets the target mesh where to display the axes viewer
  100925. */
  100926. mesh: Nullable<Mesh>;
  100927. /**
  100928. * Gets or sets the target bone where to display the axes viewer
  100929. */
  100930. bone: Nullable<Bone>;
  100931. /** Gets current position */
  100932. pos: Vector3;
  100933. /** Gets direction of X axis */
  100934. xaxis: Vector3;
  100935. /** Gets direction of Y axis */
  100936. yaxis: Vector3;
  100937. /** Gets direction of Z axis */
  100938. zaxis: Vector3;
  100939. /**
  100940. * Creates a new BoneAxesViewer
  100941. * @param scene defines the hosting scene
  100942. * @param bone defines the target bone
  100943. * @param mesh defines the target mesh
  100944. * @param scaleLines defines a scaling factor for line length (1 by default)
  100945. */
  100946. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  100947. /**
  100948. * Force the viewer to update
  100949. */
  100950. update(): void;
  100951. /** Releases resources */
  100952. dispose(): void;
  100953. }
  100954. }
  100955. declare module BABYLON {
  100956. /**
  100957. * Interface used to define scene explorer extensibility option
  100958. */
  100959. export interface IExplorerExtensibilityOption {
  100960. /**
  100961. * Define the option label
  100962. */
  100963. label: string;
  100964. /**
  100965. * Defines the action to execute on click
  100966. */
  100967. action: (entity: any) => void;
  100968. }
  100969. /**
  100970. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100971. */
  100972. export interface IExplorerExtensibilityGroup {
  100973. /**
  100974. * Defines a predicate to test if a given type mut be extended
  100975. */
  100976. predicate: (entity: any) => boolean;
  100977. /**
  100978. * Gets the list of options added to a type
  100979. */
  100980. entries: IExplorerExtensibilityOption[];
  100981. }
  100982. /**
  100983. * Interface used to define the options to use to create the Inspector
  100984. */
  100985. export interface IInspectorOptions {
  100986. /**
  100987. * Display in overlay mode (default: false)
  100988. */
  100989. overlay?: boolean;
  100990. /**
  100991. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100992. */
  100993. globalRoot?: HTMLElement;
  100994. /**
  100995. * Display the Scene explorer
  100996. */
  100997. showExplorer?: boolean;
  100998. /**
  100999. * Display the property inspector
  101000. */
  101001. showInspector?: boolean;
  101002. /**
  101003. * Display in embed mode (both panes on the right)
  101004. */
  101005. embedMode?: boolean;
  101006. /**
  101007. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  101008. */
  101009. handleResize?: boolean;
  101010. /**
  101011. * Allow the panes to popup (default: true)
  101012. */
  101013. enablePopup?: boolean;
  101014. /**
  101015. * Allow the panes to be closed by users (default: true)
  101016. */
  101017. enableClose?: boolean;
  101018. /**
  101019. * Optional list of extensibility entries
  101020. */
  101021. explorerExtensibility?: IExplorerExtensibilityGroup[];
  101022. /**
  101023. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  101024. */
  101025. inspectorURL?: string;
  101026. }
  101027. interface Scene {
  101028. /**
  101029. * @hidden
  101030. * Backing field
  101031. */
  101032. _debugLayer: DebugLayer;
  101033. /**
  101034. * Gets the debug layer (aka Inspector) associated with the scene
  101035. * @see http://doc.babylonjs.com/features/playground_debuglayer
  101036. */
  101037. debugLayer: DebugLayer;
  101038. }
  101039. /**
  101040. * The debug layer (aka Inspector) is the go to tool in order to better understand
  101041. * what is happening in your scene
  101042. * @see http://doc.babylonjs.com/features/playground_debuglayer
  101043. */
  101044. export class DebugLayer {
  101045. /**
  101046. * Define the url to get the inspector script from.
  101047. * By default it uses the babylonjs CDN.
  101048. * @ignoreNaming
  101049. */
  101050. static InspectorURL: string;
  101051. private _scene;
  101052. private BJSINSPECTOR;
  101053. /**
  101054. * Observable triggered when a property is changed through the inspector.
  101055. */
  101056. onPropertyChangedObservable: Observable<{
  101057. object: any;
  101058. property: string;
  101059. value: any;
  101060. initialValue: any;
  101061. }>;
  101062. /**
  101063. * Instantiates a new debug layer.
  101064. * The debug layer (aka Inspector) is the go to tool in order to better understand
  101065. * what is happening in your scene
  101066. * @see http://doc.babylonjs.com/features/playground_debuglayer
  101067. * @param scene Defines the scene to inspect
  101068. */
  101069. constructor(scene: Scene);
  101070. /** Creates the inspector window. */
  101071. private _createInspector;
  101072. /**
  101073. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  101074. * @param entity defines the entity to select
  101075. * @param lineContainerTitle defines the specific block to highlight
  101076. */
  101077. select(entity: any, lineContainerTitle?: string): void;
  101078. /** Get the inspector from bundle or global */
  101079. private _getGlobalInspector;
  101080. /**
  101081. * Get if the inspector is visible or not.
  101082. * @returns true if visible otherwise, false
  101083. */
  101084. isVisible(): boolean;
  101085. /**
  101086. * Hide the inspector and close its window.
  101087. */
  101088. hide(): void;
  101089. /**
  101090. * Launch the debugLayer.
  101091. * @param config Define the configuration of the inspector
  101092. * @return a promise fulfilled when the debug layer is visible
  101093. */
  101094. show(config?: IInspectorOptions): Promise<DebugLayer>;
  101095. }
  101096. }
  101097. declare module BABYLON {
  101098. /**
  101099. * Class containing static functions to help procedurally build meshes
  101100. */
  101101. export class BoxBuilder {
  101102. /**
  101103. * Creates a box mesh
  101104. * * The parameter `size` sets the size (float) of each box side (default 1)
  101105. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  101106. * * 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)
  101107. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  101108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101111. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  101112. * @param name defines the name of the mesh
  101113. * @param options defines the options used to create the mesh
  101114. * @param scene defines the hosting scene
  101115. * @returns the box mesh
  101116. */
  101117. static CreateBox(name: string, options: {
  101118. size?: number;
  101119. width?: number;
  101120. height?: number;
  101121. depth?: number;
  101122. faceUV?: Vector4[];
  101123. faceColors?: Color4[];
  101124. sideOrientation?: number;
  101125. frontUVs?: Vector4;
  101126. backUVs?: Vector4;
  101127. wrap?: boolean;
  101128. topBaseAt?: number;
  101129. bottomBaseAt?: number;
  101130. updatable?: boolean;
  101131. }, scene?: Nullable<Scene>): Mesh;
  101132. }
  101133. }
  101134. declare module BABYLON {
  101135. /**
  101136. * Class containing static functions to help procedurally build meshes
  101137. */
  101138. export class SphereBuilder {
  101139. /**
  101140. * Creates a sphere mesh
  101141. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  101142. * * 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`)
  101143. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  101144. * * 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
  101145. * * 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)
  101146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101147. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101149. * @param name defines the name of the mesh
  101150. * @param options defines the options used to create the mesh
  101151. * @param scene defines the hosting scene
  101152. * @returns the sphere mesh
  101153. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  101154. */
  101155. static CreateSphere(name: string, options: {
  101156. segments?: number;
  101157. diameter?: number;
  101158. diameterX?: number;
  101159. diameterY?: number;
  101160. diameterZ?: number;
  101161. arc?: number;
  101162. slice?: number;
  101163. sideOrientation?: number;
  101164. frontUVs?: Vector4;
  101165. backUVs?: Vector4;
  101166. updatable?: boolean;
  101167. }, scene: any): Mesh;
  101168. }
  101169. }
  101170. declare module BABYLON.Debug {
  101171. /**
  101172. * Used to show the physics impostor around the specific mesh
  101173. */
  101174. export class PhysicsViewer {
  101175. /** @hidden */
  101176. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  101177. /** @hidden */
  101178. protected _meshes: Array<Nullable<AbstractMesh>>;
  101179. /** @hidden */
  101180. protected _scene: Nullable<Scene>;
  101181. /** @hidden */
  101182. protected _numMeshes: number;
  101183. /** @hidden */
  101184. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  101185. private _renderFunction;
  101186. private _utilityLayer;
  101187. private _debugBoxMesh;
  101188. private _debugSphereMesh;
  101189. private _debugCylinderMesh;
  101190. private _debugMaterial;
  101191. private _debugMeshMeshes;
  101192. /**
  101193. * Creates a new PhysicsViewer
  101194. * @param scene defines the hosting scene
  101195. */
  101196. constructor(scene: Scene);
  101197. /** @hidden */
  101198. protected _updateDebugMeshes(): void;
  101199. /**
  101200. * Renders a specified physic impostor
  101201. * @param impostor defines the impostor to render
  101202. * @param targetMesh defines the mesh represented by the impostor
  101203. * @returns the new debug mesh used to render the impostor
  101204. */
  101205. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  101206. /**
  101207. * Hides a specified physic impostor
  101208. * @param impostor defines the impostor to hide
  101209. */
  101210. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  101211. private _getDebugMaterial;
  101212. private _getDebugBoxMesh;
  101213. private _getDebugSphereMesh;
  101214. private _getDebugCylinderMesh;
  101215. private _getDebugMeshMesh;
  101216. private _getDebugMesh;
  101217. /** Releases all resources */
  101218. dispose(): void;
  101219. }
  101220. }
  101221. declare module BABYLON {
  101222. /**
  101223. * Class containing static functions to help procedurally build meshes
  101224. */
  101225. export class LinesBuilder {
  101226. /**
  101227. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  101228. * * 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
  101229. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  101230. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  101231. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  101232. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  101233. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  101234. * * 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
  101235. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  101236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101237. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  101238. * @param name defines the name of the new line system
  101239. * @param options defines the options used to create the line system
  101240. * @param scene defines the hosting scene
  101241. * @returns a new line system mesh
  101242. */
  101243. static CreateLineSystem(name: string, options: {
  101244. lines: Vector3[][];
  101245. updatable?: boolean;
  101246. instance?: Nullable<LinesMesh>;
  101247. colors?: Nullable<Color4[][]>;
  101248. useVertexAlpha?: boolean;
  101249. }, scene: Nullable<Scene>): LinesMesh;
  101250. /**
  101251. * Creates a line mesh
  101252. * 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
  101253. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101254. * * The parameter `points` is an array successive Vector3
  101255. * * 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
  101256. * * The optional parameter `colors` is an array of successive Color4, one per line point
  101257. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  101258. * * When updating an instance, remember that only point positions can change, not the number of points
  101259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101260. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  101261. * @param name defines the name of the new line system
  101262. * @param options defines the options used to create the line system
  101263. * @param scene defines the hosting scene
  101264. * @returns a new line mesh
  101265. */
  101266. static CreateLines(name: string, options: {
  101267. points: Vector3[];
  101268. updatable?: boolean;
  101269. instance?: Nullable<LinesMesh>;
  101270. colors?: Color4[];
  101271. useVertexAlpha?: boolean;
  101272. }, scene?: Nullable<Scene>): LinesMesh;
  101273. /**
  101274. * Creates a dashed line mesh
  101275. * * 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
  101276. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101277. * * The parameter `points` is an array successive Vector3
  101278. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  101279. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  101280. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  101281. * * 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
  101282. * * When updating an instance, remember that only point positions can change, not the number of points
  101283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101284. * @param name defines the name of the mesh
  101285. * @param options defines the options used to create the mesh
  101286. * @param scene defines the hosting scene
  101287. * @returns the dashed line mesh
  101288. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  101289. */
  101290. static CreateDashedLines(name: string, options: {
  101291. points: Vector3[];
  101292. dashSize?: number;
  101293. gapSize?: number;
  101294. dashNb?: number;
  101295. updatable?: boolean;
  101296. instance?: LinesMesh;
  101297. }, scene?: Nullable<Scene>): LinesMesh;
  101298. }
  101299. }
  101300. declare module BABYLON {
  101301. /**
  101302. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101303. * in order to better appreciate the issue one might have.
  101304. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101305. */
  101306. export class RayHelper {
  101307. /**
  101308. * Defines the ray we are currently tryin to visualize.
  101309. */
  101310. ray: Nullable<Ray>;
  101311. private _renderPoints;
  101312. private _renderLine;
  101313. private _renderFunction;
  101314. private _scene;
  101315. private _updateToMeshFunction;
  101316. private _attachedToMesh;
  101317. private _meshSpaceDirection;
  101318. private _meshSpaceOrigin;
  101319. /**
  101320. * Helper function to create a colored helper in a scene in one line.
  101321. * @param ray Defines the ray we are currently tryin to visualize
  101322. * @param scene Defines the scene the ray is used in
  101323. * @param color Defines the color we want to see the ray in
  101324. * @returns The newly created ray helper.
  101325. */
  101326. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  101327. /**
  101328. * Instantiate a new ray helper.
  101329. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101330. * in order to better appreciate the issue one might have.
  101331. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101332. * @param ray Defines the ray we are currently tryin to visualize
  101333. */
  101334. constructor(ray: Ray);
  101335. /**
  101336. * Shows the ray we are willing to debug.
  101337. * @param scene Defines the scene the ray needs to be rendered in
  101338. * @param color Defines the color the ray needs to be rendered in
  101339. */
  101340. show(scene: Scene, color?: Color3): void;
  101341. /**
  101342. * Hides the ray we are debugging.
  101343. */
  101344. hide(): void;
  101345. private _render;
  101346. /**
  101347. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  101348. * @param mesh Defines the mesh we want the helper attached to
  101349. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  101350. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  101351. * @param length Defines the length of the ray
  101352. */
  101353. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  101354. /**
  101355. * Detach the ray helper from the mesh it has previously been attached to.
  101356. */
  101357. detachFromMesh(): void;
  101358. private _updateToMesh;
  101359. /**
  101360. * Dispose the helper and release its associated resources.
  101361. */
  101362. dispose(): void;
  101363. }
  101364. }
  101365. declare module BABYLON.Debug {
  101366. /**
  101367. * Class used to render a debug view of a given skeleton
  101368. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  101369. */
  101370. export class SkeletonViewer {
  101371. /** defines the skeleton to render */
  101372. skeleton: Skeleton;
  101373. /** defines the mesh attached to the skeleton */
  101374. mesh: AbstractMesh;
  101375. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101376. autoUpdateBonesMatrices: boolean;
  101377. /** defines the rendering group id to use with the viewer */
  101378. renderingGroupId: number;
  101379. /** Gets or sets the color used to render the skeleton */
  101380. color: Color3;
  101381. private _scene;
  101382. private _debugLines;
  101383. private _debugMesh;
  101384. private _isEnabled;
  101385. private _renderFunction;
  101386. private _utilityLayer;
  101387. /**
  101388. * Returns the mesh used to render the bones
  101389. */
  101390. readonly debugMesh: Nullable<LinesMesh>;
  101391. /**
  101392. * Creates a new SkeletonViewer
  101393. * @param skeleton defines the skeleton to render
  101394. * @param mesh defines the mesh attached to the skeleton
  101395. * @param scene defines the hosting scene
  101396. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  101397. * @param renderingGroupId defines the rendering group id to use with the viewer
  101398. */
  101399. constructor(
  101400. /** defines the skeleton to render */
  101401. skeleton: Skeleton,
  101402. /** defines the mesh attached to the skeleton */
  101403. mesh: AbstractMesh, scene: Scene,
  101404. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101405. autoUpdateBonesMatrices?: boolean,
  101406. /** defines the rendering group id to use with the viewer */
  101407. renderingGroupId?: number);
  101408. /** Gets or sets a boolean indicating if the viewer is enabled */
  101409. isEnabled: boolean;
  101410. private _getBonePosition;
  101411. private _getLinesForBonesWithLength;
  101412. private _getLinesForBonesNoLength;
  101413. /** Update the viewer to sync with current skeleton state */
  101414. update(): void;
  101415. /** Release associated resources */
  101416. dispose(): void;
  101417. }
  101418. }
  101419. declare module BABYLON {
  101420. /**
  101421. * Options to create the null engine
  101422. */
  101423. export class NullEngineOptions {
  101424. /**
  101425. * Render width (Default: 512)
  101426. */
  101427. renderWidth: number;
  101428. /**
  101429. * Render height (Default: 256)
  101430. */
  101431. renderHeight: number;
  101432. /**
  101433. * Texture size (Default: 512)
  101434. */
  101435. textureSize: number;
  101436. /**
  101437. * If delta time between frames should be constant
  101438. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101439. */
  101440. deterministicLockstep: boolean;
  101441. /**
  101442. * Maximum about of steps between frames (Default: 4)
  101443. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101444. */
  101445. lockstepMaxSteps: number;
  101446. }
  101447. /**
  101448. * The null engine class provides support for headless version of babylon.js.
  101449. * This can be used in server side scenario or for testing purposes
  101450. */
  101451. export class NullEngine extends Engine {
  101452. private _options;
  101453. /**
  101454. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101455. */
  101456. isDeterministicLockStep(): boolean;
  101457. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  101458. getLockstepMaxSteps(): number;
  101459. /**
  101460. * Sets hardware scaling, used to save performance if needed
  101461. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101462. */
  101463. getHardwareScalingLevel(): number;
  101464. constructor(options?: NullEngineOptions);
  101465. createVertexBuffer(vertices: FloatArray): DataBuffer;
  101466. createIndexBuffer(indices: IndicesArray): DataBuffer;
  101467. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101468. getRenderWidth(useScreen?: boolean): number;
  101469. getRenderHeight(useScreen?: boolean): number;
  101470. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  101471. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  101472. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  101473. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  101474. bindSamplers(effect: Effect): void;
  101475. enableEffect(effect: Effect): void;
  101476. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  101477. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  101478. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  101479. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  101480. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  101481. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  101482. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  101483. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  101484. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  101485. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  101486. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  101487. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  101488. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  101489. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  101490. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  101491. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101492. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101493. setFloat(uniform: WebGLUniformLocation, value: number): void;
  101494. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  101495. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  101496. setBool(uniform: WebGLUniformLocation, bool: number): void;
  101497. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  101498. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  101499. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  101500. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101501. bindBuffers(vertexBuffers: {
  101502. [key: string]: VertexBuffer;
  101503. }, indexBuffer: DataBuffer, effect: Effect): void;
  101504. wipeCaches(bruteForce?: boolean): void;
  101505. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101506. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101507. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101508. /** @hidden */
  101509. _createTexture(): WebGLTexture;
  101510. /** @hidden */
  101511. _releaseTexture(texture: InternalTexture): void;
  101512. 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;
  101513. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  101514. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  101515. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  101516. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101517. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  101518. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  101519. areAllEffectsReady(): boolean;
  101520. /**
  101521. * @hidden
  101522. * Get the current error code of the webGL context
  101523. * @returns the error code
  101524. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  101525. */
  101526. getError(): number;
  101527. /** @hidden */
  101528. _getUnpackAlignement(): number;
  101529. /** @hidden */
  101530. _unpackFlipY(value: boolean): void;
  101531. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  101532. /**
  101533. * Updates a dynamic vertex buffer.
  101534. * @param vertexBuffer the vertex buffer to update
  101535. * @param data the data used to update the vertex buffer
  101536. * @param byteOffset the byte offset of the data (optional)
  101537. * @param byteLength the byte length of the data (optional)
  101538. */
  101539. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  101540. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  101541. /** @hidden */
  101542. _bindTexture(channel: number, texture: InternalTexture): void;
  101543. /** @hidden */
  101544. _releaseBuffer(buffer: DataBuffer): boolean;
  101545. releaseEffects(): void;
  101546. displayLoadingUI(): void;
  101547. hideLoadingUI(): void;
  101548. /** @hidden */
  101549. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101550. /** @hidden */
  101551. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101552. /** @hidden */
  101553. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101554. /** @hidden */
  101555. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  101556. }
  101557. }
  101558. declare module BABYLON {
  101559. /** @hidden */
  101560. export class _OcclusionDataStorage {
  101561. /** @hidden */
  101562. occlusionInternalRetryCounter: number;
  101563. /** @hidden */
  101564. isOcclusionQueryInProgress: boolean;
  101565. /** @hidden */
  101566. isOccluded: boolean;
  101567. /** @hidden */
  101568. occlusionRetryCount: number;
  101569. /** @hidden */
  101570. occlusionType: number;
  101571. /** @hidden */
  101572. occlusionQueryAlgorithmType: number;
  101573. }
  101574. interface Engine {
  101575. /**
  101576. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  101577. * @return the new query
  101578. */
  101579. createQuery(): WebGLQuery;
  101580. /**
  101581. * Delete and release a webGL query
  101582. * @param query defines the query to delete
  101583. * @return the current engine
  101584. */
  101585. deleteQuery(query: WebGLQuery): Engine;
  101586. /**
  101587. * Check if a given query has resolved and got its value
  101588. * @param query defines the query to check
  101589. * @returns true if the query got its value
  101590. */
  101591. isQueryResultAvailable(query: WebGLQuery): boolean;
  101592. /**
  101593. * Gets the value of a given query
  101594. * @param query defines the query to check
  101595. * @returns the value of the query
  101596. */
  101597. getQueryResult(query: WebGLQuery): number;
  101598. /**
  101599. * Initiates an occlusion query
  101600. * @param algorithmType defines the algorithm to use
  101601. * @param query defines the query to use
  101602. * @returns the current engine
  101603. * @see http://doc.babylonjs.com/features/occlusionquery
  101604. */
  101605. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  101606. /**
  101607. * Ends an occlusion query
  101608. * @see http://doc.babylonjs.com/features/occlusionquery
  101609. * @param algorithmType defines the algorithm to use
  101610. * @returns the current engine
  101611. */
  101612. endOcclusionQuery(algorithmType: number): Engine;
  101613. /**
  101614. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  101615. * Please note that only one query can be issued at a time
  101616. * @returns a time token used to track the time span
  101617. */
  101618. startTimeQuery(): Nullable<_TimeToken>;
  101619. /**
  101620. * Ends a time query
  101621. * @param token defines the token used to measure the time span
  101622. * @returns the time spent (in ns)
  101623. */
  101624. endTimeQuery(token: _TimeToken): int;
  101625. /** @hidden */
  101626. _currentNonTimestampToken: Nullable<_TimeToken>;
  101627. /** @hidden */
  101628. _createTimeQuery(): WebGLQuery;
  101629. /** @hidden */
  101630. _deleteTimeQuery(query: WebGLQuery): void;
  101631. /** @hidden */
  101632. _getGlAlgorithmType(algorithmType: number): number;
  101633. /** @hidden */
  101634. _getTimeQueryResult(query: WebGLQuery): any;
  101635. /** @hidden */
  101636. _getTimeQueryAvailability(query: WebGLQuery): any;
  101637. }
  101638. interface AbstractMesh {
  101639. /**
  101640. * Backing filed
  101641. * @hidden
  101642. */
  101643. __occlusionDataStorage: _OcclusionDataStorage;
  101644. /**
  101645. * Access property
  101646. * @hidden
  101647. */
  101648. _occlusionDataStorage: _OcclusionDataStorage;
  101649. /**
  101650. * 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.
  101651. * The default value is -1 which means don't break the query and wait till the result
  101652. * @see http://doc.babylonjs.com/features/occlusionquery
  101653. */
  101654. occlusionRetryCount: number;
  101655. /**
  101656. * 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:
  101657. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  101658. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  101659. * * 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.
  101660. * @see http://doc.babylonjs.com/features/occlusionquery
  101661. */
  101662. occlusionType: number;
  101663. /**
  101664. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  101665. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  101666. * * 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.
  101667. * @see http://doc.babylonjs.com/features/occlusionquery
  101668. */
  101669. occlusionQueryAlgorithmType: number;
  101670. /**
  101671. * 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
  101672. * @see http://doc.babylonjs.com/features/occlusionquery
  101673. */
  101674. isOccluded: boolean;
  101675. /**
  101676. * Flag to check the progress status of the query
  101677. * @see http://doc.babylonjs.com/features/occlusionquery
  101678. */
  101679. isOcclusionQueryInProgress: boolean;
  101680. }
  101681. }
  101682. declare module BABYLON {
  101683. /** @hidden */
  101684. export var _forceTransformFeedbackToBundle: boolean;
  101685. interface Engine {
  101686. /**
  101687. * Creates a webGL transform feedback object
  101688. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  101689. * @returns the webGL transform feedback object
  101690. */
  101691. createTransformFeedback(): WebGLTransformFeedback;
  101692. /**
  101693. * Delete a webGL transform feedback object
  101694. * @param value defines the webGL transform feedback object to delete
  101695. */
  101696. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  101697. /**
  101698. * Bind a webGL transform feedback object to the webgl context
  101699. * @param value defines the webGL transform feedback object to bind
  101700. */
  101701. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  101702. /**
  101703. * Begins a transform feedback operation
  101704. * @param usePoints defines if points or triangles must be used
  101705. */
  101706. beginTransformFeedback(usePoints: boolean): void;
  101707. /**
  101708. * Ends a transform feedback operation
  101709. */
  101710. endTransformFeedback(): void;
  101711. /**
  101712. * Specify the varyings to use with transform feedback
  101713. * @param program defines the associated webGL program
  101714. * @param value defines the list of strings representing the varying names
  101715. */
  101716. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  101717. /**
  101718. * Bind a webGL buffer for a transform feedback operation
  101719. * @param value defines the webGL buffer to bind
  101720. */
  101721. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  101722. }
  101723. }
  101724. declare module BABYLON {
  101725. /**
  101726. * Creation options of the multi render target texture.
  101727. */
  101728. export interface IMultiRenderTargetOptions {
  101729. /**
  101730. * Define if the texture needs to create mip maps after render.
  101731. */
  101732. generateMipMaps?: boolean;
  101733. /**
  101734. * Define the types of all the draw buffers we want to create
  101735. */
  101736. types?: number[];
  101737. /**
  101738. * Define the sampling modes of all the draw buffers we want to create
  101739. */
  101740. samplingModes?: number[];
  101741. /**
  101742. * Define if a depth buffer is required
  101743. */
  101744. generateDepthBuffer?: boolean;
  101745. /**
  101746. * Define if a stencil buffer is required
  101747. */
  101748. generateStencilBuffer?: boolean;
  101749. /**
  101750. * Define if a depth texture is required instead of a depth buffer
  101751. */
  101752. generateDepthTexture?: boolean;
  101753. /**
  101754. * Define the number of desired draw buffers
  101755. */
  101756. textureCount?: number;
  101757. /**
  101758. * Define if aspect ratio should be adapted to the texture or stay the scene one
  101759. */
  101760. doNotChangeAspectRatio?: boolean;
  101761. /**
  101762. * Define the default type of the buffers we are creating
  101763. */
  101764. defaultType?: number;
  101765. }
  101766. /**
  101767. * A multi render target, like a render target provides the ability to render to a texture.
  101768. * Unlike the render target, it can render to several draw buffers in one draw.
  101769. * This is specially interesting in deferred rendering or for any effects requiring more than
  101770. * just one color from a single pass.
  101771. */
  101772. export class MultiRenderTarget extends RenderTargetTexture {
  101773. private _internalTextures;
  101774. private _textures;
  101775. private _multiRenderTargetOptions;
  101776. /**
  101777. * Get if draw buffers are currently supported by the used hardware and browser.
  101778. */
  101779. readonly isSupported: boolean;
  101780. /**
  101781. * Get the list of textures generated by the multi render target.
  101782. */
  101783. readonly textures: Texture[];
  101784. /**
  101785. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  101786. */
  101787. readonly depthTexture: Texture;
  101788. /**
  101789. * Set the wrapping mode on U of all the textures we are rendering to.
  101790. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101791. */
  101792. wrapU: number;
  101793. /**
  101794. * Set the wrapping mode on V of all the textures we are rendering to.
  101795. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101796. */
  101797. wrapV: number;
  101798. /**
  101799. * Instantiate a new multi render target texture.
  101800. * A multi render target, like a render target provides the ability to render to a texture.
  101801. * Unlike the render target, it can render to several draw buffers in one draw.
  101802. * This is specially interesting in deferred rendering or for any effects requiring more than
  101803. * just one color from a single pass.
  101804. * @param name Define the name of the texture
  101805. * @param size Define the size of the buffers to render to
  101806. * @param count Define the number of target we are rendering into
  101807. * @param scene Define the scene the texture belongs to
  101808. * @param options Define the options used to create the multi render target
  101809. */
  101810. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  101811. /** @hidden */
  101812. _rebuild(): void;
  101813. private _createInternalTextures;
  101814. private _createTextures;
  101815. /**
  101816. * Define the number of samples used if MSAA is enabled.
  101817. */
  101818. samples: number;
  101819. /**
  101820. * Resize all the textures in the multi render target.
  101821. * Be carrefull as it will recreate all the data in the new texture.
  101822. * @param size Define the new size
  101823. */
  101824. resize(size: any): void;
  101825. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101826. /**
  101827. * Dispose the render targets and their associated resources
  101828. */
  101829. dispose(): void;
  101830. /**
  101831. * Release all the underlying texture used as draw buffers.
  101832. */
  101833. releaseInternalTextures(): void;
  101834. }
  101835. }
  101836. declare module BABYLON {
  101837. interface Engine {
  101838. /**
  101839. * Unbind a list of render target textures from the webGL context
  101840. * This is used only when drawBuffer extension or webGL2 are active
  101841. * @param textures defines the render target textures to unbind
  101842. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101843. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101844. */
  101845. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  101846. /**
  101847. * Create a multi render target texture
  101848. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  101849. * @param size defines the size of the texture
  101850. * @param options defines the creation options
  101851. * @returns the cube texture as an InternalTexture
  101852. */
  101853. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  101854. /**
  101855. * Update the sample count for a given multiple render target texture
  101856. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  101857. * @param textures defines the textures to update
  101858. * @param samples defines the sample count to set
  101859. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  101860. */
  101861. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  101862. }
  101863. }
  101864. declare module BABYLON {
  101865. /**
  101866. * Gather the list of clipboard event types as constants.
  101867. */
  101868. export class ClipboardEventTypes {
  101869. /**
  101870. * The clipboard event is fired when a copy command is active (pressed).
  101871. */
  101872. static readonly COPY: number;
  101873. /**
  101874. * The clipboard event is fired when a cut command is active (pressed).
  101875. */
  101876. static readonly CUT: number;
  101877. /**
  101878. * The clipboard event is fired when a paste command is active (pressed).
  101879. */
  101880. static readonly PASTE: number;
  101881. }
  101882. /**
  101883. * This class is used to store clipboard related info for the onClipboardObservable event.
  101884. */
  101885. export class ClipboardInfo {
  101886. /**
  101887. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101888. */
  101889. type: number;
  101890. /**
  101891. * Defines the related dom event
  101892. */
  101893. event: ClipboardEvent;
  101894. /**
  101895. *Creates an instance of ClipboardInfo.
  101896. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  101897. * @param event Defines the related dom event
  101898. */
  101899. constructor(
  101900. /**
  101901. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101902. */
  101903. type: number,
  101904. /**
  101905. * Defines the related dom event
  101906. */
  101907. event: ClipboardEvent);
  101908. /**
  101909. * Get the clipboard event's type from the keycode.
  101910. * @param keyCode Defines the keyCode for the current keyboard event.
  101911. * @return {number}
  101912. */
  101913. static GetTypeFromCharacter(keyCode: number): number;
  101914. }
  101915. }
  101916. declare module BABYLON {
  101917. /**
  101918. * Class used to represent data loading progression
  101919. */
  101920. export class SceneLoaderProgressEvent {
  101921. /** defines if data length to load can be evaluated */
  101922. readonly lengthComputable: boolean;
  101923. /** defines the loaded data length */
  101924. readonly loaded: number;
  101925. /** defines the data length to load */
  101926. readonly total: number;
  101927. /**
  101928. * Create a new progress event
  101929. * @param lengthComputable defines if data length to load can be evaluated
  101930. * @param loaded defines the loaded data length
  101931. * @param total defines the data length to load
  101932. */
  101933. constructor(
  101934. /** defines if data length to load can be evaluated */
  101935. lengthComputable: boolean,
  101936. /** defines the loaded data length */
  101937. loaded: number,
  101938. /** defines the data length to load */
  101939. total: number);
  101940. /**
  101941. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  101942. * @param event defines the source event
  101943. * @returns a new SceneLoaderProgressEvent
  101944. */
  101945. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  101946. }
  101947. /**
  101948. * Interface used by SceneLoader plugins to define supported file extensions
  101949. */
  101950. export interface ISceneLoaderPluginExtensions {
  101951. /**
  101952. * Defines the list of supported extensions
  101953. */
  101954. [extension: string]: {
  101955. isBinary: boolean;
  101956. };
  101957. }
  101958. /**
  101959. * Interface used by SceneLoader plugin factory
  101960. */
  101961. export interface ISceneLoaderPluginFactory {
  101962. /**
  101963. * Defines the name of the factory
  101964. */
  101965. name: string;
  101966. /**
  101967. * Function called to create a new plugin
  101968. * @return the new plugin
  101969. */
  101970. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  101971. /**
  101972. * Boolean indicating if the plugin can direct load specific data
  101973. */
  101974. canDirectLoad?: (data: string) => boolean;
  101975. }
  101976. /**
  101977. * Interface used to define a SceneLoader plugin
  101978. */
  101979. export interface ISceneLoaderPlugin {
  101980. /**
  101981. * The friendly name of this plugin.
  101982. */
  101983. name: string;
  101984. /**
  101985. * The file extensions supported by this plugin.
  101986. */
  101987. extensions: string | ISceneLoaderPluginExtensions;
  101988. /**
  101989. * Import meshes into a scene.
  101990. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101991. * @param scene The scene to import into
  101992. * @param data The data to import
  101993. * @param rootUrl The root url for scene and resources
  101994. * @param meshes The meshes array to import into
  101995. * @param particleSystems The particle systems array to import into
  101996. * @param skeletons The skeletons array to import into
  101997. * @param onError The callback when import fails
  101998. * @returns True if successful or false otherwise
  101999. */
  102000. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  102001. /**
  102002. * Load into a scene.
  102003. * @param scene The scene to load into
  102004. * @param data The data to import
  102005. * @param rootUrl The root url for scene and resources
  102006. * @param onError The callback when import fails
  102007. * @returns true if successful or false otherwise
  102008. */
  102009. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  102010. /**
  102011. * The callback that returns true if the data can be directly loaded.
  102012. */
  102013. canDirectLoad?: (data: string) => boolean;
  102014. /**
  102015. * The callback that allows custom handling of the root url based on the response url.
  102016. */
  102017. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  102018. /**
  102019. * Load into an asset container.
  102020. * @param scene The scene to load into
  102021. * @param data The data to import
  102022. * @param rootUrl The root url for scene and resources
  102023. * @param onError The callback when import fails
  102024. * @returns The loaded asset container
  102025. */
  102026. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  102027. }
  102028. /**
  102029. * Interface used to define an async SceneLoader plugin
  102030. */
  102031. export interface ISceneLoaderPluginAsync {
  102032. /**
  102033. * The friendly name of this plugin.
  102034. */
  102035. name: string;
  102036. /**
  102037. * The file extensions supported by this plugin.
  102038. */
  102039. extensions: string | ISceneLoaderPluginExtensions;
  102040. /**
  102041. * Import meshes into a scene.
  102042. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  102043. * @param scene The scene to import into
  102044. * @param data The data to import
  102045. * @param rootUrl The root url for scene and resources
  102046. * @param onProgress The callback when the load progresses
  102047. * @param fileName Defines the name of the file to load
  102048. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  102049. */
  102050. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  102051. meshes: AbstractMesh[];
  102052. particleSystems: IParticleSystem[];
  102053. skeletons: Skeleton[];
  102054. animationGroups: AnimationGroup[];
  102055. }>;
  102056. /**
  102057. * Load into a scene.
  102058. * @param scene The scene to load into
  102059. * @param data The data to import
  102060. * @param rootUrl The root url for scene and resources
  102061. * @param onProgress The callback when the load progresses
  102062. * @param fileName Defines the name of the file to load
  102063. * @returns Nothing
  102064. */
  102065. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  102066. /**
  102067. * The callback that returns true if the data can be directly loaded.
  102068. */
  102069. canDirectLoad?: (data: string) => boolean;
  102070. /**
  102071. * The callback that allows custom handling of the root url based on the response url.
  102072. */
  102073. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  102074. /**
  102075. * Load into an asset container.
  102076. * @param scene The scene to load into
  102077. * @param data The data to import
  102078. * @param rootUrl The root url for scene and resources
  102079. * @param onProgress The callback when the load progresses
  102080. * @param fileName Defines the name of the file to load
  102081. * @returns The loaded asset container
  102082. */
  102083. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  102084. }
  102085. /**
  102086. * Class used to load scene from various file formats using registered plugins
  102087. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  102088. */
  102089. export class SceneLoader {
  102090. /**
  102091. * No logging while loading
  102092. */
  102093. static readonly NO_LOGGING: number;
  102094. /**
  102095. * Minimal logging while loading
  102096. */
  102097. static readonly MINIMAL_LOGGING: number;
  102098. /**
  102099. * Summary logging while loading
  102100. */
  102101. static readonly SUMMARY_LOGGING: number;
  102102. /**
  102103. * Detailled logging while loading
  102104. */
  102105. static readonly DETAILED_LOGGING: number;
  102106. /**
  102107. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  102108. */
  102109. static ForceFullSceneLoadingForIncremental: boolean;
  102110. /**
  102111. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  102112. */
  102113. static ShowLoadingScreen: boolean;
  102114. /**
  102115. * Defines the current logging level (while loading the scene)
  102116. * @ignorenaming
  102117. */
  102118. static loggingLevel: number;
  102119. /**
  102120. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  102121. */
  102122. static CleanBoneMatrixWeights: boolean;
  102123. /**
  102124. * Event raised when a plugin is used to load a scene
  102125. */
  102126. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  102127. private static _registeredPlugins;
  102128. private static _getDefaultPlugin;
  102129. private static _getPluginForExtension;
  102130. private static _getPluginForDirectLoad;
  102131. private static _getPluginForFilename;
  102132. private static _getDirectLoad;
  102133. private static _loadData;
  102134. private static _getFileInfo;
  102135. /**
  102136. * Gets a plugin that can load the given extension
  102137. * @param extension defines the extension to load
  102138. * @returns a plugin or null if none works
  102139. */
  102140. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  102141. /**
  102142. * Gets a boolean indicating that the given extension can be loaded
  102143. * @param extension defines the extension to load
  102144. * @returns true if the extension is supported
  102145. */
  102146. static IsPluginForExtensionAvailable(extension: string): boolean;
  102147. /**
  102148. * Adds a new plugin to the list of registered plugins
  102149. * @param plugin defines the plugin to add
  102150. */
  102151. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  102152. /**
  102153. * Import meshes into a scene
  102154. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  102155. * @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)
  102156. * @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)
  102157. * @param scene the instance of BABYLON.Scene to append to
  102158. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  102159. * @param onProgress a callback with a progress event for each file being loaded
  102160. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102161. * @param pluginExtension the extension used to determine the plugin
  102162. * @returns The loaded plugin
  102163. */
  102164. 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>;
  102165. /**
  102166. * Import meshes into a scene
  102167. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  102168. * @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)
  102169. * @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)
  102170. * @param scene the instance of BABYLON.Scene to append to
  102171. * @param onProgress a callback with a progress event for each file being loaded
  102172. * @param pluginExtension the extension used to determine the plugin
  102173. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  102174. */
  102175. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  102176. meshes: AbstractMesh[];
  102177. particleSystems: IParticleSystem[];
  102178. skeletons: Skeleton[];
  102179. animationGroups: AnimationGroup[];
  102180. }>;
  102181. /**
  102182. * Load a scene
  102183. * @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)
  102184. * @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)
  102185. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102186. * @param onSuccess a callback with the scene when import succeeds
  102187. * @param onProgress a callback with a progress event for each file being loaded
  102188. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102189. * @param pluginExtension the extension used to determine the plugin
  102190. * @returns The loaded plugin
  102191. */
  102192. 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>;
  102193. /**
  102194. * Load a scene
  102195. * @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)
  102196. * @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)
  102197. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102198. * @param onProgress a callback with a progress event for each file being loaded
  102199. * @param pluginExtension the extension used to determine the plugin
  102200. * @returns The loaded scene
  102201. */
  102202. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102203. /**
  102204. * Append a scene
  102205. * @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)
  102206. * @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)
  102207. * @param scene is the instance of BABYLON.Scene to append to
  102208. * @param onSuccess a callback with the scene when import succeeds
  102209. * @param onProgress a callback with a progress event for each file being loaded
  102210. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102211. * @param pluginExtension the extension used to determine the plugin
  102212. * @returns The loaded plugin
  102213. */
  102214. 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>;
  102215. /**
  102216. * Append a scene
  102217. * @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)
  102218. * @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)
  102219. * @param scene is the instance of BABYLON.Scene to append to
  102220. * @param onProgress a callback with a progress event for each file being loaded
  102221. * @param pluginExtension the extension used to determine the plugin
  102222. * @returns The given scene
  102223. */
  102224. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102225. /**
  102226. * Load a scene into an asset container
  102227. * @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)
  102228. * @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)
  102229. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  102230. * @param onSuccess a callback with the scene when import succeeds
  102231. * @param onProgress a callback with a progress event for each file being loaded
  102232. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102233. * @param pluginExtension the extension used to determine the plugin
  102234. * @returns The loaded plugin
  102235. */
  102236. 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>;
  102237. /**
  102238. * Load a scene into an asset container
  102239. * @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)
  102240. * @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)
  102241. * @param scene is the instance of Scene to append to
  102242. * @param onProgress a callback with a progress event for each file being loaded
  102243. * @param pluginExtension the extension used to determine the plugin
  102244. * @returns The loaded asset container
  102245. */
  102246. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  102247. }
  102248. }
  102249. declare module BABYLON {
  102250. /**
  102251. * Google Daydream controller
  102252. */
  102253. export class DaydreamController extends WebVRController {
  102254. /**
  102255. * Base Url for the controller model.
  102256. */
  102257. static MODEL_BASE_URL: string;
  102258. /**
  102259. * File name for the controller model.
  102260. */
  102261. static MODEL_FILENAME: string;
  102262. /**
  102263. * Gamepad Id prefix used to identify Daydream Controller.
  102264. */
  102265. static readonly GAMEPAD_ID_PREFIX: string;
  102266. /**
  102267. * Creates a new DaydreamController from a gamepad
  102268. * @param vrGamepad the gamepad that the controller should be created from
  102269. */
  102270. constructor(vrGamepad: any);
  102271. /**
  102272. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102273. * @param scene scene in which to add meshes
  102274. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102275. */
  102276. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102277. /**
  102278. * Called once for each button that changed state since the last frame
  102279. * @param buttonIdx Which button index changed
  102280. * @param state New state of the button
  102281. * @param changes Which properties on the state changed since last frame
  102282. */
  102283. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102284. }
  102285. }
  102286. declare module BABYLON {
  102287. /**
  102288. * Gear VR Controller
  102289. */
  102290. export class GearVRController extends WebVRController {
  102291. /**
  102292. * Base Url for the controller model.
  102293. */
  102294. static MODEL_BASE_URL: string;
  102295. /**
  102296. * File name for the controller model.
  102297. */
  102298. static MODEL_FILENAME: string;
  102299. /**
  102300. * Gamepad Id prefix used to identify this controller.
  102301. */
  102302. static readonly GAMEPAD_ID_PREFIX: string;
  102303. private readonly _buttonIndexToObservableNameMap;
  102304. /**
  102305. * Creates a new GearVRController from a gamepad
  102306. * @param vrGamepad the gamepad that the controller should be created from
  102307. */
  102308. constructor(vrGamepad: any);
  102309. /**
  102310. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102311. * @param scene scene in which to add meshes
  102312. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102313. */
  102314. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102315. /**
  102316. * Called once for each button that changed state since the last frame
  102317. * @param buttonIdx Which button index changed
  102318. * @param state New state of the button
  102319. * @param changes Which properties on the state changed since last frame
  102320. */
  102321. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102322. }
  102323. }
  102324. declare module BABYLON {
  102325. /**
  102326. * Generic Controller
  102327. */
  102328. export class GenericController extends WebVRController {
  102329. /**
  102330. * Base Url for the controller model.
  102331. */
  102332. static readonly MODEL_BASE_URL: string;
  102333. /**
  102334. * File name for the controller model.
  102335. */
  102336. static readonly MODEL_FILENAME: string;
  102337. /**
  102338. * Creates a new GenericController from a gamepad
  102339. * @param vrGamepad the gamepad that the controller should be created from
  102340. */
  102341. constructor(vrGamepad: any);
  102342. /**
  102343. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102344. * @param scene scene in which to add meshes
  102345. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102346. */
  102347. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102348. /**
  102349. * Called once for each button that changed state since the last frame
  102350. * @param buttonIdx Which button index changed
  102351. * @param state New state of the button
  102352. * @param changes Which properties on the state changed since last frame
  102353. */
  102354. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102355. }
  102356. }
  102357. declare module BABYLON {
  102358. /**
  102359. * Oculus Touch Controller
  102360. */
  102361. export class OculusTouchController extends WebVRController {
  102362. /**
  102363. * Base Url for the controller model.
  102364. */
  102365. static MODEL_BASE_URL: string;
  102366. /**
  102367. * File name for the left controller model.
  102368. */
  102369. static MODEL_LEFT_FILENAME: string;
  102370. /**
  102371. * File name for the right controller model.
  102372. */
  102373. static MODEL_RIGHT_FILENAME: string;
  102374. /**
  102375. * Fired when the secondary trigger on this controller is modified
  102376. */
  102377. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  102378. /**
  102379. * Fired when the thumb rest on this controller is modified
  102380. */
  102381. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  102382. /**
  102383. * Creates a new OculusTouchController from a gamepad
  102384. * @param vrGamepad the gamepad that the controller should be created from
  102385. */
  102386. constructor(vrGamepad: any);
  102387. /**
  102388. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102389. * @param scene scene in which to add meshes
  102390. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102391. */
  102392. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102393. /**
  102394. * Fired when the A button on this controller is modified
  102395. */
  102396. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102397. /**
  102398. * Fired when the B button on this controller is modified
  102399. */
  102400. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102401. /**
  102402. * Fired when the X button on this controller is modified
  102403. */
  102404. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102405. /**
  102406. * Fired when the Y button on this controller is modified
  102407. */
  102408. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102409. /**
  102410. * Called once for each button that changed state since the last frame
  102411. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  102412. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  102413. * 2) secondary trigger (same)
  102414. * 3) A (right) X (left), touch, pressed = value
  102415. * 4) B / Y
  102416. * 5) thumb rest
  102417. * @param buttonIdx Which button index changed
  102418. * @param state New state of the button
  102419. * @param changes Which properties on the state changed since last frame
  102420. */
  102421. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102422. }
  102423. }
  102424. declare module BABYLON {
  102425. /**
  102426. * Vive Controller
  102427. */
  102428. export class ViveController extends WebVRController {
  102429. /**
  102430. * Base Url for the controller model.
  102431. */
  102432. static MODEL_BASE_URL: string;
  102433. /**
  102434. * File name for the controller model.
  102435. */
  102436. static MODEL_FILENAME: string;
  102437. /**
  102438. * Creates a new ViveController from a gamepad
  102439. * @param vrGamepad the gamepad that the controller should be created from
  102440. */
  102441. constructor(vrGamepad: any);
  102442. /**
  102443. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102444. * @param scene scene in which to add meshes
  102445. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102446. */
  102447. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102448. /**
  102449. * Fired when the left button on this controller is modified
  102450. */
  102451. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102452. /**
  102453. * Fired when the right button on this controller is modified
  102454. */
  102455. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102456. /**
  102457. * Fired when the menu button on this controller is modified
  102458. */
  102459. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102460. /**
  102461. * Called once for each button that changed state since the last frame
  102462. * Vive mapping:
  102463. * 0: touchpad
  102464. * 1: trigger
  102465. * 2: left AND right buttons
  102466. * 3: menu button
  102467. * @param buttonIdx Which button index changed
  102468. * @param state New state of the button
  102469. * @param changes Which properties on the state changed since last frame
  102470. */
  102471. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102472. }
  102473. }
  102474. declare module BABYLON {
  102475. /**
  102476. * Defines the WindowsMotionController object that the state of the windows motion controller
  102477. */
  102478. export class WindowsMotionController extends WebVRController {
  102479. /**
  102480. * The base url used to load the left and right controller models
  102481. */
  102482. static MODEL_BASE_URL: string;
  102483. /**
  102484. * The name of the left controller model file
  102485. */
  102486. static MODEL_LEFT_FILENAME: string;
  102487. /**
  102488. * The name of the right controller model file
  102489. */
  102490. static MODEL_RIGHT_FILENAME: string;
  102491. /**
  102492. * The controller name prefix for this controller type
  102493. */
  102494. static readonly GAMEPAD_ID_PREFIX: string;
  102495. /**
  102496. * The controller id pattern for this controller type
  102497. */
  102498. private static readonly GAMEPAD_ID_PATTERN;
  102499. private _loadedMeshInfo;
  102500. private readonly _mapping;
  102501. /**
  102502. * Fired when the trackpad on this controller is clicked
  102503. */
  102504. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  102505. /**
  102506. * Fired when the trackpad on this controller is modified
  102507. */
  102508. onTrackpadValuesChangedObservable: Observable<StickValues>;
  102509. /**
  102510. * The current x and y values of this controller's trackpad
  102511. */
  102512. trackpad: StickValues;
  102513. /**
  102514. * Creates a new WindowsMotionController from a gamepad
  102515. * @param vrGamepad the gamepad that the controller should be created from
  102516. */
  102517. constructor(vrGamepad: any);
  102518. /**
  102519. * Fired when the trigger on this controller is modified
  102520. */
  102521. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102522. /**
  102523. * Fired when the menu button on this controller is modified
  102524. */
  102525. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102526. /**
  102527. * Fired when the grip button on this controller is modified
  102528. */
  102529. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102530. /**
  102531. * Fired when the thumbstick button on this controller is modified
  102532. */
  102533. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102534. /**
  102535. * Fired when the touchpad button on this controller is modified
  102536. */
  102537. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102538. /**
  102539. * Fired when the touchpad values on this controller are modified
  102540. */
  102541. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  102542. private _updateTrackpad;
  102543. /**
  102544. * Called once per frame by the engine.
  102545. */
  102546. update(): void;
  102547. /**
  102548. * Called once for each button that changed state since the last frame
  102549. * @param buttonIdx Which button index changed
  102550. * @param state New state of the button
  102551. * @param changes Which properties on the state changed since last frame
  102552. */
  102553. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102554. /**
  102555. * Moves the buttons on the controller mesh based on their current state
  102556. * @param buttonName the name of the button to move
  102557. * @param buttonValue the value of the button which determines the buttons new position
  102558. */
  102559. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  102560. /**
  102561. * Moves the axis on the controller mesh based on its current state
  102562. * @param axis the index of the axis
  102563. * @param axisValue the value of the axis which determines the meshes new position
  102564. * @hidden
  102565. */
  102566. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  102567. /**
  102568. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102569. * @param scene scene in which to add meshes
  102570. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102571. */
  102572. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  102573. /**
  102574. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  102575. * can be transformed by button presses and axes values, based on this._mapping.
  102576. *
  102577. * @param scene scene in which the meshes exist
  102578. * @param meshes list of meshes that make up the controller model to process
  102579. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  102580. */
  102581. private processModel;
  102582. private createMeshInfo;
  102583. /**
  102584. * Gets the ray of the controller in the direction the controller is pointing
  102585. * @param length the length the resulting ray should be
  102586. * @returns a ray in the direction the controller is pointing
  102587. */
  102588. getForwardRay(length?: number): Ray;
  102589. /**
  102590. * Disposes of the controller
  102591. */
  102592. dispose(): void;
  102593. }
  102594. }
  102595. declare module BABYLON {
  102596. /**
  102597. * Single axis scale gizmo
  102598. */
  102599. export class AxisScaleGizmo extends Gizmo {
  102600. private _coloredMaterial;
  102601. /**
  102602. * Drag behavior responsible for the gizmos dragging interactions
  102603. */
  102604. dragBehavior: PointerDragBehavior;
  102605. private _pointerObserver;
  102606. /**
  102607. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102608. */
  102609. snapDistance: number;
  102610. /**
  102611. * Event that fires each time the gizmo snaps to a new location.
  102612. * * snapDistance is the the change in distance
  102613. */
  102614. onSnapObservable: Observable<{
  102615. snapDistance: number;
  102616. }>;
  102617. /**
  102618. * If the scaling operation should be done on all axis (default: false)
  102619. */
  102620. uniformScaling: boolean;
  102621. /**
  102622. * Creates an AxisScaleGizmo
  102623. * @param gizmoLayer The utility layer the gizmo will be added to
  102624. * @param dragAxis The axis which the gizmo will be able to scale on
  102625. * @param color The color of the gizmo
  102626. */
  102627. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102628. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102629. /**
  102630. * Disposes of the gizmo
  102631. */
  102632. dispose(): void;
  102633. /**
  102634. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  102635. * @param mesh The mesh to replace the default mesh of the gizmo
  102636. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  102637. */
  102638. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  102639. }
  102640. }
  102641. declare module BABYLON {
  102642. /**
  102643. * Bounding box gizmo
  102644. */
  102645. export class BoundingBoxGizmo extends Gizmo {
  102646. private _lineBoundingBox;
  102647. private _rotateSpheresParent;
  102648. private _scaleBoxesParent;
  102649. private _boundingDimensions;
  102650. private _renderObserver;
  102651. private _pointerObserver;
  102652. private _scaleDragSpeed;
  102653. private _tmpQuaternion;
  102654. private _tmpVector;
  102655. private _tmpRotationMatrix;
  102656. /**
  102657. * 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)
  102658. */
  102659. ignoreChildren: boolean;
  102660. /**
  102661. * 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)
  102662. */
  102663. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  102664. /**
  102665. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  102666. */
  102667. rotationSphereSize: number;
  102668. /**
  102669. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  102670. */
  102671. scaleBoxSize: number;
  102672. /**
  102673. * 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)
  102674. */
  102675. fixedDragMeshScreenSize: boolean;
  102676. /**
  102677. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  102678. */
  102679. fixedDragMeshScreenSizeDistanceFactor: number;
  102680. /**
  102681. * Fired when a rotation sphere or scale box is dragged
  102682. */
  102683. onDragStartObservable: Observable<{}>;
  102684. /**
  102685. * Fired when a scale box is dragged
  102686. */
  102687. onScaleBoxDragObservable: Observable<{}>;
  102688. /**
  102689. * Fired when a scale box drag is ended
  102690. */
  102691. onScaleBoxDragEndObservable: Observable<{}>;
  102692. /**
  102693. * Fired when a rotation sphere is dragged
  102694. */
  102695. onRotationSphereDragObservable: Observable<{}>;
  102696. /**
  102697. * Fired when a rotation sphere drag is ended
  102698. */
  102699. onRotationSphereDragEndObservable: Observable<{}>;
  102700. /**
  102701. * 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)
  102702. */
  102703. scalePivot: Nullable<Vector3>;
  102704. /**
  102705. * Mesh used as a pivot to rotate the attached mesh
  102706. */
  102707. private _anchorMesh;
  102708. private _existingMeshScale;
  102709. private _dragMesh;
  102710. private pointerDragBehavior;
  102711. private coloredMaterial;
  102712. private hoverColoredMaterial;
  102713. /**
  102714. * Sets the color of the bounding box gizmo
  102715. * @param color the color to set
  102716. */
  102717. setColor(color: Color3): void;
  102718. /**
  102719. * Creates an BoundingBoxGizmo
  102720. * @param gizmoLayer The utility layer the gizmo will be added to
  102721. * @param color The color of the gizmo
  102722. */
  102723. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102724. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102725. private _selectNode;
  102726. /**
  102727. * Updates the bounding box information for the Gizmo
  102728. */
  102729. updateBoundingBox(): void;
  102730. private _updateRotationSpheres;
  102731. private _updateScaleBoxes;
  102732. /**
  102733. * Enables rotation on the specified axis and disables rotation on the others
  102734. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  102735. */
  102736. setEnabledRotationAxis(axis: string): void;
  102737. /**
  102738. * Enables/disables scaling
  102739. * @param enable if scaling should be enabled
  102740. */
  102741. setEnabledScaling(enable: boolean): void;
  102742. private _updateDummy;
  102743. /**
  102744. * Enables a pointer drag behavior on the bounding box of the gizmo
  102745. */
  102746. enableDragBehavior(): void;
  102747. /**
  102748. * Disposes of the gizmo
  102749. */
  102750. dispose(): void;
  102751. /**
  102752. * 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)
  102753. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  102754. * @returns the bounding box mesh with the passed in mesh as a child
  102755. */
  102756. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  102757. /**
  102758. * CustomMeshes are not supported by this gizmo
  102759. * @param mesh The mesh to replace the default mesh of the gizmo
  102760. */
  102761. setCustomMesh(mesh: Mesh): void;
  102762. }
  102763. }
  102764. declare module BABYLON {
  102765. /**
  102766. * Single plane rotation gizmo
  102767. */
  102768. export class PlaneRotationGizmo extends Gizmo {
  102769. /**
  102770. * Drag behavior responsible for the gizmos dragging interactions
  102771. */
  102772. dragBehavior: PointerDragBehavior;
  102773. private _pointerObserver;
  102774. /**
  102775. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  102776. */
  102777. snapDistance: number;
  102778. /**
  102779. * Event that fires each time the gizmo snaps to a new location.
  102780. * * snapDistance is the the change in distance
  102781. */
  102782. onSnapObservable: Observable<{
  102783. snapDistance: number;
  102784. }>;
  102785. /**
  102786. * Creates a PlaneRotationGizmo
  102787. * @param gizmoLayer The utility layer the gizmo will be added to
  102788. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  102789. * @param color The color of the gizmo
  102790. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102791. */
  102792. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102793. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102794. /**
  102795. * Disposes of the gizmo
  102796. */
  102797. dispose(): void;
  102798. }
  102799. }
  102800. declare module BABYLON {
  102801. /**
  102802. * Gizmo that enables rotating a mesh along 3 axis
  102803. */
  102804. export class RotationGizmo extends Gizmo {
  102805. /**
  102806. * Internal gizmo used for interactions on the x axis
  102807. */
  102808. xGizmo: PlaneRotationGizmo;
  102809. /**
  102810. * Internal gizmo used for interactions on the y axis
  102811. */
  102812. yGizmo: PlaneRotationGizmo;
  102813. /**
  102814. * Internal gizmo used for interactions on the z axis
  102815. */
  102816. zGizmo: PlaneRotationGizmo;
  102817. /** Fires an event when any of it's sub gizmos are dragged */
  102818. onDragStartObservable: Observable<{}>;
  102819. /** Fires an event when any of it's sub gizmos are released from dragging */
  102820. onDragEndObservable: Observable<{}>;
  102821. attachedMesh: Nullable<AbstractMesh>;
  102822. /**
  102823. * Creates a RotationGizmo
  102824. * @param gizmoLayer The utility layer the gizmo will be added to
  102825. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102826. */
  102827. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102828. updateGizmoRotationToMatchAttachedMesh: boolean;
  102829. /**
  102830. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102831. */
  102832. snapDistance: number;
  102833. /**
  102834. * Ratio for the scale of the gizmo (Default: 1)
  102835. */
  102836. scaleRatio: number;
  102837. /**
  102838. * Disposes of the gizmo
  102839. */
  102840. dispose(): void;
  102841. /**
  102842. * CustomMeshes are not supported by this gizmo
  102843. * @param mesh The mesh to replace the default mesh of the gizmo
  102844. */
  102845. setCustomMesh(mesh: Mesh): void;
  102846. }
  102847. }
  102848. declare module BABYLON {
  102849. /**
  102850. * Gizmo that enables dragging a mesh along 3 axis
  102851. */
  102852. export class PositionGizmo extends Gizmo {
  102853. /**
  102854. * Internal gizmo used for interactions on the x axis
  102855. */
  102856. xGizmo: AxisDragGizmo;
  102857. /**
  102858. * Internal gizmo used for interactions on the y axis
  102859. */
  102860. yGizmo: AxisDragGizmo;
  102861. /**
  102862. * Internal gizmo used for interactions on the z axis
  102863. */
  102864. zGizmo: AxisDragGizmo;
  102865. /** Fires an event when any of it's sub gizmos are dragged */
  102866. onDragStartObservable: Observable<{}>;
  102867. /** Fires an event when any of it's sub gizmos are released from dragging */
  102868. onDragEndObservable: Observable<{}>;
  102869. attachedMesh: Nullable<AbstractMesh>;
  102870. /**
  102871. * Creates a PositionGizmo
  102872. * @param gizmoLayer The utility layer the gizmo will be added to
  102873. */
  102874. constructor(gizmoLayer?: UtilityLayerRenderer);
  102875. updateGizmoRotationToMatchAttachedMesh: boolean;
  102876. /**
  102877. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102878. */
  102879. snapDistance: number;
  102880. /**
  102881. * Ratio for the scale of the gizmo (Default: 1)
  102882. */
  102883. scaleRatio: number;
  102884. /**
  102885. * Disposes of the gizmo
  102886. */
  102887. dispose(): void;
  102888. /**
  102889. * CustomMeshes are not supported by this gizmo
  102890. * @param mesh The mesh to replace the default mesh of the gizmo
  102891. */
  102892. setCustomMesh(mesh: Mesh): void;
  102893. }
  102894. }
  102895. declare module BABYLON {
  102896. /**
  102897. * Class containing static functions to help procedurally build meshes
  102898. */
  102899. export class PolyhedronBuilder {
  102900. /**
  102901. * Creates a polyhedron mesh
  102902. * * 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
  102903. * * The parameter `size` (positive float, default 1) sets the polygon size
  102904. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  102905. * * 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`
  102906. * * 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
  102907. * * 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)`)
  102908. * * 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
  102909. * * 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
  102910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102911. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102913. * @param name defines the name of the mesh
  102914. * @param options defines the options used to create the mesh
  102915. * @param scene defines the hosting scene
  102916. * @returns the polyhedron mesh
  102917. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  102918. */
  102919. static CreatePolyhedron(name: string, options: {
  102920. type?: number;
  102921. size?: number;
  102922. sizeX?: number;
  102923. sizeY?: number;
  102924. sizeZ?: number;
  102925. custom?: any;
  102926. faceUV?: Vector4[];
  102927. faceColors?: Color4[];
  102928. flat?: boolean;
  102929. updatable?: boolean;
  102930. sideOrientation?: number;
  102931. frontUVs?: Vector4;
  102932. backUVs?: Vector4;
  102933. }, scene?: Nullable<Scene>): Mesh;
  102934. }
  102935. }
  102936. declare module BABYLON {
  102937. /**
  102938. * Gizmo that enables scaling a mesh along 3 axis
  102939. */
  102940. export class ScaleGizmo extends Gizmo {
  102941. /**
  102942. * Internal gizmo used for interactions on the x axis
  102943. */
  102944. xGizmo: AxisScaleGizmo;
  102945. /**
  102946. * Internal gizmo used for interactions on the y axis
  102947. */
  102948. yGizmo: AxisScaleGizmo;
  102949. /**
  102950. * Internal gizmo used for interactions on the z axis
  102951. */
  102952. zGizmo: AxisScaleGizmo;
  102953. /**
  102954. * Internal gizmo used to scale all axis equally
  102955. */
  102956. uniformScaleGizmo: AxisScaleGizmo;
  102957. /** Fires an event when any of it's sub gizmos are dragged */
  102958. onDragStartObservable: Observable<{}>;
  102959. /** Fires an event when any of it's sub gizmos are released from dragging */
  102960. onDragEndObservable: Observable<{}>;
  102961. attachedMesh: Nullable<AbstractMesh>;
  102962. /**
  102963. * Creates a ScaleGizmo
  102964. * @param gizmoLayer The utility layer the gizmo will be added to
  102965. */
  102966. constructor(gizmoLayer?: UtilityLayerRenderer);
  102967. updateGizmoRotationToMatchAttachedMesh: boolean;
  102968. /**
  102969. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102970. */
  102971. snapDistance: number;
  102972. /**
  102973. * Ratio for the scale of the gizmo (Default: 1)
  102974. */
  102975. scaleRatio: number;
  102976. /**
  102977. * Disposes of the gizmo
  102978. */
  102979. dispose(): void;
  102980. }
  102981. }
  102982. declare module BABYLON {
  102983. /**
  102984. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  102985. */
  102986. export class GizmoManager implements IDisposable {
  102987. private scene;
  102988. /**
  102989. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  102990. */
  102991. gizmos: {
  102992. positionGizmo: Nullable<PositionGizmo>;
  102993. rotationGizmo: Nullable<RotationGizmo>;
  102994. scaleGizmo: Nullable<ScaleGizmo>;
  102995. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  102996. };
  102997. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  102998. clearGizmoOnEmptyPointerEvent: boolean;
  102999. /** Fires an event when the manager is attached to a mesh */
  103000. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  103001. private _gizmosEnabled;
  103002. private _pointerObserver;
  103003. private _attachedMesh;
  103004. private _boundingBoxColor;
  103005. private _defaultUtilityLayer;
  103006. private _defaultKeepDepthUtilityLayer;
  103007. /**
  103008. * When bounding box gizmo is enabled, this can be used to track drag/end events
  103009. */
  103010. boundingBoxDragBehavior: SixDofDragBehavior;
  103011. /**
  103012. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  103013. */
  103014. attachableMeshes: Nullable<Array<AbstractMesh>>;
  103015. /**
  103016. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  103017. */
  103018. usePointerToAttachGizmos: boolean;
  103019. /**
  103020. * Instatiates a gizmo manager
  103021. * @param scene the scene to overlay the gizmos on top of
  103022. */
  103023. constructor(scene: Scene);
  103024. /**
  103025. * Attaches a set of gizmos to the specified mesh
  103026. * @param mesh The mesh the gizmo's should be attached to
  103027. */
  103028. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  103029. /**
  103030. * If the position gizmo is enabled
  103031. */
  103032. positionGizmoEnabled: boolean;
  103033. /**
  103034. * If the rotation gizmo is enabled
  103035. */
  103036. rotationGizmoEnabled: boolean;
  103037. /**
  103038. * If the scale gizmo is enabled
  103039. */
  103040. scaleGizmoEnabled: boolean;
  103041. /**
  103042. * If the boundingBox gizmo is enabled
  103043. */
  103044. boundingBoxGizmoEnabled: boolean;
  103045. /**
  103046. * Disposes of the gizmo manager
  103047. */
  103048. dispose(): void;
  103049. }
  103050. }
  103051. declare module BABYLON {
  103052. /**
  103053. * A directional light is defined by a direction (what a surprise!).
  103054. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  103055. * 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.
  103056. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103057. */
  103058. export class DirectionalLight extends ShadowLight {
  103059. private _shadowFrustumSize;
  103060. /**
  103061. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  103062. */
  103063. /**
  103064. * Specifies a fix frustum size for the shadow generation.
  103065. */
  103066. shadowFrustumSize: number;
  103067. private _shadowOrthoScale;
  103068. /**
  103069. * Gets the shadow projection scale against the optimal computed one.
  103070. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  103071. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  103072. */
  103073. /**
  103074. * Sets the shadow projection scale against the optimal computed one.
  103075. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  103076. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  103077. */
  103078. shadowOrthoScale: number;
  103079. /**
  103080. * Automatically compute the projection matrix to best fit (including all the casters)
  103081. * on each frame.
  103082. */
  103083. autoUpdateExtends: boolean;
  103084. private _orthoLeft;
  103085. private _orthoRight;
  103086. private _orthoTop;
  103087. private _orthoBottom;
  103088. /**
  103089. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  103090. * The directional light is emitted from everywhere in the given direction.
  103091. * It can cast shadows.
  103092. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103093. * @param name The friendly name of the light
  103094. * @param direction The direction of the light
  103095. * @param scene The scene the light belongs to
  103096. */
  103097. constructor(name: string, direction: Vector3, scene: Scene);
  103098. /**
  103099. * Returns the string "DirectionalLight".
  103100. * @return The class name
  103101. */
  103102. getClassName(): string;
  103103. /**
  103104. * Returns the integer 1.
  103105. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103106. */
  103107. getTypeID(): number;
  103108. /**
  103109. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  103110. * Returns the DirectionalLight Shadow projection matrix.
  103111. */
  103112. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103113. /**
  103114. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  103115. * Returns the DirectionalLight Shadow projection matrix.
  103116. */
  103117. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  103118. /**
  103119. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  103120. * Returns the DirectionalLight Shadow projection matrix.
  103121. */
  103122. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103123. protected _buildUniformLayout(): void;
  103124. /**
  103125. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  103126. * @param effect The effect to update
  103127. * @param lightIndex The index of the light in the effect to update
  103128. * @returns The directional light
  103129. */
  103130. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  103131. /**
  103132. * Gets the minZ used for shadow according to both the scene and the light.
  103133. *
  103134. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  103135. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  103136. * @param activeCamera The camera we are returning the min for
  103137. * @returns the depth min z
  103138. */
  103139. getDepthMinZ(activeCamera: Camera): number;
  103140. /**
  103141. * Gets the maxZ used for shadow according to both the scene and the light.
  103142. *
  103143. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  103144. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  103145. * @param activeCamera The camera we are returning the max for
  103146. * @returns the depth max z
  103147. */
  103148. getDepthMaxZ(activeCamera: Camera): number;
  103149. /**
  103150. * Prepares the list of defines specific to the light type.
  103151. * @param defines the list of defines
  103152. * @param lightIndex defines the index of the light for the effect
  103153. */
  103154. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103155. }
  103156. }
  103157. declare module BABYLON {
  103158. /**
  103159. * Class containing static functions to help procedurally build meshes
  103160. */
  103161. export class HemisphereBuilder {
  103162. /**
  103163. * Creates a hemisphere mesh
  103164. * @param name defines the name of the mesh
  103165. * @param options defines the options used to create the mesh
  103166. * @param scene defines the hosting scene
  103167. * @returns the hemisphere mesh
  103168. */
  103169. static CreateHemisphere(name: string, options: {
  103170. segments?: number;
  103171. diameter?: number;
  103172. sideOrientation?: number;
  103173. }, scene: any): Mesh;
  103174. }
  103175. }
  103176. declare module BABYLON {
  103177. /**
  103178. * A spot light is defined by a position, a direction, an angle, and an exponent.
  103179. * These values define a cone of light starting from the position, emitting toward the direction.
  103180. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  103181. * and the exponent defines the speed of the decay of the light with distance (reach).
  103182. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103183. */
  103184. export class SpotLight extends ShadowLight {
  103185. private _angle;
  103186. private _innerAngle;
  103187. private _cosHalfAngle;
  103188. private _lightAngleScale;
  103189. private _lightAngleOffset;
  103190. /**
  103191. * Gets the cone angle of the spot light in Radians.
  103192. */
  103193. /**
  103194. * Sets the cone angle of the spot light in Radians.
  103195. */
  103196. angle: number;
  103197. /**
  103198. * Only used in gltf falloff mode, this defines the angle where
  103199. * the directional falloff will start before cutting at angle which could be seen
  103200. * as outer angle.
  103201. */
  103202. /**
  103203. * Only used in gltf falloff mode, this defines the angle where
  103204. * the directional falloff will start before cutting at angle which could be seen
  103205. * as outer angle.
  103206. */
  103207. innerAngle: number;
  103208. private _shadowAngleScale;
  103209. /**
  103210. * Allows scaling the angle of the light for shadow generation only.
  103211. */
  103212. /**
  103213. * Allows scaling the angle of the light for shadow generation only.
  103214. */
  103215. shadowAngleScale: number;
  103216. /**
  103217. * The light decay speed with the distance from the emission spot.
  103218. */
  103219. exponent: number;
  103220. private _projectionTextureMatrix;
  103221. /**
  103222. * Allows reading the projecton texture
  103223. */
  103224. readonly projectionTextureMatrix: Matrix;
  103225. protected _projectionTextureLightNear: number;
  103226. /**
  103227. * Gets the near clip of the Spotlight for texture projection.
  103228. */
  103229. /**
  103230. * Sets the near clip of the Spotlight for texture projection.
  103231. */
  103232. projectionTextureLightNear: number;
  103233. protected _projectionTextureLightFar: number;
  103234. /**
  103235. * Gets the far clip of the Spotlight for texture projection.
  103236. */
  103237. /**
  103238. * Sets the far clip of the Spotlight for texture projection.
  103239. */
  103240. projectionTextureLightFar: number;
  103241. protected _projectionTextureUpDirection: Vector3;
  103242. /**
  103243. * Gets the Up vector of the Spotlight for texture projection.
  103244. */
  103245. /**
  103246. * Sets the Up vector of the Spotlight for texture projection.
  103247. */
  103248. projectionTextureUpDirection: Vector3;
  103249. private _projectionTexture;
  103250. /**
  103251. * Gets the projection texture of the light.
  103252. */
  103253. /**
  103254. * Sets the projection texture of the light.
  103255. */
  103256. projectionTexture: Nullable<BaseTexture>;
  103257. private _projectionTextureViewLightDirty;
  103258. private _projectionTextureProjectionLightDirty;
  103259. private _projectionTextureDirty;
  103260. private _projectionTextureViewTargetVector;
  103261. private _projectionTextureViewLightMatrix;
  103262. private _projectionTextureProjectionLightMatrix;
  103263. private _projectionTextureScalingMatrix;
  103264. /**
  103265. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  103266. * It can cast shadows.
  103267. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103268. * @param name The light friendly name
  103269. * @param position The position of the spot light in the scene
  103270. * @param direction The direction of the light in the scene
  103271. * @param angle The cone angle of the light in Radians
  103272. * @param exponent The light decay speed with the distance from the emission spot
  103273. * @param scene The scene the lights belongs to
  103274. */
  103275. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  103276. /**
  103277. * Returns the string "SpotLight".
  103278. * @returns the class name
  103279. */
  103280. getClassName(): string;
  103281. /**
  103282. * Returns the integer 2.
  103283. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103284. */
  103285. getTypeID(): number;
  103286. /**
  103287. * Overrides the direction setter to recompute the projection texture view light Matrix.
  103288. */
  103289. protected _setDirection(value: Vector3): void;
  103290. /**
  103291. * Overrides the position setter to recompute the projection texture view light Matrix.
  103292. */
  103293. protected _setPosition(value: Vector3): void;
  103294. /**
  103295. * 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.
  103296. * Returns the SpotLight.
  103297. */
  103298. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103299. protected _computeProjectionTextureViewLightMatrix(): void;
  103300. protected _computeProjectionTextureProjectionLightMatrix(): void;
  103301. /**
  103302. * Main function for light texture projection matrix computing.
  103303. */
  103304. protected _computeProjectionTextureMatrix(): void;
  103305. protected _buildUniformLayout(): void;
  103306. private _computeAngleValues;
  103307. /**
  103308. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  103309. * @param effect The effect to update
  103310. * @param lightIndex The index of the light in the effect to update
  103311. * @returns The spot light
  103312. */
  103313. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  103314. /**
  103315. * Disposes the light and the associated resources.
  103316. */
  103317. dispose(): void;
  103318. /**
  103319. * Prepares the list of defines specific to the light type.
  103320. * @param defines the list of defines
  103321. * @param lightIndex defines the index of the light for the effect
  103322. */
  103323. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103324. }
  103325. }
  103326. declare module BABYLON {
  103327. /**
  103328. * Gizmo that enables viewing a light
  103329. */
  103330. export class LightGizmo extends Gizmo {
  103331. private _lightMesh;
  103332. private _material;
  103333. private cachedPosition;
  103334. private cachedForward;
  103335. /**
  103336. * Creates a LightGizmo
  103337. * @param gizmoLayer The utility layer the gizmo will be added to
  103338. */
  103339. constructor(gizmoLayer?: UtilityLayerRenderer);
  103340. private _light;
  103341. /**
  103342. * The light that the gizmo is attached to
  103343. */
  103344. light: Nullable<Light>;
  103345. /**
  103346. * @hidden
  103347. * Updates the gizmo to match the attached mesh's position/rotation
  103348. */
  103349. protected _update(): void;
  103350. private static _Scale;
  103351. /**
  103352. * Creates the lines for a light mesh
  103353. */
  103354. private static _createLightLines;
  103355. /**
  103356. * Disposes of the light gizmo
  103357. */
  103358. dispose(): void;
  103359. private static _CreateHemisphericLightMesh;
  103360. private static _CreatePointLightMesh;
  103361. private static _CreateSpotLightMesh;
  103362. private static _CreateDirectionalLightMesh;
  103363. }
  103364. }
  103365. declare module BABYLON {
  103366. /** @hidden */
  103367. export var backgroundFragmentDeclaration: {
  103368. name: string;
  103369. shader: string;
  103370. };
  103371. }
  103372. declare module BABYLON {
  103373. /** @hidden */
  103374. export var backgroundUboDeclaration: {
  103375. name: string;
  103376. shader: string;
  103377. };
  103378. }
  103379. declare module BABYLON {
  103380. /** @hidden */
  103381. export var backgroundPixelShader: {
  103382. name: string;
  103383. shader: string;
  103384. };
  103385. }
  103386. declare module BABYLON {
  103387. /** @hidden */
  103388. export var backgroundVertexDeclaration: {
  103389. name: string;
  103390. shader: string;
  103391. };
  103392. }
  103393. declare module BABYLON {
  103394. /** @hidden */
  103395. export var backgroundVertexShader: {
  103396. name: string;
  103397. shader: string;
  103398. };
  103399. }
  103400. declare module BABYLON {
  103401. /**
  103402. * Background material used to create an efficient environement around your scene.
  103403. */
  103404. export class BackgroundMaterial extends PushMaterial {
  103405. /**
  103406. * Standard reflectance value at parallel view angle.
  103407. */
  103408. static StandardReflectance0: number;
  103409. /**
  103410. * Standard reflectance value at grazing angle.
  103411. */
  103412. static StandardReflectance90: number;
  103413. protected _primaryColor: Color3;
  103414. /**
  103415. * Key light Color (multiply against the environement texture)
  103416. */
  103417. primaryColor: Color3;
  103418. protected __perceptualColor: Nullable<Color3>;
  103419. /**
  103420. * Experimental Internal Use Only.
  103421. *
  103422. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  103423. * This acts as a helper to set the primary color to a more "human friendly" value.
  103424. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  103425. * output color as close as possible from the chosen value.
  103426. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  103427. * part of lighting setup.)
  103428. */
  103429. _perceptualColor: Nullable<Color3>;
  103430. protected _primaryColorShadowLevel: float;
  103431. /**
  103432. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  103433. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  103434. */
  103435. primaryColorShadowLevel: float;
  103436. protected _primaryColorHighlightLevel: float;
  103437. /**
  103438. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  103439. * The primary color is used at the level chosen to define what the white area would look.
  103440. */
  103441. primaryColorHighlightLevel: float;
  103442. protected _reflectionTexture: Nullable<BaseTexture>;
  103443. /**
  103444. * Reflection Texture used in the material.
  103445. * Should be author in a specific way for the best result (refer to the documentation).
  103446. */
  103447. reflectionTexture: Nullable<BaseTexture>;
  103448. protected _reflectionBlur: float;
  103449. /**
  103450. * Reflection Texture level of blur.
  103451. *
  103452. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  103453. * texture twice.
  103454. */
  103455. reflectionBlur: float;
  103456. protected _diffuseTexture: Nullable<BaseTexture>;
  103457. /**
  103458. * Diffuse Texture used in the material.
  103459. * Should be author in a specific way for the best result (refer to the documentation).
  103460. */
  103461. diffuseTexture: Nullable<BaseTexture>;
  103462. protected _shadowLights: Nullable<IShadowLight[]>;
  103463. /**
  103464. * Specify the list of lights casting shadow on the material.
  103465. * All scene shadow lights will be included if null.
  103466. */
  103467. shadowLights: Nullable<IShadowLight[]>;
  103468. protected _shadowLevel: float;
  103469. /**
  103470. * Helps adjusting the shadow to a softer level if required.
  103471. * 0 means black shadows and 1 means no shadows.
  103472. */
  103473. shadowLevel: float;
  103474. protected _sceneCenter: Vector3;
  103475. /**
  103476. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  103477. * It is usually zero but might be interesting to modify according to your setup.
  103478. */
  103479. sceneCenter: Vector3;
  103480. protected _opacityFresnel: boolean;
  103481. /**
  103482. * This helps specifying that the material is falling off to the sky box at grazing angle.
  103483. * This helps ensuring a nice transition when the camera goes under the ground.
  103484. */
  103485. opacityFresnel: boolean;
  103486. protected _reflectionFresnel: boolean;
  103487. /**
  103488. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  103489. * This helps adding a mirror texture on the ground.
  103490. */
  103491. reflectionFresnel: boolean;
  103492. protected _reflectionFalloffDistance: number;
  103493. /**
  103494. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  103495. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  103496. */
  103497. reflectionFalloffDistance: number;
  103498. protected _reflectionAmount: number;
  103499. /**
  103500. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  103501. */
  103502. reflectionAmount: number;
  103503. protected _reflectionReflectance0: number;
  103504. /**
  103505. * This specifies the weight of the reflection at grazing angle.
  103506. */
  103507. reflectionReflectance0: number;
  103508. protected _reflectionReflectance90: number;
  103509. /**
  103510. * This specifies the weight of the reflection at a perpendicular point of view.
  103511. */
  103512. reflectionReflectance90: number;
  103513. /**
  103514. * Sets the reflection reflectance fresnel values according to the default standard
  103515. * empirically know to work well :-)
  103516. */
  103517. reflectionStandardFresnelWeight: number;
  103518. protected _useRGBColor: boolean;
  103519. /**
  103520. * Helps to directly use the maps channels instead of their level.
  103521. */
  103522. useRGBColor: boolean;
  103523. protected _enableNoise: boolean;
  103524. /**
  103525. * This helps reducing the banding effect that could occur on the background.
  103526. */
  103527. enableNoise: boolean;
  103528. /**
  103529. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103530. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  103531. * Recommended to be keep at 1.0 except for special cases.
  103532. */
  103533. fovMultiplier: number;
  103534. private _fovMultiplier;
  103535. /**
  103536. * Enable the FOV adjustment feature controlled by fovMultiplier.
  103537. */
  103538. useEquirectangularFOV: boolean;
  103539. private _maxSimultaneousLights;
  103540. /**
  103541. * Number of Simultaneous lights allowed on the material.
  103542. */
  103543. maxSimultaneousLights: int;
  103544. /**
  103545. * Default configuration related to image processing available in the Background Material.
  103546. */
  103547. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103548. /**
  103549. * Keep track of the image processing observer to allow dispose and replace.
  103550. */
  103551. private _imageProcessingObserver;
  103552. /**
  103553. * Attaches a new image processing configuration to the PBR Material.
  103554. * @param configuration (if null the scene configuration will be use)
  103555. */
  103556. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103557. /**
  103558. * Gets the image processing configuration used either in this material.
  103559. */
  103560. /**
  103561. * Sets the Default image processing configuration used either in the this material.
  103562. *
  103563. * If sets to null, the scene one is in use.
  103564. */
  103565. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  103566. /**
  103567. * Gets wether the color curves effect is enabled.
  103568. */
  103569. /**
  103570. * Sets wether the color curves effect is enabled.
  103571. */
  103572. cameraColorCurvesEnabled: boolean;
  103573. /**
  103574. * Gets wether the color grading effect is enabled.
  103575. */
  103576. /**
  103577. * Gets wether the color grading effect is enabled.
  103578. */
  103579. cameraColorGradingEnabled: boolean;
  103580. /**
  103581. * Gets wether tonemapping is enabled or not.
  103582. */
  103583. /**
  103584. * Sets wether tonemapping is enabled or not
  103585. */
  103586. cameraToneMappingEnabled: boolean;
  103587. /**
  103588. * The camera exposure used on this material.
  103589. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103590. * This corresponds to a photographic exposure.
  103591. */
  103592. /**
  103593. * The camera exposure used on this material.
  103594. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103595. * This corresponds to a photographic exposure.
  103596. */
  103597. cameraExposure: float;
  103598. /**
  103599. * Gets The camera contrast used on this material.
  103600. */
  103601. /**
  103602. * Sets The camera contrast used on this material.
  103603. */
  103604. cameraContrast: float;
  103605. /**
  103606. * Gets the Color Grading 2D Lookup Texture.
  103607. */
  103608. /**
  103609. * Sets the Color Grading 2D Lookup Texture.
  103610. */
  103611. cameraColorGradingTexture: Nullable<BaseTexture>;
  103612. /**
  103613. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103614. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103615. * 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;
  103616. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103617. */
  103618. /**
  103619. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103620. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103621. * 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;
  103622. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103623. */
  103624. cameraColorCurves: Nullable<ColorCurves>;
  103625. /**
  103626. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  103627. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  103628. */
  103629. switchToBGR: boolean;
  103630. private _renderTargets;
  103631. private _reflectionControls;
  103632. private _white;
  103633. private _primaryShadowColor;
  103634. private _primaryHighlightColor;
  103635. /**
  103636. * Instantiates a Background Material in the given scene
  103637. * @param name The friendly name of the material
  103638. * @param scene The scene to add the material to
  103639. */
  103640. constructor(name: string, scene: Scene);
  103641. /**
  103642. * Gets a boolean indicating that current material needs to register RTT
  103643. */
  103644. readonly hasRenderTargetTextures: boolean;
  103645. /**
  103646. * The entire material has been created in order to prevent overdraw.
  103647. * @returns false
  103648. */
  103649. needAlphaTesting(): boolean;
  103650. /**
  103651. * The entire material has been created in order to prevent overdraw.
  103652. * @returns true if blending is enable
  103653. */
  103654. needAlphaBlending(): boolean;
  103655. /**
  103656. * Checks wether the material is ready to be rendered for a given mesh.
  103657. * @param mesh The mesh to render
  103658. * @param subMesh The submesh to check against
  103659. * @param useInstances Specify wether or not the material is used with instances
  103660. * @returns true if all the dependencies are ready (Textures, Effects...)
  103661. */
  103662. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103663. /**
  103664. * Compute the primary color according to the chosen perceptual color.
  103665. */
  103666. private _computePrimaryColorFromPerceptualColor;
  103667. /**
  103668. * Compute the highlights and shadow colors according to their chosen levels.
  103669. */
  103670. private _computePrimaryColors;
  103671. /**
  103672. * Build the uniform buffer used in the material.
  103673. */
  103674. buildUniformLayout(): void;
  103675. /**
  103676. * Unbind the material.
  103677. */
  103678. unbind(): void;
  103679. /**
  103680. * Bind only the world matrix to the material.
  103681. * @param world The world matrix to bind.
  103682. */
  103683. bindOnlyWorldMatrix(world: Matrix): void;
  103684. /**
  103685. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  103686. * @param world The world matrix to bind.
  103687. * @param subMesh The submesh to bind for.
  103688. */
  103689. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103690. /**
  103691. * Dispose the material.
  103692. * @param forceDisposeEffect Force disposal of the associated effect.
  103693. * @param forceDisposeTextures Force disposal of the associated textures.
  103694. */
  103695. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103696. /**
  103697. * Clones the material.
  103698. * @param name The cloned name.
  103699. * @returns The cloned material.
  103700. */
  103701. clone(name: string): BackgroundMaterial;
  103702. /**
  103703. * Serializes the current material to its JSON representation.
  103704. * @returns The JSON representation.
  103705. */
  103706. serialize(): any;
  103707. /**
  103708. * Gets the class name of the material
  103709. * @returns "BackgroundMaterial"
  103710. */
  103711. getClassName(): string;
  103712. /**
  103713. * Parse a JSON input to create back a background material.
  103714. * @param source The JSON data to parse
  103715. * @param scene The scene to create the parsed material in
  103716. * @param rootUrl The root url of the assets the material depends upon
  103717. * @returns the instantiated BackgroundMaterial.
  103718. */
  103719. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  103720. }
  103721. }
  103722. declare module BABYLON {
  103723. /**
  103724. * Represents the different options available during the creation of
  103725. * a Environment helper.
  103726. *
  103727. * This can control the default ground, skybox and image processing setup of your scene.
  103728. */
  103729. export interface IEnvironmentHelperOptions {
  103730. /**
  103731. * Specifies wether or not to create a ground.
  103732. * True by default.
  103733. */
  103734. createGround: boolean;
  103735. /**
  103736. * Specifies the ground size.
  103737. * 15 by default.
  103738. */
  103739. groundSize: number;
  103740. /**
  103741. * The texture used on the ground for the main color.
  103742. * Comes from the BabylonJS CDN by default.
  103743. *
  103744. * Remarks: Can be either a texture or a url.
  103745. */
  103746. groundTexture: string | BaseTexture;
  103747. /**
  103748. * The color mixed in the ground texture by default.
  103749. * BabylonJS clearColor by default.
  103750. */
  103751. groundColor: Color3;
  103752. /**
  103753. * Specifies the ground opacity.
  103754. * 1 by default.
  103755. */
  103756. groundOpacity: number;
  103757. /**
  103758. * Enables the ground to receive shadows.
  103759. * True by default.
  103760. */
  103761. enableGroundShadow: boolean;
  103762. /**
  103763. * Helps preventing the shadow to be fully black on the ground.
  103764. * 0.5 by default.
  103765. */
  103766. groundShadowLevel: number;
  103767. /**
  103768. * Creates a mirror texture attach to the ground.
  103769. * false by default.
  103770. */
  103771. enableGroundMirror: boolean;
  103772. /**
  103773. * Specifies the ground mirror size ratio.
  103774. * 0.3 by default as the default kernel is 64.
  103775. */
  103776. groundMirrorSizeRatio: number;
  103777. /**
  103778. * Specifies the ground mirror blur kernel size.
  103779. * 64 by default.
  103780. */
  103781. groundMirrorBlurKernel: number;
  103782. /**
  103783. * Specifies the ground mirror visibility amount.
  103784. * 1 by default
  103785. */
  103786. groundMirrorAmount: number;
  103787. /**
  103788. * Specifies the ground mirror reflectance weight.
  103789. * This uses the standard weight of the background material to setup the fresnel effect
  103790. * of the mirror.
  103791. * 1 by default.
  103792. */
  103793. groundMirrorFresnelWeight: number;
  103794. /**
  103795. * Specifies the ground mirror Falloff distance.
  103796. * This can helps reducing the size of the reflection.
  103797. * 0 by Default.
  103798. */
  103799. groundMirrorFallOffDistance: number;
  103800. /**
  103801. * Specifies the ground mirror texture type.
  103802. * Unsigned Int by Default.
  103803. */
  103804. groundMirrorTextureType: number;
  103805. /**
  103806. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  103807. * the shown objects.
  103808. */
  103809. groundYBias: number;
  103810. /**
  103811. * Specifies wether or not to create a skybox.
  103812. * True by default.
  103813. */
  103814. createSkybox: boolean;
  103815. /**
  103816. * Specifies the skybox size.
  103817. * 20 by default.
  103818. */
  103819. skyboxSize: number;
  103820. /**
  103821. * The texture used on the skybox for the main color.
  103822. * Comes from the BabylonJS CDN by default.
  103823. *
  103824. * Remarks: Can be either a texture or a url.
  103825. */
  103826. skyboxTexture: string | BaseTexture;
  103827. /**
  103828. * The color mixed in the skybox texture by default.
  103829. * BabylonJS clearColor by default.
  103830. */
  103831. skyboxColor: Color3;
  103832. /**
  103833. * The background rotation around the Y axis of the scene.
  103834. * This helps aligning the key lights of your scene with the background.
  103835. * 0 by default.
  103836. */
  103837. backgroundYRotation: number;
  103838. /**
  103839. * Compute automatically the size of the elements to best fit with the scene.
  103840. */
  103841. sizeAuto: boolean;
  103842. /**
  103843. * Default position of the rootMesh if autoSize is not true.
  103844. */
  103845. rootPosition: Vector3;
  103846. /**
  103847. * Sets up the image processing in the scene.
  103848. * true by default.
  103849. */
  103850. setupImageProcessing: boolean;
  103851. /**
  103852. * The texture used as your environment texture in the scene.
  103853. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  103854. *
  103855. * Remarks: Can be either a texture or a url.
  103856. */
  103857. environmentTexture: string | BaseTexture;
  103858. /**
  103859. * The value of the exposure to apply to the scene.
  103860. * 0.6 by default if setupImageProcessing is true.
  103861. */
  103862. cameraExposure: number;
  103863. /**
  103864. * The value of the contrast to apply to the scene.
  103865. * 1.6 by default if setupImageProcessing is true.
  103866. */
  103867. cameraContrast: number;
  103868. /**
  103869. * Specifies wether or not tonemapping should be enabled in the scene.
  103870. * true by default if setupImageProcessing is true.
  103871. */
  103872. toneMappingEnabled: boolean;
  103873. }
  103874. /**
  103875. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  103876. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  103877. * It also helps with the default setup of your imageProcessing configuration.
  103878. */
  103879. export class EnvironmentHelper {
  103880. /**
  103881. * Default ground texture URL.
  103882. */
  103883. private static _groundTextureCDNUrl;
  103884. /**
  103885. * Default skybox texture URL.
  103886. */
  103887. private static _skyboxTextureCDNUrl;
  103888. /**
  103889. * Default environment texture URL.
  103890. */
  103891. private static _environmentTextureCDNUrl;
  103892. /**
  103893. * Creates the default options for the helper.
  103894. */
  103895. private static _getDefaultOptions;
  103896. private _rootMesh;
  103897. /**
  103898. * Gets the root mesh created by the helper.
  103899. */
  103900. readonly rootMesh: Mesh;
  103901. private _skybox;
  103902. /**
  103903. * Gets the skybox created by the helper.
  103904. */
  103905. readonly skybox: Nullable<Mesh>;
  103906. private _skyboxTexture;
  103907. /**
  103908. * Gets the skybox texture created by the helper.
  103909. */
  103910. readonly skyboxTexture: Nullable<BaseTexture>;
  103911. private _skyboxMaterial;
  103912. /**
  103913. * Gets the skybox material created by the helper.
  103914. */
  103915. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  103916. private _ground;
  103917. /**
  103918. * Gets the ground mesh created by the helper.
  103919. */
  103920. readonly ground: Nullable<Mesh>;
  103921. private _groundTexture;
  103922. /**
  103923. * Gets the ground texture created by the helper.
  103924. */
  103925. readonly groundTexture: Nullable<BaseTexture>;
  103926. private _groundMirror;
  103927. /**
  103928. * Gets the ground mirror created by the helper.
  103929. */
  103930. readonly groundMirror: Nullable<MirrorTexture>;
  103931. /**
  103932. * Gets the ground mirror render list to helps pushing the meshes
  103933. * you wish in the ground reflection.
  103934. */
  103935. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  103936. private _groundMaterial;
  103937. /**
  103938. * Gets the ground material created by the helper.
  103939. */
  103940. readonly groundMaterial: Nullable<BackgroundMaterial>;
  103941. /**
  103942. * Stores the creation options.
  103943. */
  103944. private readonly _scene;
  103945. private _options;
  103946. /**
  103947. * This observable will be notified with any error during the creation of the environment,
  103948. * mainly texture creation errors.
  103949. */
  103950. onErrorObservable: Observable<{
  103951. message?: string;
  103952. exception?: any;
  103953. }>;
  103954. /**
  103955. * constructor
  103956. * @param options Defines the options we want to customize the helper
  103957. * @param scene The scene to add the material to
  103958. */
  103959. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  103960. /**
  103961. * Updates the background according to the new options
  103962. * @param options
  103963. */
  103964. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  103965. /**
  103966. * Sets the primary color of all the available elements.
  103967. * @param color the main color to affect to the ground and the background
  103968. */
  103969. setMainColor(color: Color3): void;
  103970. /**
  103971. * Setup the image processing according to the specified options.
  103972. */
  103973. private _setupImageProcessing;
  103974. /**
  103975. * Setup the environment texture according to the specified options.
  103976. */
  103977. private _setupEnvironmentTexture;
  103978. /**
  103979. * Setup the background according to the specified options.
  103980. */
  103981. private _setupBackground;
  103982. /**
  103983. * Get the scene sizes according to the setup.
  103984. */
  103985. private _getSceneSize;
  103986. /**
  103987. * Setup the ground according to the specified options.
  103988. */
  103989. private _setupGround;
  103990. /**
  103991. * Setup the ground material according to the specified options.
  103992. */
  103993. private _setupGroundMaterial;
  103994. /**
  103995. * Setup the ground diffuse texture according to the specified options.
  103996. */
  103997. private _setupGroundDiffuseTexture;
  103998. /**
  103999. * Setup the ground mirror texture according to the specified options.
  104000. */
  104001. private _setupGroundMirrorTexture;
  104002. /**
  104003. * Setup the ground to receive the mirror texture.
  104004. */
  104005. private _setupMirrorInGroundMaterial;
  104006. /**
  104007. * Setup the skybox according to the specified options.
  104008. */
  104009. private _setupSkybox;
  104010. /**
  104011. * Setup the skybox material according to the specified options.
  104012. */
  104013. private _setupSkyboxMaterial;
  104014. /**
  104015. * Setup the skybox reflection texture according to the specified options.
  104016. */
  104017. private _setupSkyboxReflectionTexture;
  104018. private _errorHandler;
  104019. /**
  104020. * Dispose all the elements created by the Helper.
  104021. */
  104022. dispose(): void;
  104023. }
  104024. }
  104025. declare module BABYLON {
  104026. /**
  104027. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  104028. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  104029. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  104030. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  104031. */
  104032. export class PhotoDome extends TransformNode {
  104033. private _useDirectMapping;
  104034. /**
  104035. * The texture being displayed on the sphere
  104036. */
  104037. protected _photoTexture: Texture;
  104038. /**
  104039. * Gets or sets the texture being displayed on the sphere
  104040. */
  104041. photoTexture: Texture;
  104042. /**
  104043. * Observable raised when an error occured while loading the 360 image
  104044. */
  104045. onLoadErrorObservable: Observable<string>;
  104046. /**
  104047. * The skybox material
  104048. */
  104049. protected _material: BackgroundMaterial;
  104050. /**
  104051. * The surface used for the skybox
  104052. */
  104053. protected _mesh: Mesh;
  104054. /**
  104055. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  104056. * Also see the options.resolution property.
  104057. */
  104058. fovMultiplier: number;
  104059. /**
  104060. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  104061. * @param name Element's name, child elements will append suffixes for their own names.
  104062. * @param urlsOfPhoto defines the url of the photo to display
  104063. * @param options defines an object containing optional or exposed sub element properties
  104064. * @param onError defines a callback called when an error occured while loading the texture
  104065. */
  104066. constructor(name: string, urlOfPhoto: string, options: {
  104067. resolution?: number;
  104068. size?: number;
  104069. useDirectMapping?: boolean;
  104070. faceForward?: boolean;
  104071. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  104072. /**
  104073. * Releases resources associated with this node.
  104074. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  104075. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  104076. */
  104077. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  104078. }
  104079. }
  104080. declare module BABYLON {
  104081. /** @hidden */
  104082. export var rgbdDecodePixelShader: {
  104083. name: string;
  104084. shader: string;
  104085. };
  104086. }
  104087. declare module BABYLON {
  104088. /**
  104089. * Class used to host texture specific utilities
  104090. */
  104091. export class BRDFTextureTools {
  104092. /**
  104093. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  104094. * @param texture the texture to expand.
  104095. */
  104096. private static _ExpandDefaultBRDFTexture;
  104097. /**
  104098. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  104099. * @param scene defines the hosting scene
  104100. * @returns the environment BRDF texture
  104101. */
  104102. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  104103. private static _environmentBRDFBase64Texture;
  104104. }
  104105. }
  104106. declare module BABYLON {
  104107. /**
  104108. * @hidden
  104109. */
  104110. export interface IMaterialClearCoatDefines {
  104111. CLEARCOAT: boolean;
  104112. CLEARCOAT_DEFAULTIOR: boolean;
  104113. CLEARCOAT_TEXTURE: boolean;
  104114. CLEARCOAT_TEXTUREDIRECTUV: number;
  104115. CLEARCOAT_BUMP: boolean;
  104116. CLEARCOAT_BUMPDIRECTUV: number;
  104117. CLEARCOAT_TINT: boolean;
  104118. CLEARCOAT_TINT_TEXTURE: boolean;
  104119. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104120. /** @hidden */
  104121. _areTexturesDirty: boolean;
  104122. }
  104123. /**
  104124. * Define the code related to the clear coat parameters of the pbr material.
  104125. */
  104126. export class PBRClearCoatConfiguration {
  104127. /**
  104128. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  104129. * The default fits with a polyurethane material.
  104130. */
  104131. private static readonly _DefaultIndiceOfRefraction;
  104132. private _isEnabled;
  104133. /**
  104134. * Defines if the clear coat is enabled in the material.
  104135. */
  104136. isEnabled: boolean;
  104137. /**
  104138. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  104139. */
  104140. intensity: number;
  104141. /**
  104142. * Defines the clear coat layer roughness.
  104143. */
  104144. roughness: number;
  104145. private _indiceOfRefraction;
  104146. /**
  104147. * Defines the indice of refraction of the clear coat.
  104148. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  104149. * The default fits with a polyurethane material.
  104150. * Changing the default value is more performance intensive.
  104151. */
  104152. indiceOfRefraction: number;
  104153. private _texture;
  104154. /**
  104155. * Stores the clear coat values in a texture.
  104156. */
  104157. texture: Nullable<BaseTexture>;
  104158. private _bumpTexture;
  104159. /**
  104160. * Define the clear coat specific bump texture.
  104161. */
  104162. bumpTexture: Nullable<BaseTexture>;
  104163. private _isTintEnabled;
  104164. /**
  104165. * Defines if the clear coat tint is enabled in the material.
  104166. */
  104167. isTintEnabled: boolean;
  104168. /**
  104169. * Defines the clear coat tint of the material.
  104170. * This is only use if tint is enabled
  104171. */
  104172. tintColor: Color3;
  104173. /**
  104174. * Defines the distance at which the tint color should be found in the
  104175. * clear coat media.
  104176. * This is only use if tint is enabled
  104177. */
  104178. tintColorAtDistance: number;
  104179. /**
  104180. * Defines the clear coat layer thickness.
  104181. * This is only use if tint is enabled
  104182. */
  104183. tintThickness: number;
  104184. private _tintTexture;
  104185. /**
  104186. * Stores the clear tint values in a texture.
  104187. * rgb is tint
  104188. * a is a thickness factor
  104189. */
  104190. tintTexture: Nullable<BaseTexture>;
  104191. /** @hidden */
  104192. private _internalMarkAllSubMeshesAsTexturesDirty;
  104193. /** @hidden */
  104194. _markAllSubMeshesAsTexturesDirty(): void;
  104195. /**
  104196. * Instantiate a new istance of clear coat configuration.
  104197. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104198. */
  104199. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104200. /**
  104201. * Gets wehter the submesh is ready to be used or not.
  104202. * @param defines the list of "defines" to update.
  104203. * @param scene defines the scene the material belongs to.
  104204. * @param engine defines the engine the material belongs to.
  104205. * @param disableBumpMap defines wether the material disables bump or not.
  104206. * @returns - boolean indicating that the submesh is ready or not.
  104207. */
  104208. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  104209. /**
  104210. * Checks to see if a texture is used in the material.
  104211. * @param defines the list of "defines" to update.
  104212. * @param scene defines the scene to the material belongs to.
  104213. */
  104214. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  104215. /**
  104216. * Binds the material data.
  104217. * @param uniformBuffer defines the Uniform buffer to fill in.
  104218. * @param scene defines the scene the material belongs to.
  104219. * @param engine defines the engine the material belongs to.
  104220. * @param disableBumpMap defines wether the material disables bump or not.
  104221. * @param isFrozen defines wether the material is frozen or not.
  104222. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104223. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104224. */
  104225. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  104226. /**
  104227. * Checks to see if a texture is used in the material.
  104228. * @param texture - Base texture to use.
  104229. * @returns - Boolean specifying if a texture is used in the material.
  104230. */
  104231. hasTexture(texture: BaseTexture): boolean;
  104232. /**
  104233. * Returns an array of the actively used textures.
  104234. * @param activeTextures Array of BaseTextures
  104235. */
  104236. getActiveTextures(activeTextures: BaseTexture[]): void;
  104237. /**
  104238. * Returns the animatable textures.
  104239. * @param animatables Array of animatable textures.
  104240. */
  104241. getAnimatables(animatables: IAnimatable[]): void;
  104242. /**
  104243. * Disposes the resources of the material.
  104244. * @param forceDisposeTextures - Forces the disposal of all textures.
  104245. */
  104246. dispose(forceDisposeTextures?: boolean): void;
  104247. /**
  104248. * Get the current class name of the texture useful for serialization or dynamic coding.
  104249. * @returns "PBRClearCoatConfiguration"
  104250. */
  104251. getClassName(): string;
  104252. /**
  104253. * Add fallbacks to the effect fallbacks list.
  104254. * @param defines defines the Base texture to use.
  104255. * @param fallbacks defines the current fallback list.
  104256. * @param currentRank defines the current fallback rank.
  104257. * @returns the new fallback rank.
  104258. */
  104259. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104260. /**
  104261. * Add the required uniforms to the current list.
  104262. * @param uniforms defines the current uniform list.
  104263. */
  104264. static AddUniforms(uniforms: string[]): void;
  104265. /**
  104266. * Add the required samplers to the current list.
  104267. * @param samplers defines the current sampler list.
  104268. */
  104269. static AddSamplers(samplers: string[]): void;
  104270. /**
  104271. * Add the required uniforms to the current buffer.
  104272. * @param uniformBuffer defines the current uniform buffer.
  104273. */
  104274. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104275. /**
  104276. * Makes a duplicate of the current configuration into another one.
  104277. * @param clearCoatConfiguration define the config where to copy the info
  104278. */
  104279. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  104280. /**
  104281. * Serializes this clear coat configuration.
  104282. * @returns - An object with the serialized config.
  104283. */
  104284. serialize(): any;
  104285. /**
  104286. * Parses a Clear Coat Configuration from a serialized object.
  104287. * @param source - Serialized object.
  104288. */
  104289. parse(source: any): void;
  104290. }
  104291. }
  104292. declare module BABYLON {
  104293. /**
  104294. * @hidden
  104295. */
  104296. export interface IMaterialAnisotropicDefines {
  104297. ANISOTROPIC: boolean;
  104298. ANISOTROPIC_TEXTURE: boolean;
  104299. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104300. MAINUV1: boolean;
  104301. _areTexturesDirty: boolean;
  104302. _needUVs: boolean;
  104303. }
  104304. /**
  104305. * Define the code related to the anisotropic parameters of the pbr material.
  104306. */
  104307. export class PBRAnisotropicConfiguration {
  104308. private _isEnabled;
  104309. /**
  104310. * Defines if the anisotropy is enabled in the material.
  104311. */
  104312. isEnabled: boolean;
  104313. /**
  104314. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  104315. */
  104316. intensity: number;
  104317. /**
  104318. * Defines if the effect is along the tangents, bitangents or in between.
  104319. * By default, the effect is "strectching" the highlights along the tangents.
  104320. */
  104321. direction: Vector2;
  104322. private _texture;
  104323. /**
  104324. * Stores the anisotropy values in a texture.
  104325. * rg is direction (like normal from -1 to 1)
  104326. * b is a intensity
  104327. */
  104328. texture: Nullable<BaseTexture>;
  104329. /** @hidden */
  104330. private _internalMarkAllSubMeshesAsTexturesDirty;
  104331. /** @hidden */
  104332. _markAllSubMeshesAsTexturesDirty(): void;
  104333. /**
  104334. * Instantiate a new istance of anisotropy configuration.
  104335. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104336. */
  104337. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104338. /**
  104339. * Specifies that the submesh is ready to be used.
  104340. * @param defines the list of "defines" to update.
  104341. * @param scene defines the scene the material belongs to.
  104342. * @returns - boolean indicating that the submesh is ready or not.
  104343. */
  104344. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  104345. /**
  104346. * Checks to see if a texture is used in the material.
  104347. * @param defines the list of "defines" to update.
  104348. * @param mesh the mesh we are preparing the defines for.
  104349. * @param scene defines the scene the material belongs to.
  104350. */
  104351. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  104352. /**
  104353. * Binds the material data.
  104354. * @param uniformBuffer defines the Uniform buffer to fill in.
  104355. * @param scene defines the scene the material belongs to.
  104356. * @param isFrozen defines wether the material is frozen or not.
  104357. */
  104358. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104359. /**
  104360. * Checks to see if a texture is used in the material.
  104361. * @param texture - Base texture to use.
  104362. * @returns - Boolean specifying if a texture is used in the material.
  104363. */
  104364. hasTexture(texture: BaseTexture): boolean;
  104365. /**
  104366. * Returns an array of the actively used textures.
  104367. * @param activeTextures Array of BaseTextures
  104368. */
  104369. getActiveTextures(activeTextures: BaseTexture[]): void;
  104370. /**
  104371. * Returns the animatable textures.
  104372. * @param animatables Array of animatable textures.
  104373. */
  104374. getAnimatables(animatables: IAnimatable[]): void;
  104375. /**
  104376. * Disposes the resources of the material.
  104377. * @param forceDisposeTextures - Forces the disposal of all textures.
  104378. */
  104379. dispose(forceDisposeTextures?: boolean): void;
  104380. /**
  104381. * Get the current class name of the texture useful for serialization or dynamic coding.
  104382. * @returns "PBRAnisotropicConfiguration"
  104383. */
  104384. getClassName(): string;
  104385. /**
  104386. * Add fallbacks to the effect fallbacks list.
  104387. * @param defines defines the Base texture to use.
  104388. * @param fallbacks defines the current fallback list.
  104389. * @param currentRank defines the current fallback rank.
  104390. * @returns the new fallback rank.
  104391. */
  104392. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104393. /**
  104394. * Add the required uniforms to the current list.
  104395. * @param uniforms defines the current uniform list.
  104396. */
  104397. static AddUniforms(uniforms: string[]): void;
  104398. /**
  104399. * Add the required uniforms to the current buffer.
  104400. * @param uniformBuffer defines the current uniform buffer.
  104401. */
  104402. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104403. /**
  104404. * Add the required samplers to the current list.
  104405. * @param samplers defines the current sampler list.
  104406. */
  104407. static AddSamplers(samplers: string[]): void;
  104408. /**
  104409. * Makes a duplicate of the current configuration into another one.
  104410. * @param anisotropicConfiguration define the config where to copy the info
  104411. */
  104412. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  104413. /**
  104414. * Serializes this anisotropy configuration.
  104415. * @returns - An object with the serialized config.
  104416. */
  104417. serialize(): any;
  104418. /**
  104419. * Parses a anisotropy Configuration from a serialized object.
  104420. * @param source - Serialized object.
  104421. */
  104422. parse(source: any): void;
  104423. }
  104424. }
  104425. declare module BABYLON {
  104426. /**
  104427. * @hidden
  104428. */
  104429. export interface IMaterialBRDFDefines {
  104430. BRDF_V_HEIGHT_CORRELATED: boolean;
  104431. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104432. SPHERICAL_HARMONICS: boolean;
  104433. /** @hidden */
  104434. _areMiscDirty: boolean;
  104435. }
  104436. /**
  104437. * Define the code related to the BRDF parameters of the pbr material.
  104438. */
  104439. export class PBRBRDFConfiguration {
  104440. /**
  104441. * Default value used for the energy conservation.
  104442. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104443. */
  104444. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  104445. /**
  104446. * Default value used for the Smith Visibility Height Correlated mode.
  104447. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104448. */
  104449. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  104450. /**
  104451. * Default value used for the IBL diffuse part.
  104452. * This can help switching back to the polynomials mode globally which is a tiny bit
  104453. * less GPU intensive at the drawback of a lower quality.
  104454. */
  104455. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  104456. private _useEnergyConservation;
  104457. /**
  104458. * Defines if the material uses energy conservation.
  104459. */
  104460. useEnergyConservation: boolean;
  104461. private _useSmithVisibilityHeightCorrelated;
  104462. /**
  104463. * LEGACY Mode set to false
  104464. * Defines if the material uses height smith correlated visibility term.
  104465. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  104466. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104467. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  104468. * Not relying on height correlated will also disable energy conservation.
  104469. */
  104470. useSmithVisibilityHeightCorrelated: boolean;
  104471. private _useSphericalHarmonics;
  104472. /**
  104473. * LEGACY Mode set to false
  104474. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  104475. * diffuse part of the IBL.
  104476. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  104477. * to the ground truth.
  104478. */
  104479. useSphericalHarmonics: boolean;
  104480. /** @hidden */
  104481. private _internalMarkAllSubMeshesAsMiscDirty;
  104482. /** @hidden */
  104483. _markAllSubMeshesAsMiscDirty(): void;
  104484. /**
  104485. * Instantiate a new istance of clear coat configuration.
  104486. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  104487. */
  104488. constructor(markAllSubMeshesAsMiscDirty: () => void);
  104489. /**
  104490. * Checks to see if a texture is used in the material.
  104491. * @param defines the list of "defines" to update.
  104492. */
  104493. prepareDefines(defines: IMaterialBRDFDefines): void;
  104494. /**
  104495. * Get the current class name of the texture useful for serialization or dynamic coding.
  104496. * @returns "PBRClearCoatConfiguration"
  104497. */
  104498. getClassName(): string;
  104499. /**
  104500. * Makes a duplicate of the current configuration into another one.
  104501. * @param brdfConfiguration define the config where to copy the info
  104502. */
  104503. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  104504. /**
  104505. * Serializes this BRDF configuration.
  104506. * @returns - An object with the serialized config.
  104507. */
  104508. serialize(): any;
  104509. /**
  104510. * Parses a BRDF Configuration from a serialized object.
  104511. * @param source - Serialized object.
  104512. */
  104513. parse(source: any): void;
  104514. }
  104515. }
  104516. declare module BABYLON {
  104517. /**
  104518. * @hidden
  104519. */
  104520. export interface IMaterialSheenDefines {
  104521. SHEEN: boolean;
  104522. SHEEN_TEXTURE: boolean;
  104523. SHEEN_TEXTUREDIRECTUV: number;
  104524. SHEEN_LINKWITHALBEDO: boolean;
  104525. /** @hidden */
  104526. _areTexturesDirty: boolean;
  104527. }
  104528. /**
  104529. * Define the code related to the Sheen parameters of the pbr material.
  104530. */
  104531. export class PBRSheenConfiguration {
  104532. private _isEnabled;
  104533. /**
  104534. * Defines if the material uses sheen.
  104535. */
  104536. isEnabled: boolean;
  104537. private _linkSheenWithAlbedo;
  104538. /**
  104539. * Defines if the sheen is linked to the sheen color.
  104540. */
  104541. linkSheenWithAlbedo: boolean;
  104542. /**
  104543. * Defines the sheen intensity.
  104544. */
  104545. intensity: number;
  104546. /**
  104547. * Defines the sheen color.
  104548. */
  104549. color: Color3;
  104550. private _texture;
  104551. /**
  104552. * Stores the sheen tint values in a texture.
  104553. * rgb is tint
  104554. * a is a intensity
  104555. */
  104556. texture: Nullable<BaseTexture>;
  104557. /** @hidden */
  104558. private _internalMarkAllSubMeshesAsTexturesDirty;
  104559. /** @hidden */
  104560. _markAllSubMeshesAsTexturesDirty(): void;
  104561. /**
  104562. * Instantiate a new istance of clear coat configuration.
  104563. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104564. */
  104565. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104566. /**
  104567. * Specifies that the submesh is ready to be used.
  104568. * @param defines the list of "defines" to update.
  104569. * @param scene defines the scene the material belongs to.
  104570. * @returns - boolean indicating that the submesh is ready or not.
  104571. */
  104572. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  104573. /**
  104574. * Checks to see if a texture is used in the material.
  104575. * @param defines the list of "defines" to update.
  104576. * @param scene defines the scene the material belongs to.
  104577. */
  104578. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  104579. /**
  104580. * Binds the material data.
  104581. * @param uniformBuffer defines the Uniform buffer to fill in.
  104582. * @param scene defines the scene the material belongs to.
  104583. * @param isFrozen defines wether the material is frozen or not.
  104584. */
  104585. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104586. /**
  104587. * Checks to see if a texture is used in the material.
  104588. * @param texture - Base texture to use.
  104589. * @returns - Boolean specifying if a texture is used in the material.
  104590. */
  104591. hasTexture(texture: BaseTexture): boolean;
  104592. /**
  104593. * Returns an array of the actively used textures.
  104594. * @param activeTextures Array of BaseTextures
  104595. */
  104596. getActiveTextures(activeTextures: BaseTexture[]): void;
  104597. /**
  104598. * Returns the animatable textures.
  104599. * @param animatables Array of animatable textures.
  104600. */
  104601. getAnimatables(animatables: IAnimatable[]): void;
  104602. /**
  104603. * Disposes the resources of the material.
  104604. * @param forceDisposeTextures - Forces the disposal of all textures.
  104605. */
  104606. dispose(forceDisposeTextures?: boolean): void;
  104607. /**
  104608. * Get the current class name of the texture useful for serialization or dynamic coding.
  104609. * @returns "PBRSheenConfiguration"
  104610. */
  104611. getClassName(): string;
  104612. /**
  104613. * Add fallbacks to the effect fallbacks list.
  104614. * @param defines defines the Base texture to use.
  104615. * @param fallbacks defines the current fallback list.
  104616. * @param currentRank defines the current fallback rank.
  104617. * @returns the new fallback rank.
  104618. */
  104619. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104620. /**
  104621. * Add the required uniforms to the current list.
  104622. * @param uniforms defines the current uniform list.
  104623. */
  104624. static AddUniforms(uniforms: string[]): void;
  104625. /**
  104626. * Add the required uniforms to the current buffer.
  104627. * @param uniformBuffer defines the current uniform buffer.
  104628. */
  104629. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104630. /**
  104631. * Add the required samplers to the current list.
  104632. * @param samplers defines the current sampler list.
  104633. */
  104634. static AddSamplers(samplers: string[]): void;
  104635. /**
  104636. * Makes a duplicate of the current configuration into another one.
  104637. * @param sheenConfiguration define the config where to copy the info
  104638. */
  104639. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  104640. /**
  104641. * Serializes this BRDF configuration.
  104642. * @returns - An object with the serialized config.
  104643. */
  104644. serialize(): any;
  104645. /**
  104646. * Parses a Sheen Configuration from a serialized object.
  104647. * @param source - Serialized object.
  104648. */
  104649. parse(source: any): void;
  104650. }
  104651. }
  104652. declare module BABYLON {
  104653. /**
  104654. * @hidden
  104655. */
  104656. export interface IMaterialSubSurfaceDefines {
  104657. SUBSURFACE: boolean;
  104658. SS_REFRACTION: boolean;
  104659. SS_TRANSLUCENCY: boolean;
  104660. SS_SCATERRING: boolean;
  104661. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104662. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104663. SS_REFRACTIONMAP_3D: boolean;
  104664. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104665. SS_LODINREFRACTIONALPHA: boolean;
  104666. SS_GAMMAREFRACTION: boolean;
  104667. SS_RGBDREFRACTION: boolean;
  104668. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104669. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104670. /** @hidden */
  104671. _areTexturesDirty: boolean;
  104672. }
  104673. /**
  104674. * Define the code related to the sub surface parameters of the pbr material.
  104675. */
  104676. export class PBRSubSurfaceConfiguration {
  104677. private _isRefractionEnabled;
  104678. /**
  104679. * Defines if the refraction is enabled in the material.
  104680. */
  104681. isRefractionEnabled: boolean;
  104682. private _isTranslucencyEnabled;
  104683. /**
  104684. * Defines if the translucency is enabled in the material.
  104685. */
  104686. isTranslucencyEnabled: boolean;
  104687. private _isScatteringEnabled;
  104688. /**
  104689. * Defines the refraction intensity of the material.
  104690. * The refraction when enabled replaces the Diffuse part of the material.
  104691. * The intensity helps transitionning between diffuse and refraction.
  104692. */
  104693. refractionIntensity: number;
  104694. /**
  104695. * Defines the translucency intensity of the material.
  104696. * When translucency has been enabled, this defines how much of the "translucency"
  104697. * is addded to the diffuse part of the material.
  104698. */
  104699. translucencyIntensity: number;
  104700. /**
  104701. * Defines the scattering intensity of the material.
  104702. * When scattering has been enabled, this defines how much of the "scattered light"
  104703. * is addded to the diffuse part of the material.
  104704. */
  104705. scatteringIntensity: number;
  104706. private _thicknessTexture;
  104707. /**
  104708. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  104709. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  104710. * 0 would mean minimumThickness
  104711. * 1 would mean maximumThickness
  104712. * The other channels might be use as a mask to vary the different effects intensity.
  104713. */
  104714. thicknessTexture: Nullable<BaseTexture>;
  104715. private _refractionTexture;
  104716. /**
  104717. * Defines the texture to use for refraction.
  104718. */
  104719. refractionTexture: Nullable<BaseTexture>;
  104720. private _indexOfRefraction;
  104721. /**
  104722. * Defines the indice of refraction used in the material.
  104723. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  104724. */
  104725. indexOfRefraction: number;
  104726. private _invertRefractionY;
  104727. /**
  104728. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104729. */
  104730. invertRefractionY: boolean;
  104731. private _linkRefractionWithTransparency;
  104732. /**
  104733. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104734. * Materials half opaque for instance using refraction could benefit from this control.
  104735. */
  104736. linkRefractionWithTransparency: boolean;
  104737. /**
  104738. * Defines the minimum thickness stored in the thickness map.
  104739. * If no thickness map is defined, this value will be used to simulate thickness.
  104740. */
  104741. minimumThickness: number;
  104742. /**
  104743. * Defines the maximum thickness stored in the thickness map.
  104744. */
  104745. maximumThickness: number;
  104746. /**
  104747. * Defines the volume tint of the material.
  104748. * This is used for both translucency and scattering.
  104749. */
  104750. tintColor: Color3;
  104751. /**
  104752. * Defines the distance at which the tint color should be found in the media.
  104753. * This is used for refraction only.
  104754. */
  104755. tintColorAtDistance: number;
  104756. /**
  104757. * Defines how far each channel transmit through the media.
  104758. * It is defined as a color to simplify it selection.
  104759. */
  104760. diffusionDistance: Color3;
  104761. private _useMaskFromThicknessTexture;
  104762. /**
  104763. * Stores the intensity of the different subsurface effects in the thickness texture.
  104764. * * the green channel is the translucency intensity.
  104765. * * the blue channel is the scattering intensity.
  104766. * * the alpha channel is the refraction intensity.
  104767. */
  104768. useMaskFromThicknessTexture: boolean;
  104769. /** @hidden */
  104770. private _internalMarkAllSubMeshesAsTexturesDirty;
  104771. /** @hidden */
  104772. _markAllSubMeshesAsTexturesDirty(): void;
  104773. /**
  104774. * Instantiate a new istance of sub surface configuration.
  104775. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104776. */
  104777. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104778. /**
  104779. * Gets wehter the submesh is ready to be used or not.
  104780. * @param defines the list of "defines" to update.
  104781. * @param scene defines the scene the material belongs to.
  104782. * @returns - boolean indicating that the submesh is ready or not.
  104783. */
  104784. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  104785. /**
  104786. * Checks to see if a texture is used in the material.
  104787. * @param defines the list of "defines" to update.
  104788. * @param scene defines the scene to the material belongs to.
  104789. */
  104790. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  104791. /**
  104792. * Binds the material data.
  104793. * @param uniformBuffer defines the Uniform buffer to fill in.
  104794. * @param scene defines the scene the material belongs to.
  104795. * @param engine defines the engine the material belongs to.
  104796. * @param isFrozen defines wether the material is frozen or not.
  104797. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  104798. */
  104799. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  104800. /**
  104801. * Unbinds the material from the mesh.
  104802. * @param activeEffect defines the effect that should be unbound from.
  104803. * @returns true if unbound, otherwise false
  104804. */
  104805. unbind(activeEffect: Effect): boolean;
  104806. /**
  104807. * Returns the texture used for refraction or null if none is used.
  104808. * @param scene defines the scene the material belongs to.
  104809. * @returns - Refraction texture if present. If no refraction texture and refraction
  104810. * is linked with transparency, returns environment texture. Otherwise, returns null.
  104811. */
  104812. private _getRefractionTexture;
  104813. /**
  104814. * Returns true if alpha blending should be disabled.
  104815. */
  104816. readonly disableAlphaBlending: boolean;
  104817. /**
  104818. * Fills the list of render target textures.
  104819. * @param renderTargets the list of render targets to update
  104820. */
  104821. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  104822. /**
  104823. * Checks to see if a texture is used in the material.
  104824. * @param texture - Base texture to use.
  104825. * @returns - Boolean specifying if a texture is used in the material.
  104826. */
  104827. hasTexture(texture: BaseTexture): boolean;
  104828. /**
  104829. * Gets a boolean indicating that current material needs to register RTT
  104830. * @returns true if this uses a render target otherwise false.
  104831. */
  104832. hasRenderTargetTextures(): boolean;
  104833. /**
  104834. * Returns an array of the actively used textures.
  104835. * @param activeTextures Array of BaseTextures
  104836. */
  104837. getActiveTextures(activeTextures: BaseTexture[]): void;
  104838. /**
  104839. * Returns the animatable textures.
  104840. * @param animatables Array of animatable textures.
  104841. */
  104842. getAnimatables(animatables: IAnimatable[]): void;
  104843. /**
  104844. * Disposes the resources of the material.
  104845. * @param forceDisposeTextures - Forces the disposal of all textures.
  104846. */
  104847. dispose(forceDisposeTextures?: boolean): void;
  104848. /**
  104849. * Get the current class name of the texture useful for serialization or dynamic coding.
  104850. * @returns "PBRSubSurfaceConfiguration"
  104851. */
  104852. getClassName(): string;
  104853. /**
  104854. * Add fallbacks to the effect fallbacks list.
  104855. * @param defines defines the Base texture to use.
  104856. * @param fallbacks defines the current fallback list.
  104857. * @param currentRank defines the current fallback rank.
  104858. * @returns the new fallback rank.
  104859. */
  104860. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104861. /**
  104862. * Add the required uniforms to the current list.
  104863. * @param uniforms defines the current uniform list.
  104864. */
  104865. static AddUniforms(uniforms: string[]): void;
  104866. /**
  104867. * Add the required samplers to the current list.
  104868. * @param samplers defines the current sampler list.
  104869. */
  104870. static AddSamplers(samplers: string[]): void;
  104871. /**
  104872. * Add the required uniforms to the current buffer.
  104873. * @param uniformBuffer defines the current uniform buffer.
  104874. */
  104875. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104876. /**
  104877. * Makes a duplicate of the current configuration into another one.
  104878. * @param configuration define the config where to copy the info
  104879. */
  104880. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  104881. /**
  104882. * Serializes this Sub Surface configuration.
  104883. * @returns - An object with the serialized config.
  104884. */
  104885. serialize(): any;
  104886. /**
  104887. * Parses a Sub Surface Configuration from a serialized object.
  104888. * @param source - Serialized object.
  104889. */
  104890. parse(source: any): void;
  104891. }
  104892. }
  104893. declare module BABYLON {
  104894. /** @hidden */
  104895. export var pbrFragmentDeclaration: {
  104896. name: string;
  104897. shader: string;
  104898. };
  104899. }
  104900. declare module BABYLON {
  104901. /** @hidden */
  104902. export var pbrUboDeclaration: {
  104903. name: string;
  104904. shader: string;
  104905. };
  104906. }
  104907. declare module BABYLON {
  104908. /** @hidden */
  104909. export var pbrFragmentExtraDeclaration: {
  104910. name: string;
  104911. shader: string;
  104912. };
  104913. }
  104914. declare module BABYLON {
  104915. /** @hidden */
  104916. export var pbrFragmentSamplersDeclaration: {
  104917. name: string;
  104918. shader: string;
  104919. };
  104920. }
  104921. declare module BABYLON {
  104922. /** @hidden */
  104923. export var pbrHelperFunctions: {
  104924. name: string;
  104925. shader: string;
  104926. };
  104927. }
  104928. declare module BABYLON {
  104929. /** @hidden */
  104930. export var harmonicsFunctions: {
  104931. name: string;
  104932. shader: string;
  104933. };
  104934. }
  104935. declare module BABYLON {
  104936. /** @hidden */
  104937. export var pbrDirectLightingSetupFunctions: {
  104938. name: string;
  104939. shader: string;
  104940. };
  104941. }
  104942. declare module BABYLON {
  104943. /** @hidden */
  104944. export var pbrDirectLightingFalloffFunctions: {
  104945. name: string;
  104946. shader: string;
  104947. };
  104948. }
  104949. declare module BABYLON {
  104950. /** @hidden */
  104951. export var pbrBRDFFunctions: {
  104952. name: string;
  104953. shader: string;
  104954. };
  104955. }
  104956. declare module BABYLON {
  104957. /** @hidden */
  104958. export var pbrDirectLightingFunctions: {
  104959. name: string;
  104960. shader: string;
  104961. };
  104962. }
  104963. declare module BABYLON {
  104964. /** @hidden */
  104965. export var pbrIBLFunctions: {
  104966. name: string;
  104967. shader: string;
  104968. };
  104969. }
  104970. declare module BABYLON {
  104971. /** @hidden */
  104972. export var pbrDebug: {
  104973. name: string;
  104974. shader: string;
  104975. };
  104976. }
  104977. declare module BABYLON {
  104978. /** @hidden */
  104979. export var pbrPixelShader: {
  104980. name: string;
  104981. shader: string;
  104982. };
  104983. }
  104984. declare module BABYLON {
  104985. /** @hidden */
  104986. export var pbrVertexDeclaration: {
  104987. name: string;
  104988. shader: string;
  104989. };
  104990. }
  104991. declare module BABYLON {
  104992. /** @hidden */
  104993. export var pbrVertexShader: {
  104994. name: string;
  104995. shader: string;
  104996. };
  104997. }
  104998. declare module BABYLON {
  104999. /**
  105000. * Manages the defines for the PBR Material.
  105001. * @hidden
  105002. */
  105003. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  105004. PBR: boolean;
  105005. MAINUV1: boolean;
  105006. MAINUV2: boolean;
  105007. UV1: boolean;
  105008. UV2: boolean;
  105009. ALBEDO: boolean;
  105010. ALBEDODIRECTUV: number;
  105011. VERTEXCOLOR: boolean;
  105012. AMBIENT: boolean;
  105013. AMBIENTDIRECTUV: number;
  105014. AMBIENTINGRAYSCALE: boolean;
  105015. OPACITY: boolean;
  105016. VERTEXALPHA: boolean;
  105017. OPACITYDIRECTUV: number;
  105018. OPACITYRGB: boolean;
  105019. ALPHATEST: boolean;
  105020. DEPTHPREPASS: boolean;
  105021. ALPHABLEND: boolean;
  105022. ALPHAFROMALBEDO: boolean;
  105023. ALPHATESTVALUE: string;
  105024. SPECULAROVERALPHA: boolean;
  105025. RADIANCEOVERALPHA: boolean;
  105026. ALPHAFRESNEL: boolean;
  105027. LINEARALPHAFRESNEL: boolean;
  105028. PREMULTIPLYALPHA: boolean;
  105029. EMISSIVE: boolean;
  105030. EMISSIVEDIRECTUV: number;
  105031. REFLECTIVITY: boolean;
  105032. REFLECTIVITYDIRECTUV: number;
  105033. SPECULARTERM: boolean;
  105034. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  105035. MICROSURFACEAUTOMATIC: boolean;
  105036. LODBASEDMICROSFURACE: boolean;
  105037. MICROSURFACEMAP: boolean;
  105038. MICROSURFACEMAPDIRECTUV: number;
  105039. METALLICWORKFLOW: boolean;
  105040. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  105041. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  105042. METALLNESSSTOREINMETALMAPBLUE: boolean;
  105043. AOSTOREINMETALMAPRED: boolean;
  105044. ENVIRONMENTBRDF: boolean;
  105045. ENVIRONMENTBRDF_RGBD: boolean;
  105046. NORMAL: boolean;
  105047. TANGENT: boolean;
  105048. BUMP: boolean;
  105049. BUMPDIRECTUV: number;
  105050. OBJECTSPACE_NORMALMAP: boolean;
  105051. PARALLAX: boolean;
  105052. PARALLAXOCCLUSION: boolean;
  105053. NORMALXYSCALE: boolean;
  105054. LIGHTMAP: boolean;
  105055. LIGHTMAPDIRECTUV: number;
  105056. USELIGHTMAPASSHADOWMAP: boolean;
  105057. GAMMALIGHTMAP: boolean;
  105058. REFLECTION: boolean;
  105059. REFLECTIONMAP_3D: boolean;
  105060. REFLECTIONMAP_SPHERICAL: boolean;
  105061. REFLECTIONMAP_PLANAR: boolean;
  105062. REFLECTIONMAP_CUBIC: boolean;
  105063. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105064. REFLECTIONMAP_PROJECTION: boolean;
  105065. REFLECTIONMAP_SKYBOX: boolean;
  105066. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  105067. REFLECTIONMAP_EXPLICIT: boolean;
  105068. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105069. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105070. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105071. INVERTCUBICMAP: boolean;
  105072. USESPHERICALFROMREFLECTIONMAP: boolean;
  105073. SPHERICAL_HARMONICS: boolean;
  105074. USESPHERICALINVERTEX: boolean;
  105075. REFLECTIONMAP_OPPOSITEZ: boolean;
  105076. LODINREFLECTIONALPHA: boolean;
  105077. GAMMAREFLECTION: boolean;
  105078. RGBDREFLECTION: boolean;
  105079. RADIANCEOCCLUSION: boolean;
  105080. HORIZONOCCLUSION: boolean;
  105081. INSTANCES: boolean;
  105082. NUM_BONE_INFLUENCERS: number;
  105083. BonesPerMesh: number;
  105084. BONETEXTURE: boolean;
  105085. NONUNIFORMSCALING: boolean;
  105086. MORPHTARGETS: boolean;
  105087. MORPHTARGETS_NORMAL: boolean;
  105088. MORPHTARGETS_TANGENT: boolean;
  105089. NUM_MORPH_INFLUENCERS: number;
  105090. IMAGEPROCESSING: boolean;
  105091. VIGNETTE: boolean;
  105092. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105093. VIGNETTEBLENDMODEOPAQUE: boolean;
  105094. TONEMAPPING: boolean;
  105095. TONEMAPPING_ACES: boolean;
  105096. CONTRAST: boolean;
  105097. COLORCURVES: boolean;
  105098. COLORGRADING: boolean;
  105099. COLORGRADING3D: boolean;
  105100. SAMPLER3DGREENDEPTH: boolean;
  105101. SAMPLER3DBGRMAP: boolean;
  105102. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105103. EXPOSURE: boolean;
  105104. MULTIVIEW: boolean;
  105105. USEPHYSICALLIGHTFALLOFF: boolean;
  105106. USEGLTFLIGHTFALLOFF: boolean;
  105107. TWOSIDEDLIGHTING: boolean;
  105108. SHADOWFLOAT: boolean;
  105109. CLIPPLANE: boolean;
  105110. CLIPPLANE2: boolean;
  105111. CLIPPLANE3: boolean;
  105112. CLIPPLANE4: boolean;
  105113. POINTSIZE: boolean;
  105114. FOG: boolean;
  105115. LOGARITHMICDEPTH: boolean;
  105116. FORCENORMALFORWARD: boolean;
  105117. SPECULARAA: boolean;
  105118. CLEARCOAT: boolean;
  105119. CLEARCOAT_DEFAULTIOR: boolean;
  105120. CLEARCOAT_TEXTURE: boolean;
  105121. CLEARCOAT_TEXTUREDIRECTUV: number;
  105122. CLEARCOAT_BUMP: boolean;
  105123. CLEARCOAT_BUMPDIRECTUV: number;
  105124. CLEARCOAT_TINT: boolean;
  105125. CLEARCOAT_TINT_TEXTURE: boolean;
  105126. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  105127. ANISOTROPIC: boolean;
  105128. ANISOTROPIC_TEXTURE: boolean;
  105129. ANISOTROPIC_TEXTUREDIRECTUV: number;
  105130. BRDF_V_HEIGHT_CORRELATED: boolean;
  105131. MS_BRDF_ENERGY_CONSERVATION: boolean;
  105132. SHEEN: boolean;
  105133. SHEEN_TEXTURE: boolean;
  105134. SHEEN_TEXTUREDIRECTUV: number;
  105135. SHEEN_LINKWITHALBEDO: boolean;
  105136. SUBSURFACE: boolean;
  105137. SS_REFRACTION: boolean;
  105138. SS_TRANSLUCENCY: boolean;
  105139. SS_SCATERRING: boolean;
  105140. SS_THICKNESSANDMASK_TEXTURE: boolean;
  105141. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  105142. SS_REFRACTIONMAP_3D: boolean;
  105143. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  105144. SS_LODINREFRACTIONALPHA: boolean;
  105145. SS_GAMMAREFRACTION: boolean;
  105146. SS_RGBDREFRACTION: boolean;
  105147. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  105148. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  105149. UNLIT: boolean;
  105150. DEBUGMODE: number;
  105151. /**
  105152. * Initializes the PBR Material defines.
  105153. */
  105154. constructor();
  105155. /**
  105156. * Resets the PBR Material defines.
  105157. */
  105158. reset(): void;
  105159. }
  105160. /**
  105161. * The Physically based material base class of BJS.
  105162. *
  105163. * This offers the main features of a standard PBR material.
  105164. * For more information, please refer to the documentation :
  105165. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  105166. */
  105167. export abstract class PBRBaseMaterial extends PushMaterial {
  105168. /**
  105169. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105170. */
  105171. static readonly PBRMATERIAL_OPAQUE: number;
  105172. /**
  105173. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105174. */
  105175. static readonly PBRMATERIAL_ALPHATEST: number;
  105176. /**
  105177. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105178. */
  105179. static readonly PBRMATERIAL_ALPHABLEND: number;
  105180. /**
  105181. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105182. * They are also discarded below the alpha cutoff threshold to improve performances.
  105183. */
  105184. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105185. /**
  105186. * Defines the default value of how much AO map is occluding the analytical lights
  105187. * (point spot...).
  105188. */
  105189. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105190. /**
  105191. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  105192. */
  105193. static readonly LIGHTFALLOFF_PHYSICAL: number;
  105194. /**
  105195. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  105196. * to enhance interoperability with other engines.
  105197. */
  105198. static readonly LIGHTFALLOFF_GLTF: number;
  105199. /**
  105200. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  105201. * to enhance interoperability with other materials.
  105202. */
  105203. static readonly LIGHTFALLOFF_STANDARD: number;
  105204. /**
  105205. * Intensity of the direct lights e.g. the four lights available in your scene.
  105206. * This impacts both the direct diffuse and specular highlights.
  105207. */
  105208. protected _directIntensity: number;
  105209. /**
  105210. * Intensity of the emissive part of the material.
  105211. * This helps controlling the emissive effect without modifying the emissive color.
  105212. */
  105213. protected _emissiveIntensity: number;
  105214. /**
  105215. * Intensity of the environment e.g. how much the environment will light the object
  105216. * either through harmonics for rough material or through the refelction for shiny ones.
  105217. */
  105218. protected _environmentIntensity: number;
  105219. /**
  105220. * This is a special control allowing the reduction of the specular highlights coming from the
  105221. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105222. */
  105223. protected _specularIntensity: number;
  105224. /**
  105225. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  105226. */
  105227. private _lightingInfos;
  105228. /**
  105229. * Debug Control allowing disabling the bump map on this material.
  105230. */
  105231. protected _disableBumpMap: boolean;
  105232. /**
  105233. * AKA Diffuse Texture in standard nomenclature.
  105234. */
  105235. protected _albedoTexture: Nullable<BaseTexture>;
  105236. /**
  105237. * AKA Occlusion Texture in other nomenclature.
  105238. */
  105239. protected _ambientTexture: Nullable<BaseTexture>;
  105240. /**
  105241. * AKA Occlusion Texture Intensity in other nomenclature.
  105242. */
  105243. protected _ambientTextureStrength: number;
  105244. /**
  105245. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105246. * 1 means it completely occludes it
  105247. * 0 mean it has no impact
  105248. */
  105249. protected _ambientTextureImpactOnAnalyticalLights: number;
  105250. /**
  105251. * Stores the alpha values in a texture.
  105252. */
  105253. protected _opacityTexture: Nullable<BaseTexture>;
  105254. /**
  105255. * Stores the reflection values in a texture.
  105256. */
  105257. protected _reflectionTexture: Nullable<BaseTexture>;
  105258. /**
  105259. * Stores the emissive values in a texture.
  105260. */
  105261. protected _emissiveTexture: Nullable<BaseTexture>;
  105262. /**
  105263. * AKA Specular texture in other nomenclature.
  105264. */
  105265. protected _reflectivityTexture: Nullable<BaseTexture>;
  105266. /**
  105267. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105268. */
  105269. protected _metallicTexture: Nullable<BaseTexture>;
  105270. /**
  105271. * Specifies the metallic scalar of the metallic/roughness workflow.
  105272. * Can also be used to scale the metalness values of the metallic texture.
  105273. */
  105274. protected _metallic: Nullable<number>;
  105275. /**
  105276. * Specifies the roughness scalar of the metallic/roughness workflow.
  105277. * Can also be used to scale the roughness values of the metallic texture.
  105278. */
  105279. protected _roughness: Nullable<number>;
  105280. /**
  105281. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105282. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105283. */
  105284. protected _microSurfaceTexture: Nullable<BaseTexture>;
  105285. /**
  105286. * Stores surface normal data used to displace a mesh in a texture.
  105287. */
  105288. protected _bumpTexture: Nullable<BaseTexture>;
  105289. /**
  105290. * Stores the pre-calculated light information of a mesh in a texture.
  105291. */
  105292. protected _lightmapTexture: Nullable<BaseTexture>;
  105293. /**
  105294. * The color of a material in ambient lighting.
  105295. */
  105296. protected _ambientColor: Color3;
  105297. /**
  105298. * AKA Diffuse Color in other nomenclature.
  105299. */
  105300. protected _albedoColor: Color3;
  105301. /**
  105302. * AKA Specular Color in other nomenclature.
  105303. */
  105304. protected _reflectivityColor: Color3;
  105305. /**
  105306. * The color applied when light is reflected from a material.
  105307. */
  105308. protected _reflectionColor: Color3;
  105309. /**
  105310. * The color applied when light is emitted from a material.
  105311. */
  105312. protected _emissiveColor: Color3;
  105313. /**
  105314. * AKA Glossiness in other nomenclature.
  105315. */
  105316. protected _microSurface: number;
  105317. /**
  105318. * Specifies that the material will use the light map as a show map.
  105319. */
  105320. protected _useLightmapAsShadowmap: boolean;
  105321. /**
  105322. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105323. * makes the reflect vector face the model (under horizon).
  105324. */
  105325. protected _useHorizonOcclusion: boolean;
  105326. /**
  105327. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105328. * too much the area relying on ambient texture to define their ambient occlusion.
  105329. */
  105330. protected _useRadianceOcclusion: boolean;
  105331. /**
  105332. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105333. */
  105334. protected _useAlphaFromAlbedoTexture: boolean;
  105335. /**
  105336. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  105337. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105338. */
  105339. protected _useSpecularOverAlpha: boolean;
  105340. /**
  105341. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105342. */
  105343. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105344. /**
  105345. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105346. */
  105347. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  105348. /**
  105349. * Specifies if the metallic texture contains the roughness information in its green channel.
  105350. */
  105351. protected _useRoughnessFromMetallicTextureGreen: boolean;
  105352. /**
  105353. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105354. */
  105355. protected _useMetallnessFromMetallicTextureBlue: boolean;
  105356. /**
  105357. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105358. */
  105359. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  105360. /**
  105361. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105362. */
  105363. protected _useAmbientInGrayScale: boolean;
  105364. /**
  105365. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105366. * The material will try to infer what glossiness each pixel should be.
  105367. */
  105368. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  105369. /**
  105370. * Defines the falloff type used in this material.
  105371. * It by default is Physical.
  105372. */
  105373. protected _lightFalloff: number;
  105374. /**
  105375. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105376. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105377. */
  105378. protected _useRadianceOverAlpha: boolean;
  105379. /**
  105380. * Allows using an object space normal map (instead of tangent space).
  105381. */
  105382. protected _useObjectSpaceNormalMap: boolean;
  105383. /**
  105384. * Allows using the bump map in parallax mode.
  105385. */
  105386. protected _useParallax: boolean;
  105387. /**
  105388. * Allows using the bump map in parallax occlusion mode.
  105389. */
  105390. protected _useParallaxOcclusion: boolean;
  105391. /**
  105392. * Controls the scale bias of the parallax mode.
  105393. */
  105394. protected _parallaxScaleBias: number;
  105395. /**
  105396. * If sets to true, disables all the lights affecting the material.
  105397. */
  105398. protected _disableLighting: boolean;
  105399. /**
  105400. * Number of Simultaneous lights allowed on the material.
  105401. */
  105402. protected _maxSimultaneousLights: number;
  105403. /**
  105404. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105405. */
  105406. protected _invertNormalMapX: boolean;
  105407. /**
  105408. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105409. */
  105410. protected _invertNormalMapY: boolean;
  105411. /**
  105412. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105413. */
  105414. protected _twoSidedLighting: boolean;
  105415. /**
  105416. * Defines the alpha limits in alpha test mode.
  105417. */
  105418. protected _alphaCutOff: number;
  105419. /**
  105420. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105421. */
  105422. protected _forceAlphaTest: boolean;
  105423. /**
  105424. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105425. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105426. */
  105427. protected _useAlphaFresnel: boolean;
  105428. /**
  105429. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105430. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105431. */
  105432. protected _useLinearAlphaFresnel: boolean;
  105433. /**
  105434. * The transparency mode of the material.
  105435. */
  105436. protected _transparencyMode: Nullable<number>;
  105437. /**
  105438. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  105439. * from cos thetav and roughness:
  105440. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  105441. */
  105442. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  105443. /**
  105444. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105445. */
  105446. protected _forceIrradianceInFragment: boolean;
  105447. /**
  105448. * Force normal to face away from face.
  105449. */
  105450. protected _forceNormalForward: boolean;
  105451. /**
  105452. * Enables specular anti aliasing in the PBR shader.
  105453. * It will both interacts on the Geometry for analytical and IBL lighting.
  105454. * It also prefilter the roughness map based on the bump values.
  105455. */
  105456. protected _enableSpecularAntiAliasing: boolean;
  105457. /**
  105458. * Default configuration related to image processing available in the PBR Material.
  105459. */
  105460. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105461. /**
  105462. * Keep track of the image processing observer to allow dispose and replace.
  105463. */
  105464. private _imageProcessingObserver;
  105465. /**
  105466. * Attaches a new image processing configuration to the PBR Material.
  105467. * @param configuration
  105468. */
  105469. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105470. /**
  105471. * Stores the available render targets.
  105472. */
  105473. private _renderTargets;
  105474. /**
  105475. * Sets the global ambient color for the material used in lighting calculations.
  105476. */
  105477. private _globalAmbientColor;
  105478. /**
  105479. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  105480. */
  105481. private _useLogarithmicDepth;
  105482. /**
  105483. * If set to true, no lighting calculations will be applied.
  105484. */
  105485. private _unlit;
  105486. private _debugMode;
  105487. /**
  105488. * @hidden
  105489. * This is reserved for the inspector.
  105490. * Defines the material debug mode.
  105491. * It helps seeing only some components of the material while troubleshooting.
  105492. */
  105493. debugMode: number;
  105494. /**
  105495. * @hidden
  105496. * This is reserved for the inspector.
  105497. * Specify from where on screen the debug mode should start.
  105498. * The value goes from -1 (full screen) to 1 (not visible)
  105499. * It helps with side by side comparison against the final render
  105500. * This defaults to -1
  105501. */
  105502. private debugLimit;
  105503. /**
  105504. * @hidden
  105505. * This is reserved for the inspector.
  105506. * As the default viewing range might not be enough (if the ambient is really small for instance)
  105507. * You can use the factor to better multiply the final value.
  105508. */
  105509. private debugFactor;
  105510. /**
  105511. * Defines the clear coat layer parameters for the material.
  105512. */
  105513. readonly clearCoat: PBRClearCoatConfiguration;
  105514. /**
  105515. * Defines the anisotropic parameters for the material.
  105516. */
  105517. readonly anisotropy: PBRAnisotropicConfiguration;
  105518. /**
  105519. * Defines the BRDF parameters for the material.
  105520. */
  105521. readonly brdf: PBRBRDFConfiguration;
  105522. /**
  105523. * Defines the Sheen parameters for the material.
  105524. */
  105525. readonly sheen: PBRSheenConfiguration;
  105526. /**
  105527. * Defines the SubSurface parameters for the material.
  105528. */
  105529. readonly subSurface: PBRSubSurfaceConfiguration;
  105530. /**
  105531. * Custom callback helping to override the default shader used in the material.
  105532. */
  105533. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  105534. /**
  105535. * Instantiates a new PBRMaterial instance.
  105536. *
  105537. * @param name The material name
  105538. * @param scene The scene the material will be use in.
  105539. */
  105540. constructor(name: string, scene: Scene);
  105541. /**
  105542. * Gets a boolean indicating that current material needs to register RTT
  105543. */
  105544. readonly hasRenderTargetTextures: boolean;
  105545. /**
  105546. * Gets the name of the material class.
  105547. */
  105548. getClassName(): string;
  105549. /**
  105550. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105551. */
  105552. /**
  105553. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105554. */
  105555. useLogarithmicDepth: boolean;
  105556. /**
  105557. * Gets the current transparency mode.
  105558. */
  105559. /**
  105560. * Sets the transparency mode of the material.
  105561. *
  105562. * | Value | Type | Description |
  105563. * | ----- | ----------------------------------- | ----------- |
  105564. * | 0 | OPAQUE | |
  105565. * | 1 | ALPHATEST | |
  105566. * | 2 | ALPHABLEND | |
  105567. * | 3 | ALPHATESTANDBLEND | |
  105568. *
  105569. */
  105570. transparencyMode: Nullable<number>;
  105571. /**
  105572. * Returns true if alpha blending should be disabled.
  105573. */
  105574. private readonly _disableAlphaBlending;
  105575. /**
  105576. * Specifies whether or not this material should be rendered in alpha blend mode.
  105577. */
  105578. needAlphaBlending(): boolean;
  105579. /**
  105580. * Specifies if the mesh will require alpha blending.
  105581. * @param mesh - BJS mesh.
  105582. */
  105583. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105584. /**
  105585. * Specifies whether or not this material should be rendered in alpha test mode.
  105586. */
  105587. needAlphaTesting(): boolean;
  105588. /**
  105589. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  105590. */
  105591. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  105592. /**
  105593. * Gets the texture used for the alpha test.
  105594. */
  105595. getAlphaTestTexture(): Nullable<BaseTexture>;
  105596. /**
  105597. * Specifies that the submesh is ready to be used.
  105598. * @param mesh - BJS mesh.
  105599. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  105600. * @param useInstances - Specifies that instances should be used.
  105601. * @returns - boolean indicating that the submesh is ready or not.
  105602. */
  105603. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105604. /**
  105605. * Specifies if the material uses metallic roughness workflow.
  105606. * @returns boolean specifiying if the material uses metallic roughness workflow.
  105607. */
  105608. isMetallicWorkflow(): boolean;
  105609. private _prepareEffect;
  105610. private _prepareDefines;
  105611. /**
  105612. * Force shader compilation
  105613. */
  105614. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  105615. clipPlane: boolean;
  105616. }>): void;
  105617. /**
  105618. * Initializes the uniform buffer layout for the shader.
  105619. */
  105620. buildUniformLayout(): void;
  105621. /**
  105622. * Unbinds the material from the mesh
  105623. */
  105624. unbind(): void;
  105625. /**
  105626. * Binds the submesh data.
  105627. * @param world - The world matrix.
  105628. * @param mesh - The BJS mesh.
  105629. * @param subMesh - A submesh of the BJS mesh.
  105630. */
  105631. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105632. /**
  105633. * Returns the animatable textures.
  105634. * @returns - Array of animatable textures.
  105635. */
  105636. getAnimatables(): IAnimatable[];
  105637. /**
  105638. * Returns the texture used for reflections.
  105639. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  105640. */
  105641. private _getReflectionTexture;
  105642. /**
  105643. * Returns an array of the actively used textures.
  105644. * @returns - Array of BaseTextures
  105645. */
  105646. getActiveTextures(): BaseTexture[];
  105647. /**
  105648. * Checks to see if a texture is used in the material.
  105649. * @param texture - Base texture to use.
  105650. * @returns - Boolean specifying if a texture is used in the material.
  105651. */
  105652. hasTexture(texture: BaseTexture): boolean;
  105653. /**
  105654. * Disposes the resources of the material.
  105655. * @param forceDisposeEffect - Forces the disposal of effects.
  105656. * @param forceDisposeTextures - Forces the disposal of all textures.
  105657. */
  105658. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105659. }
  105660. }
  105661. declare module BABYLON {
  105662. /**
  105663. * The Physically based material of BJS.
  105664. *
  105665. * This offers the main features of a standard PBR material.
  105666. * For more information, please refer to the documentation :
  105667. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  105668. */
  105669. export class PBRMaterial extends PBRBaseMaterial {
  105670. /**
  105671. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105672. */
  105673. static readonly PBRMATERIAL_OPAQUE: number;
  105674. /**
  105675. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105676. */
  105677. static readonly PBRMATERIAL_ALPHATEST: number;
  105678. /**
  105679. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105680. */
  105681. static readonly PBRMATERIAL_ALPHABLEND: number;
  105682. /**
  105683. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105684. * They are also discarded below the alpha cutoff threshold to improve performances.
  105685. */
  105686. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105687. /**
  105688. * Defines the default value of how much AO map is occluding the analytical lights
  105689. * (point spot...).
  105690. */
  105691. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105692. /**
  105693. * Intensity of the direct lights e.g. the four lights available in your scene.
  105694. * This impacts both the direct diffuse and specular highlights.
  105695. */
  105696. directIntensity: number;
  105697. /**
  105698. * Intensity of the emissive part of the material.
  105699. * This helps controlling the emissive effect without modifying the emissive color.
  105700. */
  105701. emissiveIntensity: number;
  105702. /**
  105703. * Intensity of the environment e.g. how much the environment will light the object
  105704. * either through harmonics for rough material or through the refelction for shiny ones.
  105705. */
  105706. environmentIntensity: number;
  105707. /**
  105708. * This is a special control allowing the reduction of the specular highlights coming from the
  105709. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105710. */
  105711. specularIntensity: number;
  105712. /**
  105713. * Debug Control allowing disabling the bump map on this material.
  105714. */
  105715. disableBumpMap: boolean;
  105716. /**
  105717. * AKA Diffuse Texture in standard nomenclature.
  105718. */
  105719. albedoTexture: BaseTexture;
  105720. /**
  105721. * AKA Occlusion Texture in other nomenclature.
  105722. */
  105723. ambientTexture: BaseTexture;
  105724. /**
  105725. * AKA Occlusion Texture Intensity in other nomenclature.
  105726. */
  105727. ambientTextureStrength: number;
  105728. /**
  105729. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105730. * 1 means it completely occludes it
  105731. * 0 mean it has no impact
  105732. */
  105733. ambientTextureImpactOnAnalyticalLights: number;
  105734. /**
  105735. * Stores the alpha values in a texture.
  105736. */
  105737. opacityTexture: BaseTexture;
  105738. /**
  105739. * Stores the reflection values in a texture.
  105740. */
  105741. reflectionTexture: Nullable<BaseTexture>;
  105742. /**
  105743. * Stores the emissive values in a texture.
  105744. */
  105745. emissiveTexture: BaseTexture;
  105746. /**
  105747. * AKA Specular texture in other nomenclature.
  105748. */
  105749. reflectivityTexture: BaseTexture;
  105750. /**
  105751. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105752. */
  105753. metallicTexture: BaseTexture;
  105754. /**
  105755. * Specifies the metallic scalar of the metallic/roughness workflow.
  105756. * Can also be used to scale the metalness values of the metallic texture.
  105757. */
  105758. metallic: Nullable<number>;
  105759. /**
  105760. * Specifies the roughness scalar of the metallic/roughness workflow.
  105761. * Can also be used to scale the roughness values of the metallic texture.
  105762. */
  105763. roughness: Nullable<number>;
  105764. /**
  105765. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105766. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105767. */
  105768. microSurfaceTexture: BaseTexture;
  105769. /**
  105770. * Stores surface normal data used to displace a mesh in a texture.
  105771. */
  105772. bumpTexture: BaseTexture;
  105773. /**
  105774. * Stores the pre-calculated light information of a mesh in a texture.
  105775. */
  105776. lightmapTexture: BaseTexture;
  105777. /**
  105778. * Stores the refracted light information in a texture.
  105779. */
  105780. refractionTexture: Nullable<BaseTexture>;
  105781. /**
  105782. * The color of a material in ambient lighting.
  105783. */
  105784. ambientColor: Color3;
  105785. /**
  105786. * AKA Diffuse Color in other nomenclature.
  105787. */
  105788. albedoColor: Color3;
  105789. /**
  105790. * AKA Specular Color in other nomenclature.
  105791. */
  105792. reflectivityColor: Color3;
  105793. /**
  105794. * The color reflected from the material.
  105795. */
  105796. reflectionColor: Color3;
  105797. /**
  105798. * The color emitted from the material.
  105799. */
  105800. emissiveColor: Color3;
  105801. /**
  105802. * AKA Glossiness in other nomenclature.
  105803. */
  105804. microSurface: number;
  105805. /**
  105806. * source material index of refraction (IOR)' / 'destination material IOR.
  105807. */
  105808. indexOfRefraction: number;
  105809. /**
  105810. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105811. */
  105812. invertRefractionY: boolean;
  105813. /**
  105814. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105815. * Materials half opaque for instance using refraction could benefit from this control.
  105816. */
  105817. linkRefractionWithTransparency: boolean;
  105818. /**
  105819. * If true, the light map contains occlusion information instead of lighting info.
  105820. */
  105821. useLightmapAsShadowmap: boolean;
  105822. /**
  105823. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105824. */
  105825. useAlphaFromAlbedoTexture: boolean;
  105826. /**
  105827. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105828. */
  105829. forceAlphaTest: boolean;
  105830. /**
  105831. * Defines the alpha limits in alpha test mode.
  105832. */
  105833. alphaCutOff: number;
  105834. /**
  105835. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105836. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105837. */
  105838. useSpecularOverAlpha: boolean;
  105839. /**
  105840. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105841. */
  105842. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105843. /**
  105844. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105845. */
  105846. useRoughnessFromMetallicTextureAlpha: boolean;
  105847. /**
  105848. * Specifies if the metallic texture contains the roughness information in its green channel.
  105849. */
  105850. useRoughnessFromMetallicTextureGreen: boolean;
  105851. /**
  105852. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105853. */
  105854. useMetallnessFromMetallicTextureBlue: boolean;
  105855. /**
  105856. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105857. */
  105858. useAmbientOcclusionFromMetallicTextureRed: boolean;
  105859. /**
  105860. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105861. */
  105862. useAmbientInGrayScale: boolean;
  105863. /**
  105864. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105865. * The material will try to infer what glossiness each pixel should be.
  105866. */
  105867. useAutoMicroSurfaceFromReflectivityMap: boolean;
  105868. /**
  105869. * BJS is using an harcoded light falloff based on a manually sets up range.
  105870. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105871. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105872. */
  105873. /**
  105874. * BJS is using an harcoded light falloff based on a manually sets up range.
  105875. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105876. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105877. */
  105878. usePhysicalLightFalloff: boolean;
  105879. /**
  105880. * In order to support the falloff compatibility with gltf, a special mode has been added
  105881. * to reproduce the gltf light falloff.
  105882. */
  105883. /**
  105884. * In order to support the falloff compatibility with gltf, a special mode has been added
  105885. * to reproduce the gltf light falloff.
  105886. */
  105887. useGLTFLightFalloff: boolean;
  105888. /**
  105889. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105890. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105891. */
  105892. useRadianceOverAlpha: boolean;
  105893. /**
  105894. * Allows using an object space normal map (instead of tangent space).
  105895. */
  105896. useObjectSpaceNormalMap: boolean;
  105897. /**
  105898. * Allows using the bump map in parallax mode.
  105899. */
  105900. useParallax: boolean;
  105901. /**
  105902. * Allows using the bump map in parallax occlusion mode.
  105903. */
  105904. useParallaxOcclusion: boolean;
  105905. /**
  105906. * Controls the scale bias of the parallax mode.
  105907. */
  105908. parallaxScaleBias: number;
  105909. /**
  105910. * If sets to true, disables all the lights affecting the material.
  105911. */
  105912. disableLighting: boolean;
  105913. /**
  105914. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105915. */
  105916. forceIrradianceInFragment: boolean;
  105917. /**
  105918. * Number of Simultaneous lights allowed on the material.
  105919. */
  105920. maxSimultaneousLights: number;
  105921. /**
  105922. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105923. */
  105924. invertNormalMapX: boolean;
  105925. /**
  105926. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105927. */
  105928. invertNormalMapY: boolean;
  105929. /**
  105930. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105931. */
  105932. twoSidedLighting: boolean;
  105933. /**
  105934. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105935. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105936. */
  105937. useAlphaFresnel: boolean;
  105938. /**
  105939. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105940. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105941. */
  105942. useLinearAlphaFresnel: boolean;
  105943. /**
  105944. * Let user defines the brdf lookup texture used for IBL.
  105945. * A default 8bit version is embedded but you could point at :
  105946. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  105947. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105948. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105949. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105950. */
  105951. environmentBRDFTexture: Nullable<BaseTexture>;
  105952. /**
  105953. * Force normal to face away from face.
  105954. */
  105955. forceNormalForward: boolean;
  105956. /**
  105957. * Enables specular anti aliasing in the PBR shader.
  105958. * It will both interacts on the Geometry for analytical and IBL lighting.
  105959. * It also prefilter the roughness map based on the bump values.
  105960. */
  105961. enableSpecularAntiAliasing: boolean;
  105962. /**
  105963. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105964. * makes the reflect vector face the model (under horizon).
  105965. */
  105966. useHorizonOcclusion: boolean;
  105967. /**
  105968. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105969. * too much the area relying on ambient texture to define their ambient occlusion.
  105970. */
  105971. useRadianceOcclusion: boolean;
  105972. /**
  105973. * If set to true, no lighting calculations will be applied.
  105974. */
  105975. unlit: boolean;
  105976. /**
  105977. * Gets the image processing configuration used either in this material.
  105978. */
  105979. /**
  105980. * Sets the Default image processing configuration used either in the this material.
  105981. *
  105982. * If sets to null, the scene one is in use.
  105983. */
  105984. imageProcessingConfiguration: ImageProcessingConfiguration;
  105985. /**
  105986. * Gets wether the color curves effect is enabled.
  105987. */
  105988. /**
  105989. * Sets wether the color curves effect is enabled.
  105990. */
  105991. cameraColorCurvesEnabled: boolean;
  105992. /**
  105993. * Gets wether the color grading effect is enabled.
  105994. */
  105995. /**
  105996. * Gets wether the color grading effect is enabled.
  105997. */
  105998. cameraColorGradingEnabled: boolean;
  105999. /**
  106000. * Gets wether tonemapping is enabled or not.
  106001. */
  106002. /**
  106003. * Sets wether tonemapping is enabled or not
  106004. */
  106005. cameraToneMappingEnabled: boolean;
  106006. /**
  106007. * The camera exposure used on this material.
  106008. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106009. * This corresponds to a photographic exposure.
  106010. */
  106011. /**
  106012. * The camera exposure used on this material.
  106013. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106014. * This corresponds to a photographic exposure.
  106015. */
  106016. cameraExposure: number;
  106017. /**
  106018. * Gets The camera contrast used on this material.
  106019. */
  106020. /**
  106021. * Sets The camera contrast used on this material.
  106022. */
  106023. cameraContrast: number;
  106024. /**
  106025. * Gets the Color Grading 2D Lookup Texture.
  106026. */
  106027. /**
  106028. * Sets the Color Grading 2D Lookup Texture.
  106029. */
  106030. cameraColorGradingTexture: Nullable<BaseTexture>;
  106031. /**
  106032. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106033. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106034. * 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;
  106035. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106036. */
  106037. /**
  106038. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106039. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106040. * 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;
  106041. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106042. */
  106043. cameraColorCurves: Nullable<ColorCurves>;
  106044. /**
  106045. * Instantiates a new PBRMaterial instance.
  106046. *
  106047. * @param name The material name
  106048. * @param scene The scene the material will be use in.
  106049. */
  106050. constructor(name: string, scene: Scene);
  106051. /**
  106052. * Returns the name of this material class.
  106053. */
  106054. getClassName(): string;
  106055. /**
  106056. * Makes a duplicate of the current material.
  106057. * @param name - name to use for the new material.
  106058. */
  106059. clone(name: string): PBRMaterial;
  106060. /**
  106061. * Serializes this PBR Material.
  106062. * @returns - An object with the serialized material.
  106063. */
  106064. serialize(): any;
  106065. /**
  106066. * Parses a PBR Material from a serialized object.
  106067. * @param source - Serialized object.
  106068. * @param scene - BJS scene instance.
  106069. * @param rootUrl - url for the scene object
  106070. * @returns - PBRMaterial
  106071. */
  106072. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  106073. }
  106074. }
  106075. declare module BABYLON {
  106076. /**
  106077. * Direct draw surface info
  106078. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  106079. */
  106080. export interface DDSInfo {
  106081. /**
  106082. * Width of the texture
  106083. */
  106084. width: number;
  106085. /**
  106086. * Width of the texture
  106087. */
  106088. height: number;
  106089. /**
  106090. * Number of Mipmaps for the texture
  106091. * @see https://en.wikipedia.org/wiki/Mipmap
  106092. */
  106093. mipmapCount: number;
  106094. /**
  106095. * If the textures format is a known fourCC format
  106096. * @see https://www.fourcc.org/
  106097. */
  106098. isFourCC: boolean;
  106099. /**
  106100. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  106101. */
  106102. isRGB: boolean;
  106103. /**
  106104. * If the texture is a lumincance format
  106105. */
  106106. isLuminance: boolean;
  106107. /**
  106108. * If this is a cube texture
  106109. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  106110. */
  106111. isCube: boolean;
  106112. /**
  106113. * If the texture is a compressed format eg. FOURCC_DXT1
  106114. */
  106115. isCompressed: boolean;
  106116. /**
  106117. * The dxgiFormat of the texture
  106118. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  106119. */
  106120. dxgiFormat: number;
  106121. /**
  106122. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  106123. */
  106124. textureType: number;
  106125. /**
  106126. * Sphericle polynomial created for the dds texture
  106127. */
  106128. sphericalPolynomial?: SphericalPolynomial;
  106129. }
  106130. /**
  106131. * Class used to provide DDS decompression tools
  106132. */
  106133. export class DDSTools {
  106134. /**
  106135. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  106136. */
  106137. static StoreLODInAlphaChannel: boolean;
  106138. /**
  106139. * Gets DDS information from an array buffer
  106140. * @param arrayBuffer defines the array buffer to read data from
  106141. * @returns the DDS information
  106142. */
  106143. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  106144. private static _FloatView;
  106145. private static _Int32View;
  106146. private static _ToHalfFloat;
  106147. private static _FromHalfFloat;
  106148. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  106149. private static _GetHalfFloatRGBAArrayBuffer;
  106150. private static _GetFloatRGBAArrayBuffer;
  106151. private static _GetFloatAsUIntRGBAArrayBuffer;
  106152. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  106153. private static _GetRGBAArrayBuffer;
  106154. private static _ExtractLongWordOrder;
  106155. private static _GetRGBArrayBuffer;
  106156. private static _GetLuminanceArrayBuffer;
  106157. /**
  106158. * Uploads DDS Levels to a Babylon Texture
  106159. * @hidden
  106160. */
  106161. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  106162. }
  106163. interface Engine {
  106164. /**
  106165. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  106166. * @param rootUrl defines the url where the file to load is located
  106167. * @param scene defines the current scene
  106168. * @param lodScale defines scale to apply to the mip map selection
  106169. * @param lodOffset defines offset to apply to the mip map selection
  106170. * @param onLoad defines an optional callback raised when the texture is loaded
  106171. * @param onError defines an optional callback raised if there is an issue to load the texture
  106172. * @param format defines the format of the data
  106173. * @param forcedExtension defines the extension to use to pick the right loader
  106174. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  106175. * @returns the cube texture as an InternalTexture
  106176. */
  106177. 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;
  106178. }
  106179. }
  106180. declare module BABYLON {
  106181. /**
  106182. * Implementation of the DDS Texture Loader.
  106183. * @hidden
  106184. */
  106185. export class _DDSTextureLoader implements IInternalTextureLoader {
  106186. /**
  106187. * Defines wether the loader supports cascade loading the different faces.
  106188. */
  106189. readonly supportCascades: boolean;
  106190. /**
  106191. * This returns if the loader support the current file information.
  106192. * @param extension defines the file extension of the file being loaded
  106193. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106194. * @param fallback defines the fallback internal texture if any
  106195. * @param isBase64 defines whether the texture is encoded as a base64
  106196. * @param isBuffer defines whether the texture data are stored as a buffer
  106197. * @returns true if the loader can load the specified file
  106198. */
  106199. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106200. /**
  106201. * Transform the url before loading if required.
  106202. * @param rootUrl the url of the texture
  106203. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106204. * @returns the transformed texture
  106205. */
  106206. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106207. /**
  106208. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106209. * @param rootUrl the url of the texture
  106210. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106211. * @returns the fallback texture
  106212. */
  106213. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106214. /**
  106215. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106216. * @param data contains the texture data
  106217. * @param texture defines the BabylonJS internal texture
  106218. * @param createPolynomials will be true if polynomials have been requested
  106219. * @param onLoad defines the callback to trigger once the texture is ready
  106220. * @param onError defines the callback to trigger in case of error
  106221. */
  106222. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106223. /**
  106224. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106225. * @param data contains the texture data
  106226. * @param texture defines the BabylonJS internal texture
  106227. * @param callback defines the method to call once ready to upload
  106228. */
  106229. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106230. }
  106231. }
  106232. declare module BABYLON {
  106233. /** @hidden */
  106234. export var rgbdEncodePixelShader: {
  106235. name: string;
  106236. shader: string;
  106237. };
  106238. }
  106239. declare module BABYLON {
  106240. /**
  106241. * Raw texture data and descriptor sufficient for WebGL texture upload
  106242. */
  106243. export interface EnvironmentTextureInfo {
  106244. /**
  106245. * Version of the environment map
  106246. */
  106247. version: number;
  106248. /**
  106249. * Width of image
  106250. */
  106251. width: number;
  106252. /**
  106253. * Irradiance information stored in the file.
  106254. */
  106255. irradiance: any;
  106256. /**
  106257. * Specular information stored in the file.
  106258. */
  106259. specular: any;
  106260. }
  106261. /**
  106262. * Sets of helpers addressing the serialization and deserialization of environment texture
  106263. * stored in a BabylonJS env file.
  106264. * Those files are usually stored as .env files.
  106265. */
  106266. export class EnvironmentTextureTools {
  106267. /**
  106268. * Magic number identifying the env file.
  106269. */
  106270. private static _MagicBytes;
  106271. /**
  106272. * Gets the environment info from an env file.
  106273. * @param data The array buffer containing the .env bytes.
  106274. * @returns the environment file info (the json header) if successfully parsed.
  106275. */
  106276. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  106277. /**
  106278. * Creates an environment texture from a loaded cube texture.
  106279. * @param texture defines the cube texture to convert in env file
  106280. * @return a promise containing the environment data if succesfull.
  106281. */
  106282. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  106283. /**
  106284. * Creates a JSON representation of the spherical data.
  106285. * @param texture defines the texture containing the polynomials
  106286. * @return the JSON representation of the spherical info
  106287. */
  106288. private static _CreateEnvTextureIrradiance;
  106289. /**
  106290. * Uploads the texture info contained in the env file to the GPU.
  106291. * @param texture defines the internal texture to upload to
  106292. * @param arrayBuffer defines the buffer cotaining the data to load
  106293. * @param info defines the texture info retrieved through the GetEnvInfo method
  106294. * @returns a promise
  106295. */
  106296. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  106297. /**
  106298. * Uploads the levels of image data to the GPU.
  106299. * @param texture defines the internal texture to upload to
  106300. * @param imageData defines the array buffer views of image data [mipmap][face]
  106301. * @returns a promise
  106302. */
  106303. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  106304. /**
  106305. * Uploads spherical polynomials information to the texture.
  106306. * @param texture defines the texture we are trying to upload the information to
  106307. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  106308. */
  106309. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  106310. /** @hidden */
  106311. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106312. }
  106313. }
  106314. declare module BABYLON {
  106315. /**
  106316. * Implementation of the ENV Texture Loader.
  106317. * @hidden
  106318. */
  106319. export class _ENVTextureLoader implements IInternalTextureLoader {
  106320. /**
  106321. * Defines wether the loader supports cascade loading the different faces.
  106322. */
  106323. readonly supportCascades: boolean;
  106324. /**
  106325. * This returns if the loader support the current file information.
  106326. * @param extension defines the file extension of the file being loaded
  106327. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106328. * @param fallback defines the fallback internal texture if any
  106329. * @param isBase64 defines whether the texture is encoded as a base64
  106330. * @param isBuffer defines whether the texture data are stored as a buffer
  106331. * @returns true if the loader can load the specified file
  106332. */
  106333. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106334. /**
  106335. * Transform the url before loading if required.
  106336. * @param rootUrl the url of the texture
  106337. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106338. * @returns the transformed texture
  106339. */
  106340. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106341. /**
  106342. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106343. * @param rootUrl the url of the texture
  106344. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106345. * @returns the fallback texture
  106346. */
  106347. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106348. /**
  106349. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106350. * @param data contains the texture data
  106351. * @param texture defines the BabylonJS internal texture
  106352. * @param createPolynomials will be true if polynomials have been requested
  106353. * @param onLoad defines the callback to trigger once the texture is ready
  106354. * @param onError defines the callback to trigger in case of error
  106355. */
  106356. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106357. /**
  106358. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106359. * @param data contains the texture data
  106360. * @param texture defines the BabylonJS internal texture
  106361. * @param callback defines the method to call once ready to upload
  106362. */
  106363. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106364. }
  106365. }
  106366. declare module BABYLON {
  106367. /**
  106368. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106369. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106370. */
  106371. export class KhronosTextureContainer {
  106372. /** contents of the KTX container file */
  106373. arrayBuffer: any;
  106374. private static HEADER_LEN;
  106375. private static COMPRESSED_2D;
  106376. private static COMPRESSED_3D;
  106377. private static TEX_2D;
  106378. private static TEX_3D;
  106379. /**
  106380. * Gets the openGL type
  106381. */
  106382. glType: number;
  106383. /**
  106384. * Gets the openGL type size
  106385. */
  106386. glTypeSize: number;
  106387. /**
  106388. * Gets the openGL format
  106389. */
  106390. glFormat: number;
  106391. /**
  106392. * Gets the openGL internal format
  106393. */
  106394. glInternalFormat: number;
  106395. /**
  106396. * Gets the base internal format
  106397. */
  106398. glBaseInternalFormat: number;
  106399. /**
  106400. * Gets image width in pixel
  106401. */
  106402. pixelWidth: number;
  106403. /**
  106404. * Gets image height in pixel
  106405. */
  106406. pixelHeight: number;
  106407. /**
  106408. * Gets image depth in pixels
  106409. */
  106410. pixelDepth: number;
  106411. /**
  106412. * Gets the number of array elements
  106413. */
  106414. numberOfArrayElements: number;
  106415. /**
  106416. * Gets the number of faces
  106417. */
  106418. numberOfFaces: number;
  106419. /**
  106420. * Gets the number of mipmap levels
  106421. */
  106422. numberOfMipmapLevels: number;
  106423. /**
  106424. * Gets the bytes of key value data
  106425. */
  106426. bytesOfKeyValueData: number;
  106427. /**
  106428. * Gets the load type
  106429. */
  106430. loadType: number;
  106431. /**
  106432. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  106433. */
  106434. isInvalid: boolean;
  106435. /**
  106436. * Creates a new KhronosTextureContainer
  106437. * @param arrayBuffer contents of the KTX container file
  106438. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  106439. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  106440. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  106441. */
  106442. constructor(
  106443. /** contents of the KTX container file */
  106444. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  106445. /**
  106446. * Uploads KTX content to a Babylon Texture.
  106447. * It is assumed that the texture has already been created & is currently bound
  106448. * @hidden
  106449. */
  106450. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  106451. private _upload2DCompressedLevels;
  106452. }
  106453. }
  106454. declare module BABYLON {
  106455. /**
  106456. * Implementation of the KTX Texture Loader.
  106457. * @hidden
  106458. */
  106459. export class _KTXTextureLoader implements IInternalTextureLoader {
  106460. /**
  106461. * Defines wether the loader supports cascade loading the different faces.
  106462. */
  106463. readonly supportCascades: boolean;
  106464. /**
  106465. * This returns if the loader support the current file information.
  106466. * @param extension defines the file extension of the file being loaded
  106467. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106468. * @param fallback defines the fallback internal texture if any
  106469. * @param isBase64 defines whether the texture is encoded as a base64
  106470. * @param isBuffer defines whether the texture data are stored as a buffer
  106471. * @returns true if the loader can load the specified file
  106472. */
  106473. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106474. /**
  106475. * Transform the url before loading if required.
  106476. * @param rootUrl the url of the texture
  106477. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106478. * @returns the transformed texture
  106479. */
  106480. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106481. /**
  106482. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106483. * @param rootUrl the url of the texture
  106484. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106485. * @returns the fallback texture
  106486. */
  106487. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106488. /**
  106489. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106490. * @param data contains the texture data
  106491. * @param texture defines the BabylonJS internal texture
  106492. * @param createPolynomials will be true if polynomials have been requested
  106493. * @param onLoad defines the callback to trigger once the texture is ready
  106494. * @param onError defines the callback to trigger in case of error
  106495. */
  106496. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106497. /**
  106498. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106499. * @param data contains the texture data
  106500. * @param texture defines the BabylonJS internal texture
  106501. * @param callback defines the method to call once ready to upload
  106502. */
  106503. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  106504. }
  106505. }
  106506. declare module BABYLON {
  106507. /** @hidden */
  106508. export var _forceSceneHelpersToBundle: boolean;
  106509. interface Scene {
  106510. /**
  106511. * Creates a default light for the scene.
  106512. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  106513. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  106514. */
  106515. createDefaultLight(replace?: boolean): void;
  106516. /**
  106517. * Creates a default camera for the scene.
  106518. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  106519. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106520. * @param replace has default false, when true replaces the active camera in the scene
  106521. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  106522. */
  106523. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106524. /**
  106525. * Creates a default camera and a default light.
  106526. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  106527. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106528. * @param replace has the default false, when true replaces the active camera/light in the scene
  106529. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  106530. */
  106531. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106532. /**
  106533. * Creates a new sky box
  106534. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  106535. * @param environmentTexture defines the texture to use as environment texture
  106536. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  106537. * @param scale defines the overall scale of the skybox
  106538. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  106539. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  106540. * @returns a new mesh holding the sky box
  106541. */
  106542. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  106543. /**
  106544. * Creates a new environment
  106545. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  106546. * @param options defines the options you can use to configure the environment
  106547. * @returns the new EnvironmentHelper
  106548. */
  106549. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  106550. /**
  106551. * Creates a new VREXperienceHelper
  106552. * @see http://doc.babylonjs.com/how_to/webvr_helper
  106553. * @param webVROptions defines the options used to create the new VREXperienceHelper
  106554. * @returns a new VREXperienceHelper
  106555. */
  106556. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  106557. /**
  106558. * Creates a new XREXperienceHelper
  106559. * @see http://doc.babylonjs.com/how_to/webxr
  106560. * @returns a promise for a new XREXperienceHelper
  106561. */
  106562. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  106563. }
  106564. }
  106565. declare module BABYLON {
  106566. /**
  106567. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  106568. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  106569. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  106570. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106571. */
  106572. export class VideoDome extends TransformNode {
  106573. /**
  106574. * Define the video source as a Monoscopic panoramic 360 video.
  106575. */
  106576. static readonly MODE_MONOSCOPIC: number;
  106577. /**
  106578. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106579. */
  106580. static readonly MODE_TOPBOTTOM: number;
  106581. /**
  106582. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106583. */
  106584. static readonly MODE_SIDEBYSIDE: number;
  106585. private _useDirectMapping;
  106586. /**
  106587. * The video texture being displayed on the sphere
  106588. */
  106589. protected _videoTexture: VideoTexture;
  106590. /**
  106591. * Gets the video texture being displayed on the sphere
  106592. */
  106593. readonly videoTexture: VideoTexture;
  106594. /**
  106595. * The skybox material
  106596. */
  106597. protected _material: BackgroundMaterial;
  106598. /**
  106599. * The surface used for the skybox
  106600. */
  106601. protected _mesh: Mesh;
  106602. /**
  106603. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106604. * Also see the options.resolution property.
  106605. */
  106606. fovMultiplier: number;
  106607. private _videoMode;
  106608. /**
  106609. * Gets or set the current video mode for the video. It can be:
  106610. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  106611. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106612. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106613. */
  106614. videoMode: number;
  106615. /**
  106616. * Oberserver used in Stereoscopic VR Mode.
  106617. */
  106618. private _onBeforeCameraRenderObserver;
  106619. /**
  106620. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  106621. * @param name Element's name, child elements will append suffixes for their own names.
  106622. * @param urlsOrVideo defines the url(s) or the video element to use
  106623. * @param options An object containing optional or exposed sub element properties
  106624. */
  106625. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  106626. resolution?: number;
  106627. clickToPlay?: boolean;
  106628. autoPlay?: boolean;
  106629. loop?: boolean;
  106630. size?: number;
  106631. poster?: string;
  106632. faceForward?: boolean;
  106633. useDirectMapping?: boolean;
  106634. }, scene: Scene);
  106635. private _changeVideoMode;
  106636. /**
  106637. * Releases resources associated with this node.
  106638. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106639. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106640. */
  106641. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106642. }
  106643. }
  106644. declare module BABYLON {
  106645. /**
  106646. * This class can be used to get instrumentation data from a Babylon engine
  106647. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106648. */
  106649. export class EngineInstrumentation implements IDisposable {
  106650. /**
  106651. * Define the instrumented engine.
  106652. */
  106653. engine: Engine;
  106654. private _captureGPUFrameTime;
  106655. private _gpuFrameTimeToken;
  106656. private _gpuFrameTime;
  106657. private _captureShaderCompilationTime;
  106658. private _shaderCompilationTime;
  106659. private _onBeginFrameObserver;
  106660. private _onEndFrameObserver;
  106661. private _onBeforeShaderCompilationObserver;
  106662. private _onAfterShaderCompilationObserver;
  106663. /**
  106664. * Gets the perf counter used for GPU frame time
  106665. */
  106666. readonly gpuFrameTimeCounter: PerfCounter;
  106667. /**
  106668. * Gets the GPU frame time capture status
  106669. */
  106670. /**
  106671. * Enable or disable the GPU frame time capture
  106672. */
  106673. captureGPUFrameTime: boolean;
  106674. /**
  106675. * Gets the perf counter used for shader compilation time
  106676. */
  106677. readonly shaderCompilationTimeCounter: PerfCounter;
  106678. /**
  106679. * Gets the shader compilation time capture status
  106680. */
  106681. /**
  106682. * Enable or disable the shader compilation time capture
  106683. */
  106684. captureShaderCompilationTime: boolean;
  106685. /**
  106686. * Instantiates a new engine instrumentation.
  106687. * This class can be used to get instrumentation data from a Babylon engine
  106688. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106689. * @param engine Defines the engine to instrument
  106690. */
  106691. constructor(
  106692. /**
  106693. * Define the instrumented engine.
  106694. */
  106695. engine: Engine);
  106696. /**
  106697. * Dispose and release associated resources.
  106698. */
  106699. dispose(): void;
  106700. }
  106701. }
  106702. declare module BABYLON {
  106703. /**
  106704. * This class can be used to get instrumentation data from a Babylon engine
  106705. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106706. */
  106707. export class SceneInstrumentation implements IDisposable {
  106708. /**
  106709. * Defines the scene to instrument
  106710. */
  106711. scene: Scene;
  106712. private _captureActiveMeshesEvaluationTime;
  106713. private _activeMeshesEvaluationTime;
  106714. private _captureRenderTargetsRenderTime;
  106715. private _renderTargetsRenderTime;
  106716. private _captureFrameTime;
  106717. private _frameTime;
  106718. private _captureRenderTime;
  106719. private _renderTime;
  106720. private _captureInterFrameTime;
  106721. private _interFrameTime;
  106722. private _captureParticlesRenderTime;
  106723. private _particlesRenderTime;
  106724. private _captureSpritesRenderTime;
  106725. private _spritesRenderTime;
  106726. private _capturePhysicsTime;
  106727. private _physicsTime;
  106728. private _captureAnimationsTime;
  106729. private _animationsTime;
  106730. private _captureCameraRenderTime;
  106731. private _cameraRenderTime;
  106732. private _onBeforeActiveMeshesEvaluationObserver;
  106733. private _onAfterActiveMeshesEvaluationObserver;
  106734. private _onBeforeRenderTargetsRenderObserver;
  106735. private _onAfterRenderTargetsRenderObserver;
  106736. private _onAfterRenderObserver;
  106737. private _onBeforeDrawPhaseObserver;
  106738. private _onAfterDrawPhaseObserver;
  106739. private _onBeforeAnimationsObserver;
  106740. private _onBeforeParticlesRenderingObserver;
  106741. private _onAfterParticlesRenderingObserver;
  106742. private _onBeforeSpritesRenderingObserver;
  106743. private _onAfterSpritesRenderingObserver;
  106744. private _onBeforePhysicsObserver;
  106745. private _onAfterPhysicsObserver;
  106746. private _onAfterAnimationsObserver;
  106747. private _onBeforeCameraRenderObserver;
  106748. private _onAfterCameraRenderObserver;
  106749. /**
  106750. * Gets the perf counter used for active meshes evaluation time
  106751. */
  106752. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  106753. /**
  106754. * Gets the active meshes evaluation time capture status
  106755. */
  106756. /**
  106757. * Enable or disable the active meshes evaluation time capture
  106758. */
  106759. captureActiveMeshesEvaluationTime: boolean;
  106760. /**
  106761. * Gets the perf counter used for render targets render time
  106762. */
  106763. readonly renderTargetsRenderTimeCounter: PerfCounter;
  106764. /**
  106765. * Gets the render targets render time capture status
  106766. */
  106767. /**
  106768. * Enable or disable the render targets render time capture
  106769. */
  106770. captureRenderTargetsRenderTime: boolean;
  106771. /**
  106772. * Gets the perf counter used for particles render time
  106773. */
  106774. readonly particlesRenderTimeCounter: PerfCounter;
  106775. /**
  106776. * Gets the particles render time capture status
  106777. */
  106778. /**
  106779. * Enable or disable the particles render time capture
  106780. */
  106781. captureParticlesRenderTime: boolean;
  106782. /**
  106783. * Gets the perf counter used for sprites render time
  106784. */
  106785. readonly spritesRenderTimeCounter: PerfCounter;
  106786. /**
  106787. * Gets the sprites render time capture status
  106788. */
  106789. /**
  106790. * Enable or disable the sprites render time capture
  106791. */
  106792. captureSpritesRenderTime: boolean;
  106793. /**
  106794. * Gets the perf counter used for physics time
  106795. */
  106796. readonly physicsTimeCounter: PerfCounter;
  106797. /**
  106798. * Gets the physics time capture status
  106799. */
  106800. /**
  106801. * Enable or disable the physics time capture
  106802. */
  106803. capturePhysicsTime: boolean;
  106804. /**
  106805. * Gets the perf counter used for animations time
  106806. */
  106807. readonly animationsTimeCounter: PerfCounter;
  106808. /**
  106809. * Gets the animations time capture status
  106810. */
  106811. /**
  106812. * Enable or disable the animations time capture
  106813. */
  106814. captureAnimationsTime: boolean;
  106815. /**
  106816. * Gets the perf counter used for frame time capture
  106817. */
  106818. readonly frameTimeCounter: PerfCounter;
  106819. /**
  106820. * Gets the frame time capture status
  106821. */
  106822. /**
  106823. * Enable or disable the frame time capture
  106824. */
  106825. captureFrameTime: boolean;
  106826. /**
  106827. * Gets the perf counter used for inter-frames time capture
  106828. */
  106829. readonly interFrameTimeCounter: PerfCounter;
  106830. /**
  106831. * Gets the inter-frames time capture status
  106832. */
  106833. /**
  106834. * Enable or disable the inter-frames time capture
  106835. */
  106836. captureInterFrameTime: boolean;
  106837. /**
  106838. * Gets the perf counter used for render time capture
  106839. */
  106840. readonly renderTimeCounter: PerfCounter;
  106841. /**
  106842. * Gets the render time capture status
  106843. */
  106844. /**
  106845. * Enable or disable the render time capture
  106846. */
  106847. captureRenderTime: boolean;
  106848. /**
  106849. * Gets the perf counter used for camera render time capture
  106850. */
  106851. readonly cameraRenderTimeCounter: PerfCounter;
  106852. /**
  106853. * Gets the camera render time capture status
  106854. */
  106855. /**
  106856. * Enable or disable the camera render time capture
  106857. */
  106858. captureCameraRenderTime: boolean;
  106859. /**
  106860. * Gets the perf counter used for draw calls
  106861. */
  106862. readonly drawCallsCounter: PerfCounter;
  106863. /**
  106864. * Instantiates a new scene instrumentation.
  106865. * This class can be used to get instrumentation data from a Babylon engine
  106866. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106867. * @param scene Defines the scene to instrument
  106868. */
  106869. constructor(
  106870. /**
  106871. * Defines the scene to instrument
  106872. */
  106873. scene: Scene);
  106874. /**
  106875. * Dispose and release associated resources.
  106876. */
  106877. dispose(): void;
  106878. }
  106879. }
  106880. declare module BABYLON {
  106881. /** @hidden */
  106882. export var glowMapGenerationPixelShader: {
  106883. name: string;
  106884. shader: string;
  106885. };
  106886. }
  106887. declare module BABYLON {
  106888. /** @hidden */
  106889. export var glowMapGenerationVertexShader: {
  106890. name: string;
  106891. shader: string;
  106892. };
  106893. }
  106894. declare module BABYLON {
  106895. /**
  106896. * Effect layer options. This helps customizing the behaviour
  106897. * of the effect layer.
  106898. */
  106899. export interface IEffectLayerOptions {
  106900. /**
  106901. * Multiplication factor apply to the canvas size to compute the render target size
  106902. * used to generated the objects (the smaller the faster).
  106903. */
  106904. mainTextureRatio: number;
  106905. /**
  106906. * Enforces a fixed size texture to ensure effect stability across devices.
  106907. */
  106908. mainTextureFixedSize?: number;
  106909. /**
  106910. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  106911. */
  106912. alphaBlendingMode: number;
  106913. /**
  106914. * The camera attached to the layer.
  106915. */
  106916. camera: Nullable<Camera>;
  106917. /**
  106918. * The rendering group to draw the layer in.
  106919. */
  106920. renderingGroupId: number;
  106921. }
  106922. /**
  106923. * The effect layer Helps adding post process effect blended with the main pass.
  106924. *
  106925. * This can be for instance use to generate glow or higlight effects on the scene.
  106926. *
  106927. * The effect layer class can not be used directly and is intented to inherited from to be
  106928. * customized per effects.
  106929. */
  106930. export abstract class EffectLayer {
  106931. private _vertexBuffers;
  106932. private _indexBuffer;
  106933. private _cachedDefines;
  106934. private _effectLayerMapGenerationEffect;
  106935. private _effectLayerOptions;
  106936. private _mergeEffect;
  106937. protected _scene: Scene;
  106938. protected _engine: Engine;
  106939. protected _maxSize: number;
  106940. protected _mainTextureDesiredSize: ISize;
  106941. protected _mainTexture: RenderTargetTexture;
  106942. protected _shouldRender: boolean;
  106943. protected _postProcesses: PostProcess[];
  106944. protected _textures: BaseTexture[];
  106945. protected _emissiveTextureAndColor: {
  106946. texture: Nullable<BaseTexture>;
  106947. color: Color4;
  106948. };
  106949. /**
  106950. * The name of the layer
  106951. */
  106952. name: string;
  106953. /**
  106954. * The clear color of the texture used to generate the glow map.
  106955. */
  106956. neutralColor: Color4;
  106957. /**
  106958. * Specifies wether the highlight layer is enabled or not.
  106959. */
  106960. isEnabled: boolean;
  106961. /**
  106962. * Gets the camera attached to the layer.
  106963. */
  106964. readonly camera: Nullable<Camera>;
  106965. /**
  106966. * Gets the rendering group id the layer should render in.
  106967. */
  106968. readonly renderingGroupId: number;
  106969. /**
  106970. * An event triggered when the effect layer has been disposed.
  106971. */
  106972. onDisposeObservable: Observable<EffectLayer>;
  106973. /**
  106974. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  106975. */
  106976. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  106977. /**
  106978. * An event triggered when the generated texture is being merged in the scene.
  106979. */
  106980. onBeforeComposeObservable: Observable<EffectLayer>;
  106981. /**
  106982. * An event triggered when the generated texture has been merged in the scene.
  106983. */
  106984. onAfterComposeObservable: Observable<EffectLayer>;
  106985. /**
  106986. * An event triggered when the efffect layer changes its size.
  106987. */
  106988. onSizeChangedObservable: Observable<EffectLayer>;
  106989. /** @hidden */
  106990. static _SceneComponentInitialization: (scene: Scene) => void;
  106991. /**
  106992. * Instantiates a new effect Layer and references it in the scene.
  106993. * @param name The name of the layer
  106994. * @param scene The scene to use the layer in
  106995. */
  106996. constructor(
  106997. /** The Friendly of the effect in the scene */
  106998. name: string, scene: Scene);
  106999. /**
  107000. * Get the effect name of the layer.
  107001. * @return The effect name
  107002. */
  107003. abstract getEffectName(): string;
  107004. /**
  107005. * Checks for the readiness of the element composing the layer.
  107006. * @param subMesh the mesh to check for
  107007. * @param useInstances specify wether or not to use instances to render the mesh
  107008. * @return true if ready otherwise, false
  107009. */
  107010. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107011. /**
  107012. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107013. * @returns true if the effect requires stencil during the main canvas render pass.
  107014. */
  107015. abstract needStencil(): boolean;
  107016. /**
  107017. * Create the merge effect. This is the shader use to blit the information back
  107018. * to the main canvas at the end of the scene rendering.
  107019. * @returns The effect containing the shader used to merge the effect on the main canvas
  107020. */
  107021. protected abstract _createMergeEffect(): Effect;
  107022. /**
  107023. * Creates the render target textures and post processes used in the effect layer.
  107024. */
  107025. protected abstract _createTextureAndPostProcesses(): void;
  107026. /**
  107027. * Implementation specific of rendering the generating effect on the main canvas.
  107028. * @param effect The effect used to render through
  107029. */
  107030. protected abstract _internalRender(effect: Effect): void;
  107031. /**
  107032. * Sets the required values for both the emissive texture and and the main color.
  107033. */
  107034. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107035. /**
  107036. * Free any resources and references associated to a mesh.
  107037. * Internal use
  107038. * @param mesh The mesh to free.
  107039. */
  107040. abstract _disposeMesh(mesh: Mesh): void;
  107041. /**
  107042. * Serializes this layer (Glow or Highlight for example)
  107043. * @returns a serialized layer object
  107044. */
  107045. abstract serialize?(): any;
  107046. /**
  107047. * Initializes the effect layer with the required options.
  107048. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  107049. */
  107050. protected _init(options: Partial<IEffectLayerOptions>): void;
  107051. /**
  107052. * Generates the index buffer of the full screen quad blending to the main canvas.
  107053. */
  107054. private _generateIndexBuffer;
  107055. /**
  107056. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  107057. */
  107058. private _generateVertexBuffer;
  107059. /**
  107060. * Sets the main texture desired size which is the closest power of two
  107061. * of the engine canvas size.
  107062. */
  107063. private _setMainTextureSize;
  107064. /**
  107065. * Creates the main texture for the effect layer.
  107066. */
  107067. protected _createMainTexture(): void;
  107068. /**
  107069. * Adds specific effects defines.
  107070. * @param defines The defines to add specifics to.
  107071. */
  107072. protected _addCustomEffectDefines(defines: string[]): void;
  107073. /**
  107074. * Checks for the readiness of the element composing the layer.
  107075. * @param subMesh the mesh to check for
  107076. * @param useInstances specify wether or not to use instances to render the mesh
  107077. * @param emissiveTexture the associated emissive texture used to generate the glow
  107078. * @return true if ready otherwise, false
  107079. */
  107080. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  107081. /**
  107082. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  107083. */
  107084. render(): void;
  107085. /**
  107086. * Determine if a given mesh will be used in the current effect.
  107087. * @param mesh mesh to test
  107088. * @returns true if the mesh will be used
  107089. */
  107090. hasMesh(mesh: AbstractMesh): boolean;
  107091. /**
  107092. * Returns true if the layer contains information to display, otherwise false.
  107093. * @returns true if the glow layer should be rendered
  107094. */
  107095. shouldRender(): boolean;
  107096. /**
  107097. * Returns true if the mesh should render, otherwise false.
  107098. * @param mesh The mesh to render
  107099. * @returns true if it should render otherwise false
  107100. */
  107101. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  107102. /**
  107103. * Returns true if the mesh can be rendered, otherwise false.
  107104. * @param mesh The mesh to render
  107105. * @param material The material used on the mesh
  107106. * @returns true if it can be rendered otherwise false
  107107. */
  107108. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  107109. /**
  107110. * Returns true if the mesh should render, otherwise false.
  107111. * @param mesh The mesh to render
  107112. * @returns true if it should render otherwise false
  107113. */
  107114. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  107115. /**
  107116. * Renders the submesh passed in parameter to the generation map.
  107117. */
  107118. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  107119. /**
  107120. * Rebuild the required buffers.
  107121. * @hidden Internal use only.
  107122. */
  107123. _rebuild(): void;
  107124. /**
  107125. * Dispose only the render target textures and post process.
  107126. */
  107127. private _disposeTextureAndPostProcesses;
  107128. /**
  107129. * Dispose the highlight layer and free resources.
  107130. */
  107131. dispose(): void;
  107132. /**
  107133. * Gets the class name of the effect layer
  107134. * @returns the string with the class name of the effect layer
  107135. */
  107136. getClassName(): string;
  107137. /**
  107138. * Creates an effect layer from parsed effect layer data
  107139. * @param parsedEffectLayer defines effect layer data
  107140. * @param scene defines the current scene
  107141. * @param rootUrl defines the root URL containing the effect layer information
  107142. * @returns a parsed effect Layer
  107143. */
  107144. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  107145. }
  107146. }
  107147. declare module BABYLON {
  107148. interface AbstractScene {
  107149. /**
  107150. * The list of effect layers (highlights/glow) added to the scene
  107151. * @see http://doc.babylonjs.com/how_to/highlight_layer
  107152. * @see http://doc.babylonjs.com/how_to/glow_layer
  107153. */
  107154. effectLayers: Array<EffectLayer>;
  107155. /**
  107156. * Removes the given effect layer from this scene.
  107157. * @param toRemove defines the effect layer to remove
  107158. * @returns the index of the removed effect layer
  107159. */
  107160. removeEffectLayer(toRemove: EffectLayer): number;
  107161. /**
  107162. * Adds the given effect layer to this scene
  107163. * @param newEffectLayer defines the effect layer to add
  107164. */
  107165. addEffectLayer(newEffectLayer: EffectLayer): void;
  107166. }
  107167. /**
  107168. * Defines the layer scene component responsible to manage any effect layers
  107169. * in a given scene.
  107170. */
  107171. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  107172. /**
  107173. * The component name helpfull to identify the component in the list of scene components.
  107174. */
  107175. readonly name: string;
  107176. /**
  107177. * The scene the component belongs to.
  107178. */
  107179. scene: Scene;
  107180. private _engine;
  107181. private _renderEffects;
  107182. private _needStencil;
  107183. private _previousStencilState;
  107184. /**
  107185. * Creates a new instance of the component for the given scene
  107186. * @param scene Defines the scene to register the component in
  107187. */
  107188. constructor(scene: Scene);
  107189. /**
  107190. * Registers the component in a given scene
  107191. */
  107192. register(): void;
  107193. /**
  107194. * Rebuilds the elements related to this component in case of
  107195. * context lost for instance.
  107196. */
  107197. rebuild(): void;
  107198. /**
  107199. * Serializes the component data to the specified json object
  107200. * @param serializationObject The object to serialize to
  107201. */
  107202. serialize(serializationObject: any): void;
  107203. /**
  107204. * Adds all the element from the container to the scene
  107205. * @param container the container holding the elements
  107206. */
  107207. addFromContainer(container: AbstractScene): void;
  107208. /**
  107209. * Removes all the elements in the container from the scene
  107210. * @param container contains the elements to remove
  107211. * @param dispose if the removed element should be disposed (default: false)
  107212. */
  107213. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107214. /**
  107215. * Disposes the component and the associated ressources.
  107216. */
  107217. dispose(): void;
  107218. private _isReadyForMesh;
  107219. private _renderMainTexture;
  107220. private _setStencil;
  107221. private _setStencilBack;
  107222. private _draw;
  107223. private _drawCamera;
  107224. private _drawRenderingGroup;
  107225. }
  107226. }
  107227. declare module BABYLON {
  107228. /** @hidden */
  107229. export var glowMapMergePixelShader: {
  107230. name: string;
  107231. shader: string;
  107232. };
  107233. }
  107234. declare module BABYLON {
  107235. /** @hidden */
  107236. export var glowMapMergeVertexShader: {
  107237. name: string;
  107238. shader: string;
  107239. };
  107240. }
  107241. declare module BABYLON {
  107242. interface AbstractScene {
  107243. /**
  107244. * Return a the first highlight layer of the scene with a given name.
  107245. * @param name The name of the highlight layer to look for.
  107246. * @return The highlight layer if found otherwise null.
  107247. */
  107248. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  107249. }
  107250. /**
  107251. * Glow layer options. This helps customizing the behaviour
  107252. * of the glow layer.
  107253. */
  107254. export interface IGlowLayerOptions {
  107255. /**
  107256. * Multiplication factor apply to the canvas size to compute the render target size
  107257. * used to generated the glowing objects (the smaller the faster).
  107258. */
  107259. mainTextureRatio: number;
  107260. /**
  107261. * Enforces a fixed size texture to ensure resize independant blur.
  107262. */
  107263. mainTextureFixedSize?: number;
  107264. /**
  107265. * How big is the kernel of the blur texture.
  107266. */
  107267. blurKernelSize: number;
  107268. /**
  107269. * The camera attached to the layer.
  107270. */
  107271. camera: Nullable<Camera>;
  107272. /**
  107273. * Enable MSAA by chosing the number of samples.
  107274. */
  107275. mainTextureSamples?: number;
  107276. /**
  107277. * The rendering group to draw the layer in.
  107278. */
  107279. renderingGroupId: number;
  107280. }
  107281. /**
  107282. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  107283. *
  107284. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107285. * glowy meshes to your scene.
  107286. *
  107287. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  107288. */
  107289. export class GlowLayer extends EffectLayer {
  107290. /**
  107291. * Effect Name of the layer.
  107292. */
  107293. static readonly EffectName: string;
  107294. /**
  107295. * The default blur kernel size used for the glow.
  107296. */
  107297. static DefaultBlurKernelSize: number;
  107298. /**
  107299. * The default texture size ratio used for the glow.
  107300. */
  107301. static DefaultTextureRatio: number;
  107302. /**
  107303. * Sets the kernel size of the blur.
  107304. */
  107305. /**
  107306. * Gets the kernel size of the blur.
  107307. */
  107308. blurKernelSize: number;
  107309. /**
  107310. * Sets the glow intensity.
  107311. */
  107312. /**
  107313. * Gets the glow intensity.
  107314. */
  107315. intensity: number;
  107316. private _options;
  107317. private _intensity;
  107318. private _horizontalBlurPostprocess1;
  107319. private _verticalBlurPostprocess1;
  107320. private _horizontalBlurPostprocess2;
  107321. private _verticalBlurPostprocess2;
  107322. private _blurTexture1;
  107323. private _blurTexture2;
  107324. private _postProcesses1;
  107325. private _postProcesses2;
  107326. private _includedOnlyMeshes;
  107327. private _excludedMeshes;
  107328. /**
  107329. * Callback used to let the user override the color selection on a per mesh basis
  107330. */
  107331. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  107332. /**
  107333. * Callback used to let the user override the texture selection on a per mesh basis
  107334. */
  107335. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  107336. /**
  107337. * Instantiates a new glow Layer and references it to the scene.
  107338. * @param name The name of the layer
  107339. * @param scene The scene to use the layer in
  107340. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  107341. */
  107342. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  107343. /**
  107344. * Get the effect name of the layer.
  107345. * @return The effect name
  107346. */
  107347. getEffectName(): string;
  107348. /**
  107349. * Create the merge effect. This is the shader use to blit the information back
  107350. * to the main canvas at the end of the scene rendering.
  107351. */
  107352. protected _createMergeEffect(): Effect;
  107353. /**
  107354. * Creates the render target textures and post processes used in the glow layer.
  107355. */
  107356. protected _createTextureAndPostProcesses(): void;
  107357. /**
  107358. * Checks for the readiness of the element composing the layer.
  107359. * @param subMesh the mesh to check for
  107360. * @param useInstances specify wether or not to use instances to render the mesh
  107361. * @param emissiveTexture the associated emissive texture used to generate the glow
  107362. * @return true if ready otherwise, false
  107363. */
  107364. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107365. /**
  107366. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107367. */
  107368. needStencil(): boolean;
  107369. /**
  107370. * Returns true if the mesh can be rendered, otherwise false.
  107371. * @param mesh The mesh to render
  107372. * @param material The material used on the mesh
  107373. * @returns true if it can be rendered otherwise false
  107374. */
  107375. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  107376. /**
  107377. * Implementation specific of rendering the generating effect on the main canvas.
  107378. * @param effect The effect used to render through
  107379. */
  107380. protected _internalRender(effect: Effect): void;
  107381. /**
  107382. * Sets the required values for both the emissive texture and and the main color.
  107383. */
  107384. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107385. /**
  107386. * Returns true if the mesh should render, otherwise false.
  107387. * @param mesh The mesh to render
  107388. * @returns true if it should render otherwise false
  107389. */
  107390. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107391. /**
  107392. * Adds specific effects defines.
  107393. * @param defines The defines to add specifics to.
  107394. */
  107395. protected _addCustomEffectDefines(defines: string[]): void;
  107396. /**
  107397. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  107398. * @param mesh The mesh to exclude from the glow layer
  107399. */
  107400. addExcludedMesh(mesh: Mesh): void;
  107401. /**
  107402. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  107403. * @param mesh The mesh to remove
  107404. */
  107405. removeExcludedMesh(mesh: Mesh): void;
  107406. /**
  107407. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  107408. * @param mesh The mesh to include in the glow layer
  107409. */
  107410. addIncludedOnlyMesh(mesh: Mesh): void;
  107411. /**
  107412. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  107413. * @param mesh The mesh to remove
  107414. */
  107415. removeIncludedOnlyMesh(mesh: Mesh): void;
  107416. /**
  107417. * Determine if a given mesh will be used in the glow layer
  107418. * @param mesh The mesh to test
  107419. * @returns true if the mesh will be highlighted by the current glow layer
  107420. */
  107421. hasMesh(mesh: AbstractMesh): boolean;
  107422. /**
  107423. * Free any resources and references associated to a mesh.
  107424. * Internal use
  107425. * @param mesh The mesh to free.
  107426. * @hidden
  107427. */
  107428. _disposeMesh(mesh: Mesh): void;
  107429. /**
  107430. * Gets the class name of the effect layer
  107431. * @returns the string with the class name of the effect layer
  107432. */
  107433. getClassName(): string;
  107434. /**
  107435. * Serializes this glow layer
  107436. * @returns a serialized glow layer object
  107437. */
  107438. serialize(): any;
  107439. /**
  107440. * Creates a Glow Layer from parsed glow layer data
  107441. * @param parsedGlowLayer defines glow layer data
  107442. * @param scene defines the current scene
  107443. * @param rootUrl defines the root URL containing the glow layer information
  107444. * @returns a parsed Glow Layer
  107445. */
  107446. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  107447. }
  107448. }
  107449. declare module BABYLON {
  107450. /** @hidden */
  107451. export var glowBlurPostProcessPixelShader: {
  107452. name: string;
  107453. shader: string;
  107454. };
  107455. }
  107456. declare module BABYLON {
  107457. interface AbstractScene {
  107458. /**
  107459. * Return a the first highlight layer of the scene with a given name.
  107460. * @param name The name of the highlight layer to look for.
  107461. * @return The highlight layer if found otherwise null.
  107462. */
  107463. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  107464. }
  107465. /**
  107466. * Highlight layer options. This helps customizing the behaviour
  107467. * of the highlight layer.
  107468. */
  107469. export interface IHighlightLayerOptions {
  107470. /**
  107471. * Multiplication factor apply to the canvas size to compute the render target size
  107472. * used to generated the glowing objects (the smaller the faster).
  107473. */
  107474. mainTextureRatio: number;
  107475. /**
  107476. * Enforces a fixed size texture to ensure resize independant blur.
  107477. */
  107478. mainTextureFixedSize?: number;
  107479. /**
  107480. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  107481. * of the picture to blur (the smaller the faster).
  107482. */
  107483. blurTextureSizeRatio: number;
  107484. /**
  107485. * How big in texel of the blur texture is the vertical blur.
  107486. */
  107487. blurVerticalSize: number;
  107488. /**
  107489. * How big in texel of the blur texture is the horizontal blur.
  107490. */
  107491. blurHorizontalSize: number;
  107492. /**
  107493. * Alpha blending mode used to apply the blur. Default is combine.
  107494. */
  107495. alphaBlendingMode: number;
  107496. /**
  107497. * The camera attached to the layer.
  107498. */
  107499. camera: Nullable<Camera>;
  107500. /**
  107501. * Should we display highlight as a solid stroke?
  107502. */
  107503. isStroke?: boolean;
  107504. /**
  107505. * The rendering group to draw the layer in.
  107506. */
  107507. renderingGroupId: number;
  107508. }
  107509. /**
  107510. * The highlight layer Helps adding a glow effect around a mesh.
  107511. *
  107512. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107513. * glowy meshes to your scene.
  107514. *
  107515. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  107516. */
  107517. export class HighlightLayer extends EffectLayer {
  107518. name: string;
  107519. /**
  107520. * Effect Name of the highlight layer.
  107521. */
  107522. static readonly EffectName: string;
  107523. /**
  107524. * The neutral color used during the preparation of the glow effect.
  107525. * This is black by default as the blend operation is a blend operation.
  107526. */
  107527. static NeutralColor: Color4;
  107528. /**
  107529. * Stencil value used for glowing meshes.
  107530. */
  107531. static GlowingMeshStencilReference: number;
  107532. /**
  107533. * Stencil value used for the other meshes in the scene.
  107534. */
  107535. static NormalMeshStencilReference: number;
  107536. /**
  107537. * Specifies whether or not the inner glow is ACTIVE in the layer.
  107538. */
  107539. innerGlow: boolean;
  107540. /**
  107541. * Specifies whether or not the outer glow is ACTIVE in the layer.
  107542. */
  107543. outerGlow: boolean;
  107544. /**
  107545. * Specifies the horizontal size of the blur.
  107546. */
  107547. /**
  107548. * Gets the horizontal size of the blur.
  107549. */
  107550. blurHorizontalSize: number;
  107551. /**
  107552. * Specifies the vertical size of the blur.
  107553. */
  107554. /**
  107555. * Gets the vertical size of the blur.
  107556. */
  107557. blurVerticalSize: number;
  107558. /**
  107559. * An event triggered when the highlight layer is being blurred.
  107560. */
  107561. onBeforeBlurObservable: Observable<HighlightLayer>;
  107562. /**
  107563. * An event triggered when the highlight layer has been blurred.
  107564. */
  107565. onAfterBlurObservable: Observable<HighlightLayer>;
  107566. private _instanceGlowingMeshStencilReference;
  107567. private _options;
  107568. private _downSamplePostprocess;
  107569. private _horizontalBlurPostprocess;
  107570. private _verticalBlurPostprocess;
  107571. private _blurTexture;
  107572. private _meshes;
  107573. private _excludedMeshes;
  107574. /**
  107575. * Instantiates a new highlight Layer and references it to the scene..
  107576. * @param name The name of the layer
  107577. * @param scene The scene to use the layer in
  107578. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  107579. */
  107580. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  107581. /**
  107582. * Get the effect name of the layer.
  107583. * @return The effect name
  107584. */
  107585. getEffectName(): string;
  107586. /**
  107587. * Create the merge effect. This is the shader use to blit the information back
  107588. * to the main canvas at the end of the scene rendering.
  107589. */
  107590. protected _createMergeEffect(): Effect;
  107591. /**
  107592. * Creates the render target textures and post processes used in the highlight layer.
  107593. */
  107594. protected _createTextureAndPostProcesses(): void;
  107595. /**
  107596. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107597. */
  107598. needStencil(): boolean;
  107599. /**
  107600. * Checks for the readiness of the element composing the layer.
  107601. * @param subMesh the mesh to check for
  107602. * @param useInstances specify wether or not to use instances to render the mesh
  107603. * @param emissiveTexture the associated emissive texture used to generate the glow
  107604. * @return true if ready otherwise, false
  107605. */
  107606. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107607. /**
  107608. * Implementation specific of rendering the generating effect on the main canvas.
  107609. * @param effect The effect used to render through
  107610. */
  107611. protected _internalRender(effect: Effect): void;
  107612. /**
  107613. * Returns true if the layer contains information to display, otherwise false.
  107614. */
  107615. shouldRender(): boolean;
  107616. /**
  107617. * Returns true if the mesh should render, otherwise false.
  107618. * @param mesh The mesh to render
  107619. * @returns true if it should render otherwise false
  107620. */
  107621. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107622. /**
  107623. * Sets the required values for both the emissive texture and and the main color.
  107624. */
  107625. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107626. /**
  107627. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  107628. * @param mesh The mesh to exclude from the highlight layer
  107629. */
  107630. addExcludedMesh(mesh: Mesh): void;
  107631. /**
  107632. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  107633. * @param mesh The mesh to highlight
  107634. */
  107635. removeExcludedMesh(mesh: Mesh): void;
  107636. /**
  107637. * Determine if a given mesh will be highlighted by the current HighlightLayer
  107638. * @param mesh mesh to test
  107639. * @returns true if the mesh will be highlighted by the current HighlightLayer
  107640. */
  107641. hasMesh(mesh: AbstractMesh): boolean;
  107642. /**
  107643. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  107644. * @param mesh The mesh to highlight
  107645. * @param color The color of the highlight
  107646. * @param glowEmissiveOnly Extract the glow from the emissive texture
  107647. */
  107648. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  107649. /**
  107650. * Remove a mesh from the highlight layer in order to make it stop glowing.
  107651. * @param mesh The mesh to highlight
  107652. */
  107653. removeMesh(mesh: Mesh): void;
  107654. /**
  107655. * Force the stencil to the normal expected value for none glowing parts
  107656. */
  107657. private _defaultStencilReference;
  107658. /**
  107659. * Free any resources and references associated to a mesh.
  107660. * Internal use
  107661. * @param mesh The mesh to free.
  107662. * @hidden
  107663. */
  107664. _disposeMesh(mesh: Mesh): void;
  107665. /**
  107666. * Dispose the highlight layer and free resources.
  107667. */
  107668. dispose(): void;
  107669. /**
  107670. * Gets the class name of the effect layer
  107671. * @returns the string with the class name of the effect layer
  107672. */
  107673. getClassName(): string;
  107674. /**
  107675. * Serializes this Highlight layer
  107676. * @returns a serialized Highlight layer object
  107677. */
  107678. serialize(): any;
  107679. /**
  107680. * Creates a Highlight layer from parsed Highlight layer data
  107681. * @param parsedHightlightLayer defines the Highlight layer data
  107682. * @param scene defines the current scene
  107683. * @param rootUrl defines the root URL containing the Highlight layer information
  107684. * @returns a parsed Highlight layer
  107685. */
  107686. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  107687. }
  107688. }
  107689. declare module BABYLON {
  107690. /** @hidden */
  107691. export var lensFlarePixelShader: {
  107692. name: string;
  107693. shader: string;
  107694. };
  107695. }
  107696. declare module BABYLON {
  107697. /** @hidden */
  107698. export var lensFlareVertexShader: {
  107699. name: string;
  107700. shader: string;
  107701. };
  107702. }
  107703. declare module BABYLON {
  107704. /**
  107705. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107706. * It is usually composed of several `lensFlare`.
  107707. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107708. */
  107709. export class LensFlareSystem {
  107710. /**
  107711. * Define the name of the lens flare system
  107712. */
  107713. name: string;
  107714. /**
  107715. * List of lens flares used in this system.
  107716. */
  107717. lensFlares: LensFlare[];
  107718. /**
  107719. * Define a limit from the border the lens flare can be visible.
  107720. */
  107721. borderLimit: number;
  107722. /**
  107723. * Define a viewport border we do not want to see the lens flare in.
  107724. */
  107725. viewportBorder: number;
  107726. /**
  107727. * Define a predicate which could limit the list of meshes able to occlude the effect.
  107728. */
  107729. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107730. /**
  107731. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  107732. */
  107733. layerMask: number;
  107734. /**
  107735. * Define the id of the lens flare system in the scene.
  107736. * (equal to name by default)
  107737. */
  107738. id: string;
  107739. private _scene;
  107740. private _emitter;
  107741. private _vertexBuffers;
  107742. private _indexBuffer;
  107743. private _effect;
  107744. private _positionX;
  107745. private _positionY;
  107746. private _isEnabled;
  107747. /** @hidden */
  107748. static _SceneComponentInitialization: (scene: Scene) => void;
  107749. /**
  107750. * Instantiates a lens flare system.
  107751. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107752. * It is usually composed of several `lensFlare`.
  107753. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107754. * @param name Define the name of the lens flare system in the scene
  107755. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  107756. * @param scene Define the scene the lens flare system belongs to
  107757. */
  107758. constructor(
  107759. /**
  107760. * Define the name of the lens flare system
  107761. */
  107762. name: string, emitter: any, scene: Scene);
  107763. /**
  107764. * Define if the lens flare system is enabled.
  107765. */
  107766. isEnabled: boolean;
  107767. /**
  107768. * Get the scene the effects belongs to.
  107769. * @returns the scene holding the lens flare system
  107770. */
  107771. getScene(): Scene;
  107772. /**
  107773. * Get the emitter of the lens flare system.
  107774. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107775. * @returns the emitter of the lens flare system
  107776. */
  107777. getEmitter(): any;
  107778. /**
  107779. * Set the emitter of the lens flare system.
  107780. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107781. * @param newEmitter Define the new emitter of the system
  107782. */
  107783. setEmitter(newEmitter: any): void;
  107784. /**
  107785. * Get the lens flare system emitter position.
  107786. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  107787. * @returns the position
  107788. */
  107789. getEmitterPosition(): Vector3;
  107790. /**
  107791. * @hidden
  107792. */
  107793. computeEffectivePosition(globalViewport: Viewport): boolean;
  107794. /** @hidden */
  107795. _isVisible(): boolean;
  107796. /**
  107797. * @hidden
  107798. */
  107799. render(): boolean;
  107800. /**
  107801. * Dispose and release the lens flare with its associated resources.
  107802. */
  107803. dispose(): void;
  107804. /**
  107805. * Parse a lens flare system from a JSON repressentation
  107806. * @param parsedLensFlareSystem Define the JSON to parse
  107807. * @param scene Define the scene the parsed system should be instantiated in
  107808. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  107809. * @returns the parsed system
  107810. */
  107811. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  107812. /**
  107813. * Serialize the current Lens Flare System into a JSON representation.
  107814. * @returns the serialized JSON
  107815. */
  107816. serialize(): any;
  107817. }
  107818. }
  107819. declare module BABYLON {
  107820. /**
  107821. * This represents one of the lens effect in a `lensFlareSystem`.
  107822. * It controls one of the indiviual texture used in the effect.
  107823. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107824. */
  107825. export class LensFlare {
  107826. /**
  107827. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107828. */
  107829. size: number;
  107830. /**
  107831. * 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.
  107832. */
  107833. position: number;
  107834. /**
  107835. * Define the lens color.
  107836. */
  107837. color: Color3;
  107838. /**
  107839. * Define the lens texture.
  107840. */
  107841. texture: Nullable<Texture>;
  107842. /**
  107843. * Define the alpha mode to render this particular lens.
  107844. */
  107845. alphaMode: number;
  107846. private _system;
  107847. /**
  107848. * Creates a new Lens Flare.
  107849. * This represents one of the lens effect in a `lensFlareSystem`.
  107850. * It controls one of the indiviual texture used in the effect.
  107851. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107852. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  107853. * @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.
  107854. * @param color Define the lens color
  107855. * @param imgUrl Define the lens texture url
  107856. * @param system Define the `lensFlareSystem` this flare is part of
  107857. * @returns The newly created Lens Flare
  107858. */
  107859. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  107860. /**
  107861. * Instantiates a new Lens Flare.
  107862. * This represents one of the lens effect in a `lensFlareSystem`.
  107863. * It controls one of the indiviual texture used in the effect.
  107864. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107865. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  107866. * @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.
  107867. * @param color Define the lens color
  107868. * @param imgUrl Define the lens texture url
  107869. * @param system Define the `lensFlareSystem` this flare is part of
  107870. */
  107871. constructor(
  107872. /**
  107873. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107874. */
  107875. size: number,
  107876. /**
  107877. * 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.
  107878. */
  107879. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  107880. /**
  107881. * Dispose and release the lens flare with its associated resources.
  107882. */
  107883. dispose(): void;
  107884. }
  107885. }
  107886. declare module BABYLON {
  107887. interface AbstractScene {
  107888. /**
  107889. * The list of lens flare system added to the scene
  107890. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107891. */
  107892. lensFlareSystems: Array<LensFlareSystem>;
  107893. /**
  107894. * Removes the given lens flare system from this scene.
  107895. * @param toRemove The lens flare system to remove
  107896. * @returns The index of the removed lens flare system
  107897. */
  107898. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  107899. /**
  107900. * Adds the given lens flare system to this scene
  107901. * @param newLensFlareSystem The lens flare system to add
  107902. */
  107903. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  107904. /**
  107905. * Gets a lens flare system using its name
  107906. * @param name defines the name to look for
  107907. * @returns the lens flare system or null if not found
  107908. */
  107909. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  107910. /**
  107911. * Gets a lens flare system using its id
  107912. * @param id defines the id to look for
  107913. * @returns the lens flare system or null if not found
  107914. */
  107915. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  107916. }
  107917. /**
  107918. * Defines the lens flare scene component responsible to manage any lens flares
  107919. * in a given scene.
  107920. */
  107921. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  107922. /**
  107923. * The component name helpfull to identify the component in the list of scene components.
  107924. */
  107925. readonly name: string;
  107926. /**
  107927. * The scene the component belongs to.
  107928. */
  107929. scene: Scene;
  107930. /**
  107931. * Creates a new instance of the component for the given scene
  107932. * @param scene Defines the scene to register the component in
  107933. */
  107934. constructor(scene: Scene);
  107935. /**
  107936. * Registers the component in a given scene
  107937. */
  107938. register(): void;
  107939. /**
  107940. * Rebuilds the elements related to this component in case of
  107941. * context lost for instance.
  107942. */
  107943. rebuild(): void;
  107944. /**
  107945. * Adds all the element from the container to the scene
  107946. * @param container the container holding the elements
  107947. */
  107948. addFromContainer(container: AbstractScene): void;
  107949. /**
  107950. * Removes all the elements in the container from the scene
  107951. * @param container contains the elements to remove
  107952. * @param dispose if the removed element should be disposed (default: false)
  107953. */
  107954. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107955. /**
  107956. * Serializes the component data to the specified json object
  107957. * @param serializationObject The object to serialize to
  107958. */
  107959. serialize(serializationObject: any): void;
  107960. /**
  107961. * Disposes the component and the associated ressources.
  107962. */
  107963. dispose(): void;
  107964. private _draw;
  107965. }
  107966. }
  107967. declare module BABYLON {
  107968. /**
  107969. * Defines the shadow generator component responsible to manage any shadow generators
  107970. * in a given scene.
  107971. */
  107972. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  107973. /**
  107974. * The component name helpfull to identify the component in the list of scene components.
  107975. */
  107976. readonly name: string;
  107977. /**
  107978. * The scene the component belongs to.
  107979. */
  107980. scene: Scene;
  107981. /**
  107982. * Creates a new instance of the component for the given scene
  107983. * @param scene Defines the scene to register the component in
  107984. */
  107985. constructor(scene: Scene);
  107986. /**
  107987. * Registers the component in a given scene
  107988. */
  107989. register(): void;
  107990. /**
  107991. * Rebuilds the elements related to this component in case of
  107992. * context lost for instance.
  107993. */
  107994. rebuild(): void;
  107995. /**
  107996. * Serializes the component data to the specified json object
  107997. * @param serializationObject The object to serialize to
  107998. */
  107999. serialize(serializationObject: any): void;
  108000. /**
  108001. * Adds all the element from the container to the scene
  108002. * @param container the container holding the elements
  108003. */
  108004. addFromContainer(container: AbstractScene): void;
  108005. /**
  108006. * Removes all the elements in the container from the scene
  108007. * @param container contains the elements to remove
  108008. * @param dispose if the removed element should be disposed (default: false)
  108009. */
  108010. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  108011. /**
  108012. * Rebuilds the elements related to this component in case of
  108013. * context lost for instance.
  108014. */
  108015. dispose(): void;
  108016. private _gatherRenderTargets;
  108017. }
  108018. }
  108019. declare module BABYLON {
  108020. /**
  108021. * A point light is a light defined by an unique point in world space.
  108022. * The light is emitted in every direction from this point.
  108023. * A good example of a point light is a standard light bulb.
  108024. * Documentation: https://doc.babylonjs.com/babylon101/lights
  108025. */
  108026. export class PointLight extends ShadowLight {
  108027. private _shadowAngle;
  108028. /**
  108029. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  108030. * This specifies what angle the shadow will use to be created.
  108031. *
  108032. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  108033. */
  108034. /**
  108035. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  108036. * This specifies what angle the shadow will use to be created.
  108037. *
  108038. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  108039. */
  108040. shadowAngle: number;
  108041. /**
  108042. * Gets the direction if it has been set.
  108043. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  108044. */
  108045. /**
  108046. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  108047. */
  108048. direction: Vector3;
  108049. /**
  108050. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  108051. * A PointLight emits the light in every direction.
  108052. * It can cast shadows.
  108053. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  108054. * ```javascript
  108055. * var pointLight = new PointLight("pl", camera.position, scene);
  108056. * ```
  108057. * Documentation : https://doc.babylonjs.com/babylon101/lights
  108058. * @param name The light friendly name
  108059. * @param position The position of the point light in the scene
  108060. * @param scene The scene the lights belongs to
  108061. */
  108062. constructor(name: string, position: Vector3, scene: Scene);
  108063. /**
  108064. * Returns the string "PointLight"
  108065. * @returns the class name
  108066. */
  108067. getClassName(): string;
  108068. /**
  108069. * Returns the integer 0.
  108070. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108071. */
  108072. getTypeID(): number;
  108073. /**
  108074. * Specifies wether or not the shadowmap should be a cube texture.
  108075. * @returns true if the shadowmap needs to be a cube texture.
  108076. */
  108077. needCube(): boolean;
  108078. /**
  108079. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  108080. * @param faceIndex The index of the face we are computed the direction to generate shadow
  108081. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  108082. */
  108083. getShadowDirection(faceIndex?: number): Vector3;
  108084. /**
  108085. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  108086. * - fov = PI / 2
  108087. * - aspect ratio : 1.0
  108088. * - z-near and far equal to the active camera minZ and maxZ.
  108089. * Returns the PointLight.
  108090. */
  108091. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108092. protected _buildUniformLayout(): void;
  108093. /**
  108094. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  108095. * @param effect The effect to update
  108096. * @param lightIndex The index of the light in the effect to update
  108097. * @returns The point light
  108098. */
  108099. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  108100. /**
  108101. * Prepares the list of defines specific to the light type.
  108102. * @param defines the list of defines
  108103. * @param lightIndex defines the index of the light for the effect
  108104. */
  108105. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108106. }
  108107. }
  108108. declare module BABYLON {
  108109. /**
  108110. * Header information of HDR texture files.
  108111. */
  108112. export interface HDRInfo {
  108113. /**
  108114. * The height of the texture in pixels.
  108115. */
  108116. height: number;
  108117. /**
  108118. * The width of the texture in pixels.
  108119. */
  108120. width: number;
  108121. /**
  108122. * The index of the beginning of the data in the binary file.
  108123. */
  108124. dataPosition: number;
  108125. }
  108126. /**
  108127. * This groups tools to convert HDR texture to native colors array.
  108128. */
  108129. export class HDRTools {
  108130. private static Ldexp;
  108131. private static Rgbe2float;
  108132. private static readStringLine;
  108133. /**
  108134. * Reads header information from an RGBE texture stored in a native array.
  108135. * More information on this format are available here:
  108136. * https://en.wikipedia.org/wiki/RGBE_image_format
  108137. *
  108138. * @param uint8array The binary file stored in native array.
  108139. * @return The header information.
  108140. */
  108141. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  108142. /**
  108143. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  108144. * This RGBE texture needs to store the information as a panorama.
  108145. *
  108146. * More information on this format are available here:
  108147. * https://en.wikipedia.org/wiki/RGBE_image_format
  108148. *
  108149. * @param buffer The binary file stored in an array buffer.
  108150. * @param size The expected size of the extracted cubemap.
  108151. * @return The Cube Map information.
  108152. */
  108153. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  108154. /**
  108155. * Returns the pixels data extracted from an RGBE texture.
  108156. * This pixels will be stored left to right up to down in the R G B order in one array.
  108157. *
  108158. * More information on this format are available here:
  108159. * https://en.wikipedia.org/wiki/RGBE_image_format
  108160. *
  108161. * @param uint8array The binary file stored in an array buffer.
  108162. * @param hdrInfo The header information of the file.
  108163. * @return The pixels data in RGB right to left up to down order.
  108164. */
  108165. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  108166. private static RGBE_ReadPixels_RLE;
  108167. }
  108168. }
  108169. declare module BABYLON {
  108170. /**
  108171. * This represents a texture coming from an HDR input.
  108172. *
  108173. * The only supported format is currently panorama picture stored in RGBE format.
  108174. * Example of such files can be found on HDRLib: http://hdrlib.com/
  108175. */
  108176. export class HDRCubeTexture extends BaseTexture {
  108177. private static _facesMapping;
  108178. private _generateHarmonics;
  108179. private _noMipmap;
  108180. private _textureMatrix;
  108181. private _size;
  108182. private _onLoad;
  108183. private _onError;
  108184. /**
  108185. * The texture URL.
  108186. */
  108187. url: string;
  108188. /**
  108189. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  108190. */
  108191. coordinatesMode: number;
  108192. protected _isBlocking: boolean;
  108193. /**
  108194. * Sets wether or not the texture is blocking during loading.
  108195. */
  108196. /**
  108197. * Gets wether or not the texture is blocking during loading.
  108198. */
  108199. isBlocking: boolean;
  108200. protected _rotationY: number;
  108201. /**
  108202. * Sets texture matrix rotation angle around Y axis in radians.
  108203. */
  108204. /**
  108205. * Gets texture matrix rotation angle around Y axis radians.
  108206. */
  108207. rotationY: number;
  108208. /**
  108209. * Gets or sets the center of the bounding box associated with the cube texture
  108210. * It must define where the camera used to render the texture was set
  108211. */
  108212. boundingBoxPosition: Vector3;
  108213. private _boundingBoxSize;
  108214. /**
  108215. * Gets or sets the size of the bounding box associated with the cube texture
  108216. * When defined, the cubemap will switch to local mode
  108217. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  108218. * @example https://www.babylonjs-playground.com/#RNASML
  108219. */
  108220. boundingBoxSize: Vector3;
  108221. /**
  108222. * Instantiates an HDRTexture from the following parameters.
  108223. *
  108224. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  108225. * @param scene The scene the texture will be used in
  108226. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108227. * @param noMipmap Forces to not generate the mipmap if true
  108228. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  108229. * @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)
  108230. * @param reserved Reserved flag for internal use.
  108231. */
  108232. 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>);
  108233. /**
  108234. * Get the current class name of the texture useful for serialization or dynamic coding.
  108235. * @returns "HDRCubeTexture"
  108236. */
  108237. getClassName(): string;
  108238. /**
  108239. * Occurs when the file is raw .hdr file.
  108240. */
  108241. private loadTexture;
  108242. clone(): HDRCubeTexture;
  108243. delayLoad(): void;
  108244. /**
  108245. * Get the texture reflection matrix used to rotate/transform the reflection.
  108246. * @returns the reflection matrix
  108247. */
  108248. getReflectionTextureMatrix(): Matrix;
  108249. /**
  108250. * Set the texture reflection matrix used to rotate/transform the reflection.
  108251. * @param value Define the reflection matrix to set
  108252. */
  108253. setReflectionTextureMatrix(value: Matrix): void;
  108254. /**
  108255. * Parses a JSON representation of an HDR Texture in order to create the texture
  108256. * @param parsedTexture Define the JSON representation
  108257. * @param scene Define the scene the texture should be created in
  108258. * @param rootUrl Define the root url in case we need to load relative dependencies
  108259. * @returns the newly created texture after parsing
  108260. */
  108261. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  108262. serialize(): any;
  108263. }
  108264. }
  108265. declare module BABYLON {
  108266. /**
  108267. * Class used to control physics engine
  108268. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  108269. */
  108270. export class PhysicsEngine implements IPhysicsEngine {
  108271. private _physicsPlugin;
  108272. /**
  108273. * Global value used to control the smallest number supported by the simulation
  108274. */
  108275. static Epsilon: number;
  108276. private _impostors;
  108277. private _joints;
  108278. /**
  108279. * Gets the gravity vector used by the simulation
  108280. */
  108281. gravity: Vector3;
  108282. /**
  108283. * Factory used to create the default physics plugin.
  108284. * @returns The default physics plugin
  108285. */
  108286. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  108287. /**
  108288. * Creates a new Physics Engine
  108289. * @param gravity defines the gravity vector used by the simulation
  108290. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  108291. */
  108292. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  108293. /**
  108294. * Sets the gravity vector used by the simulation
  108295. * @param gravity defines the gravity vector to use
  108296. */
  108297. setGravity(gravity: Vector3): void;
  108298. /**
  108299. * Set the time step of the physics engine.
  108300. * Default is 1/60.
  108301. * To slow it down, enter 1/600 for example.
  108302. * To speed it up, 1/30
  108303. * @param newTimeStep defines the new timestep to apply to this world.
  108304. */
  108305. setTimeStep(newTimeStep?: number): void;
  108306. /**
  108307. * Get the time step of the physics engine.
  108308. * @returns the current time step
  108309. */
  108310. getTimeStep(): number;
  108311. /**
  108312. * Release all resources
  108313. */
  108314. dispose(): void;
  108315. /**
  108316. * Gets the name of the current physics plugin
  108317. * @returns the name of the plugin
  108318. */
  108319. getPhysicsPluginName(): string;
  108320. /**
  108321. * Adding a new impostor for the impostor tracking.
  108322. * This will be done by the impostor itself.
  108323. * @param impostor the impostor to add
  108324. */
  108325. addImpostor(impostor: PhysicsImpostor): void;
  108326. /**
  108327. * Remove an impostor from the engine.
  108328. * This impostor and its mesh will not longer be updated by the physics engine.
  108329. * @param impostor the impostor to remove
  108330. */
  108331. removeImpostor(impostor: PhysicsImpostor): void;
  108332. /**
  108333. * Add a joint to the physics engine
  108334. * @param mainImpostor defines the main impostor to which the joint is added.
  108335. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  108336. * @param joint defines the joint that will connect both impostors.
  108337. */
  108338. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108339. /**
  108340. * Removes a joint from the simulation
  108341. * @param mainImpostor defines the impostor used with the joint
  108342. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  108343. * @param joint defines the joint to remove
  108344. */
  108345. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108346. /**
  108347. * Called by the scene. No need to call it.
  108348. * @param delta defines the timespam between frames
  108349. */
  108350. _step(delta: number): void;
  108351. /**
  108352. * Gets the current plugin used to run the simulation
  108353. * @returns current plugin
  108354. */
  108355. getPhysicsPlugin(): IPhysicsEnginePlugin;
  108356. /**
  108357. * Gets the list of physic impostors
  108358. * @returns an array of PhysicsImpostor
  108359. */
  108360. getImpostors(): Array<PhysicsImpostor>;
  108361. /**
  108362. * Gets the impostor for a physics enabled object
  108363. * @param object defines the object impersonated by the impostor
  108364. * @returns the PhysicsImpostor or null if not found
  108365. */
  108366. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108367. /**
  108368. * Gets the impostor for a physics body object
  108369. * @param body defines physics body used by the impostor
  108370. * @returns the PhysicsImpostor or null if not found
  108371. */
  108372. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  108373. /**
  108374. * Does a raycast in the physics world
  108375. * @param from when should the ray start?
  108376. * @param to when should the ray end?
  108377. * @returns PhysicsRaycastResult
  108378. */
  108379. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108380. }
  108381. }
  108382. declare module BABYLON {
  108383. /** @hidden */
  108384. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  108385. private _useDeltaForWorldStep;
  108386. world: any;
  108387. name: string;
  108388. private _physicsMaterials;
  108389. private _fixedTimeStep;
  108390. private _cannonRaycastResult;
  108391. private _raycastResult;
  108392. private _removeAfterStep;
  108393. BJSCANNON: any;
  108394. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  108395. setGravity(gravity: Vector3): void;
  108396. setTimeStep(timeStep: number): void;
  108397. getTimeStep(): number;
  108398. executeStep(delta: number): void;
  108399. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108400. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108401. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108402. private _processChildMeshes;
  108403. removePhysicsBody(impostor: PhysicsImpostor): void;
  108404. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108405. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108406. private _addMaterial;
  108407. private _checkWithEpsilon;
  108408. private _createShape;
  108409. private _createHeightmap;
  108410. private _minus90X;
  108411. private _plus90X;
  108412. private _tmpPosition;
  108413. private _tmpDeltaPosition;
  108414. private _tmpUnityRotation;
  108415. private _updatePhysicsBodyTransformation;
  108416. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108417. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108418. isSupported(): boolean;
  108419. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108420. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108421. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108422. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108423. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108424. getBodyMass(impostor: PhysicsImpostor): number;
  108425. getBodyFriction(impostor: PhysicsImpostor): number;
  108426. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108427. getBodyRestitution(impostor: PhysicsImpostor): number;
  108428. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108429. sleepBody(impostor: PhysicsImpostor): void;
  108430. wakeUpBody(impostor: PhysicsImpostor): void;
  108431. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  108432. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108433. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108434. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108435. getRadius(impostor: PhysicsImpostor): number;
  108436. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108437. dispose(): void;
  108438. private _extendNamespace;
  108439. /**
  108440. * Does a raycast in the physics world
  108441. * @param from when should the ray start?
  108442. * @param to when should the ray end?
  108443. * @returns PhysicsRaycastResult
  108444. */
  108445. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108446. }
  108447. }
  108448. declare module BABYLON {
  108449. /** @hidden */
  108450. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  108451. world: any;
  108452. name: string;
  108453. BJSOIMO: any;
  108454. private _raycastResult;
  108455. constructor(iterations?: number, oimoInjection?: any);
  108456. setGravity(gravity: Vector3): void;
  108457. setTimeStep(timeStep: number): void;
  108458. getTimeStep(): number;
  108459. private _tmpImpostorsArray;
  108460. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108461. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108462. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108463. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108464. private _tmpPositionVector;
  108465. removePhysicsBody(impostor: PhysicsImpostor): void;
  108466. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108467. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108468. isSupported(): boolean;
  108469. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108470. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108471. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108472. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108473. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108474. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108475. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108476. getBodyMass(impostor: PhysicsImpostor): number;
  108477. getBodyFriction(impostor: PhysicsImpostor): number;
  108478. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108479. getBodyRestitution(impostor: PhysicsImpostor): number;
  108480. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108481. sleepBody(impostor: PhysicsImpostor): void;
  108482. wakeUpBody(impostor: PhysicsImpostor): void;
  108483. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108484. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  108485. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  108486. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108487. getRadius(impostor: PhysicsImpostor): number;
  108488. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108489. dispose(): void;
  108490. /**
  108491. * Does a raycast in the physics world
  108492. * @param from when should the ray start?
  108493. * @param to when should the ray end?
  108494. * @returns PhysicsRaycastResult
  108495. */
  108496. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108497. }
  108498. }
  108499. declare module BABYLON {
  108500. /**
  108501. * Class containing static functions to help procedurally build meshes
  108502. */
  108503. export class RibbonBuilder {
  108504. /**
  108505. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108506. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  108507. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  108508. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  108509. * * 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
  108510. * * 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
  108511. * * 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
  108512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108513. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108514. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108515. * * 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
  108516. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  108517. * * 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
  108518. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  108519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108520. * @param name defines the name of the mesh
  108521. * @param options defines the options used to create the mesh
  108522. * @param scene defines the hosting scene
  108523. * @returns the ribbon mesh
  108524. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  108525. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108526. */
  108527. static CreateRibbon(name: string, options: {
  108528. pathArray: Vector3[][];
  108529. closeArray?: boolean;
  108530. closePath?: boolean;
  108531. offset?: number;
  108532. updatable?: boolean;
  108533. sideOrientation?: number;
  108534. frontUVs?: Vector4;
  108535. backUVs?: Vector4;
  108536. instance?: Mesh;
  108537. invertUV?: boolean;
  108538. uvs?: Vector2[];
  108539. colors?: Color4[];
  108540. }, scene?: Nullable<Scene>): Mesh;
  108541. }
  108542. }
  108543. declare module BABYLON {
  108544. /**
  108545. * Class containing static functions to help procedurally build meshes
  108546. */
  108547. export class ShapeBuilder {
  108548. /**
  108549. * 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.
  108550. * * 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.
  108551. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108552. * * 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.
  108553. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  108554. * * 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
  108555. * * 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
  108556. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  108557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108558. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108559. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  108560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108561. * @param name defines the name of the mesh
  108562. * @param options defines the options used to create the mesh
  108563. * @param scene defines the hosting scene
  108564. * @returns the extruded shape mesh
  108565. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108566. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108567. */
  108568. static ExtrudeShape(name: string, options: {
  108569. shape: Vector3[];
  108570. path: Vector3[];
  108571. scale?: number;
  108572. rotation?: number;
  108573. cap?: number;
  108574. updatable?: boolean;
  108575. sideOrientation?: number;
  108576. frontUVs?: Vector4;
  108577. backUVs?: Vector4;
  108578. instance?: Mesh;
  108579. invertUV?: boolean;
  108580. }, scene?: Nullable<Scene>): Mesh;
  108581. /**
  108582. * Creates an custom extruded shape mesh.
  108583. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  108584. * * 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.
  108585. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108586. * * 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
  108587. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  108588. * * 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
  108589. * * It must returns a float value that will be the scale value applied to the shape on each path point
  108590. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108591. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  108592. * * 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
  108593. * * 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
  108594. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  108595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108597. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108599. * @param name defines the name of the mesh
  108600. * @param options defines the options used to create the mesh
  108601. * @param scene defines the hosting scene
  108602. * @returns the custom extruded shape mesh
  108603. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  108604. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108605. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108606. */
  108607. static ExtrudeShapeCustom(name: string, options: {
  108608. shape: Vector3[];
  108609. path: Vector3[];
  108610. scaleFunction?: any;
  108611. rotationFunction?: any;
  108612. ribbonCloseArray?: boolean;
  108613. ribbonClosePath?: boolean;
  108614. cap?: number;
  108615. updatable?: boolean;
  108616. sideOrientation?: number;
  108617. frontUVs?: Vector4;
  108618. backUVs?: Vector4;
  108619. instance?: Mesh;
  108620. invertUV?: boolean;
  108621. }, scene?: Nullable<Scene>): Mesh;
  108622. private static _ExtrudeShapeGeneric;
  108623. }
  108624. }
  108625. declare module BABYLON {
  108626. /**
  108627. * AmmoJS Physics plugin
  108628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108629. * @see https://github.com/kripken/ammo.js/
  108630. */
  108631. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  108632. private _useDeltaForWorldStep;
  108633. /**
  108634. * Reference to the Ammo library
  108635. */
  108636. bjsAMMO: any;
  108637. /**
  108638. * Created ammoJS world which physics bodies are added to
  108639. */
  108640. world: any;
  108641. /**
  108642. * Name of the plugin
  108643. */
  108644. name: string;
  108645. private _timeStep;
  108646. private _fixedTimeStep;
  108647. private _maxSteps;
  108648. private _tmpQuaternion;
  108649. private _tmpAmmoTransform;
  108650. private _tmpAmmoQuaternion;
  108651. private _tmpAmmoConcreteContactResultCallback;
  108652. private _collisionConfiguration;
  108653. private _dispatcher;
  108654. private _overlappingPairCache;
  108655. private _solver;
  108656. private _softBodySolver;
  108657. private _tmpAmmoVectorA;
  108658. private _tmpAmmoVectorB;
  108659. private _tmpAmmoVectorC;
  108660. private _tmpAmmoVectorD;
  108661. private _tmpContactCallbackResult;
  108662. private _tmpAmmoVectorRCA;
  108663. private _tmpAmmoVectorRCB;
  108664. private _raycastResult;
  108665. private static readonly DISABLE_COLLISION_FLAG;
  108666. private static readonly KINEMATIC_FLAG;
  108667. private static readonly DISABLE_DEACTIVATION_FLAG;
  108668. /**
  108669. * Initializes the ammoJS plugin
  108670. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  108671. * @param ammoInjection can be used to inject your own ammo reference
  108672. */
  108673. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  108674. /**
  108675. * Sets the gravity of the physics world (m/(s^2))
  108676. * @param gravity Gravity to set
  108677. */
  108678. setGravity(gravity: Vector3): void;
  108679. /**
  108680. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  108681. * @param timeStep timestep to use in seconds
  108682. */
  108683. setTimeStep(timeStep: number): void;
  108684. /**
  108685. * 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)
  108686. * @param fixedTimeStep fixedTimeStep to use in seconds
  108687. */
  108688. setFixedTimeStep(fixedTimeStep: number): void;
  108689. /**
  108690. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  108691. * @param maxSteps the maximum number of steps by the physics engine per frame
  108692. */
  108693. setMaxSteps(maxSteps: number): void;
  108694. /**
  108695. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  108696. * @returns the current timestep in seconds
  108697. */
  108698. getTimeStep(): number;
  108699. private _isImpostorInContact;
  108700. private _isImpostorPairInContact;
  108701. private _stepSimulation;
  108702. /**
  108703. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  108704. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  108705. * After the step the babylon meshes are set to the position of the physics imposters
  108706. * @param delta amount of time to step forward
  108707. * @param impostors array of imposters to update before/after the step
  108708. */
  108709. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108710. /**
  108711. * Update babylon mesh to match physics world object
  108712. * @param impostor imposter to match
  108713. */
  108714. private _afterSoftStep;
  108715. /**
  108716. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108717. * @param impostor imposter to match
  108718. */
  108719. private _ropeStep;
  108720. /**
  108721. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108722. * @param impostor imposter to match
  108723. */
  108724. private _softbodyOrClothStep;
  108725. private _tmpVector;
  108726. private _tmpMatrix;
  108727. /**
  108728. * Applies an impulse on the imposter
  108729. * @param impostor imposter to apply impulse to
  108730. * @param force amount of force to be applied to the imposter
  108731. * @param contactPoint the location to apply the impulse on the imposter
  108732. */
  108733. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108734. /**
  108735. * Applies a force on the imposter
  108736. * @param impostor imposter to apply force
  108737. * @param force amount of force to be applied to the imposter
  108738. * @param contactPoint the location to apply the force on the imposter
  108739. */
  108740. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108741. /**
  108742. * Creates a physics body using the plugin
  108743. * @param impostor the imposter to create the physics body on
  108744. */
  108745. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108746. /**
  108747. * Removes the physics body from the imposter and disposes of the body's memory
  108748. * @param impostor imposter to remove the physics body from
  108749. */
  108750. removePhysicsBody(impostor: PhysicsImpostor): void;
  108751. /**
  108752. * Generates a joint
  108753. * @param impostorJoint the imposter joint to create the joint with
  108754. */
  108755. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108756. /**
  108757. * Removes a joint
  108758. * @param impostorJoint the imposter joint to remove the joint from
  108759. */
  108760. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108761. private _addMeshVerts;
  108762. /**
  108763. * Initialise the soft body vertices to match its object's (mesh) vertices
  108764. * Softbody vertices (nodes) are in world space and to match this
  108765. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  108766. * @param impostor to create the softbody for
  108767. */
  108768. private _softVertexData;
  108769. /**
  108770. * Create an impostor's soft body
  108771. * @param impostor to create the softbody for
  108772. */
  108773. private _createSoftbody;
  108774. /**
  108775. * Create cloth for an impostor
  108776. * @param impostor to create the softbody for
  108777. */
  108778. private _createCloth;
  108779. /**
  108780. * Create rope for an impostor
  108781. * @param impostor to create the softbody for
  108782. */
  108783. private _createRope;
  108784. private _addHullVerts;
  108785. private _createShape;
  108786. /**
  108787. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108788. * @param impostor imposter containing the physics body and babylon object
  108789. */
  108790. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108791. /**
  108792. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108793. * @param impostor imposter containing the physics body and babylon object
  108794. * @param newPosition new position
  108795. * @param newRotation new rotation
  108796. */
  108797. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108798. /**
  108799. * If this plugin is supported
  108800. * @returns true if its supported
  108801. */
  108802. isSupported(): boolean;
  108803. /**
  108804. * Sets the linear velocity of the physics body
  108805. * @param impostor imposter to set the velocity on
  108806. * @param velocity velocity to set
  108807. */
  108808. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108809. /**
  108810. * Sets the angular velocity of the physics body
  108811. * @param impostor imposter to set the velocity on
  108812. * @param velocity velocity to set
  108813. */
  108814. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108815. /**
  108816. * gets the linear velocity
  108817. * @param impostor imposter to get linear velocity from
  108818. * @returns linear velocity
  108819. */
  108820. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108821. /**
  108822. * gets the angular velocity
  108823. * @param impostor imposter to get angular velocity from
  108824. * @returns angular velocity
  108825. */
  108826. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108827. /**
  108828. * Sets the mass of physics body
  108829. * @param impostor imposter to set the mass on
  108830. * @param mass mass to set
  108831. */
  108832. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108833. /**
  108834. * Gets the mass of the physics body
  108835. * @param impostor imposter to get the mass from
  108836. * @returns mass
  108837. */
  108838. getBodyMass(impostor: PhysicsImpostor): number;
  108839. /**
  108840. * Gets friction of the impostor
  108841. * @param impostor impostor to get friction from
  108842. * @returns friction value
  108843. */
  108844. getBodyFriction(impostor: PhysicsImpostor): number;
  108845. /**
  108846. * Sets friction of the impostor
  108847. * @param impostor impostor to set friction on
  108848. * @param friction friction value
  108849. */
  108850. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108851. /**
  108852. * Gets restitution of the impostor
  108853. * @param impostor impostor to get restitution from
  108854. * @returns restitution value
  108855. */
  108856. getBodyRestitution(impostor: PhysicsImpostor): number;
  108857. /**
  108858. * Sets resitution of the impostor
  108859. * @param impostor impostor to set resitution on
  108860. * @param restitution resitution value
  108861. */
  108862. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108863. /**
  108864. * Gets pressure inside the impostor
  108865. * @param impostor impostor to get pressure from
  108866. * @returns pressure value
  108867. */
  108868. getBodyPressure(impostor: PhysicsImpostor): number;
  108869. /**
  108870. * Sets pressure inside a soft body impostor
  108871. * Cloth and rope must remain 0 pressure
  108872. * @param impostor impostor to set pressure on
  108873. * @param pressure pressure value
  108874. */
  108875. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  108876. /**
  108877. * Gets stiffness of the impostor
  108878. * @param impostor impostor to get stiffness from
  108879. * @returns pressure value
  108880. */
  108881. getBodyStiffness(impostor: PhysicsImpostor): number;
  108882. /**
  108883. * Sets stiffness of the impostor
  108884. * @param impostor impostor to set stiffness on
  108885. * @param stiffness stiffness value from 0 to 1
  108886. */
  108887. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  108888. /**
  108889. * Gets velocityIterations of the impostor
  108890. * @param impostor impostor to get velocity iterations from
  108891. * @returns velocityIterations value
  108892. */
  108893. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  108894. /**
  108895. * Sets velocityIterations of the impostor
  108896. * @param impostor impostor to set velocity iterations on
  108897. * @param velocityIterations velocityIterations value
  108898. */
  108899. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  108900. /**
  108901. * Gets positionIterations of the impostor
  108902. * @param impostor impostor to get position iterations from
  108903. * @returns positionIterations value
  108904. */
  108905. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  108906. /**
  108907. * Sets positionIterations of the impostor
  108908. * @param impostor impostor to set position on
  108909. * @param positionIterations positionIterations value
  108910. */
  108911. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  108912. /**
  108913. * Append an anchor to a cloth object
  108914. * @param impostor is the cloth impostor to add anchor to
  108915. * @param otherImpostor is the rigid impostor to anchor to
  108916. * @param width ratio across width from 0 to 1
  108917. * @param height ratio up height from 0 to 1
  108918. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108919. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108920. */
  108921. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108922. /**
  108923. * Append an hook to a rope object
  108924. * @param impostor is the rope impostor to add hook to
  108925. * @param otherImpostor is the rigid impostor to hook to
  108926. * @param length ratio along the rope from 0 to 1
  108927. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  108928. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108929. */
  108930. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108931. /**
  108932. * Sleeps the physics body and stops it from being active
  108933. * @param impostor impostor to sleep
  108934. */
  108935. sleepBody(impostor: PhysicsImpostor): void;
  108936. /**
  108937. * Activates the physics body
  108938. * @param impostor impostor to activate
  108939. */
  108940. wakeUpBody(impostor: PhysicsImpostor): void;
  108941. /**
  108942. * Updates the distance parameters of the joint
  108943. * @param joint joint to update
  108944. * @param maxDistance maximum distance of the joint
  108945. * @param minDistance minimum distance of the joint
  108946. */
  108947. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108948. /**
  108949. * Sets a motor on the joint
  108950. * @param joint joint to set motor on
  108951. * @param speed speed of the motor
  108952. * @param maxForce maximum force of the motor
  108953. * @param motorIndex index of the motor
  108954. */
  108955. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108956. /**
  108957. * Sets the motors limit
  108958. * @param joint joint to set limit on
  108959. * @param upperLimit upper limit
  108960. * @param lowerLimit lower limit
  108961. */
  108962. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108963. /**
  108964. * Syncs the position and rotation of a mesh with the impostor
  108965. * @param mesh mesh to sync
  108966. * @param impostor impostor to update the mesh with
  108967. */
  108968. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108969. /**
  108970. * Gets the radius of the impostor
  108971. * @param impostor impostor to get radius from
  108972. * @returns the radius
  108973. */
  108974. getRadius(impostor: PhysicsImpostor): number;
  108975. /**
  108976. * Gets the box size of the impostor
  108977. * @param impostor impostor to get box size from
  108978. * @param result the resulting box size
  108979. */
  108980. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108981. /**
  108982. * Disposes of the impostor
  108983. */
  108984. dispose(): void;
  108985. /**
  108986. * Does a raycast in the physics world
  108987. * @param from when should the ray start?
  108988. * @param to when should the ray end?
  108989. * @returns PhysicsRaycastResult
  108990. */
  108991. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108992. }
  108993. }
  108994. declare module BABYLON {
  108995. interface AbstractScene {
  108996. /**
  108997. * The list of reflection probes added to the scene
  108998. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108999. */
  109000. reflectionProbes: Array<ReflectionProbe>;
  109001. /**
  109002. * Removes the given reflection probe from this scene.
  109003. * @param toRemove The reflection probe to remove
  109004. * @returns The index of the removed reflection probe
  109005. */
  109006. removeReflectionProbe(toRemove: ReflectionProbe): number;
  109007. /**
  109008. * Adds the given reflection probe to this scene.
  109009. * @param newReflectionProbe The reflection probe to add
  109010. */
  109011. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  109012. }
  109013. /**
  109014. * Class used to generate realtime reflection / refraction cube textures
  109015. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  109016. */
  109017. export class ReflectionProbe {
  109018. /** defines the name of the probe */
  109019. name: string;
  109020. private _scene;
  109021. private _renderTargetTexture;
  109022. private _projectionMatrix;
  109023. private _viewMatrix;
  109024. private _target;
  109025. private _add;
  109026. private _attachedMesh;
  109027. private _invertYAxis;
  109028. /** Gets or sets probe position (center of the cube map) */
  109029. position: Vector3;
  109030. /**
  109031. * Creates a new reflection probe
  109032. * @param name defines the name of the probe
  109033. * @param size defines the texture resolution (for each face)
  109034. * @param scene defines the hosting scene
  109035. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  109036. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  109037. */
  109038. constructor(
  109039. /** defines the name of the probe */
  109040. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  109041. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  109042. samples: number;
  109043. /** Gets or sets the refresh rate to use (on every frame by default) */
  109044. refreshRate: number;
  109045. /**
  109046. * Gets the hosting scene
  109047. * @returns a Scene
  109048. */
  109049. getScene(): Scene;
  109050. /** Gets the internal CubeTexture used to render to */
  109051. readonly cubeTexture: RenderTargetTexture;
  109052. /** Gets the list of meshes to render */
  109053. readonly renderList: Nullable<AbstractMesh[]>;
  109054. /**
  109055. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  109056. * @param mesh defines the mesh to attach to
  109057. */
  109058. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  109059. /**
  109060. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  109061. * @param renderingGroupId The rendering group id corresponding to its index
  109062. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  109063. */
  109064. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  109065. /**
  109066. * Clean all associated resources
  109067. */
  109068. dispose(): void;
  109069. /**
  109070. * Converts the reflection probe information to a readable string for debug purpose.
  109071. * @param fullDetails Supports for multiple levels of logging within scene loading
  109072. * @returns the human readable reflection probe info
  109073. */
  109074. toString(fullDetails?: boolean): string;
  109075. /**
  109076. * Get the class name of the relfection probe.
  109077. * @returns "ReflectionProbe"
  109078. */
  109079. getClassName(): string;
  109080. /**
  109081. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  109082. * @returns The JSON representation of the texture
  109083. */
  109084. serialize(): any;
  109085. /**
  109086. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  109087. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  109088. * @param scene Define the scene the parsed reflection probe should be instantiated in
  109089. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  109090. * @returns The parsed reflection probe if successful
  109091. */
  109092. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  109093. }
  109094. }
  109095. declare module BABYLON {
  109096. /** @hidden */
  109097. export var _BabylonLoaderRegistered: boolean;
  109098. }
  109099. declare module BABYLON {
  109100. /**
  109101. * The Physically based simple base material of BJS.
  109102. *
  109103. * This enables better naming and convention enforcements on top of the pbrMaterial.
  109104. * It is used as the base class for both the specGloss and metalRough conventions.
  109105. */
  109106. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  109107. /**
  109108. * Number of Simultaneous lights allowed on the material.
  109109. */
  109110. maxSimultaneousLights: number;
  109111. /**
  109112. * If sets to true, disables all the lights affecting the material.
  109113. */
  109114. disableLighting: boolean;
  109115. /**
  109116. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  109117. */
  109118. environmentTexture: BaseTexture;
  109119. /**
  109120. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109121. */
  109122. invertNormalMapX: boolean;
  109123. /**
  109124. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109125. */
  109126. invertNormalMapY: boolean;
  109127. /**
  109128. * Normal map used in the model.
  109129. */
  109130. normalTexture: BaseTexture;
  109131. /**
  109132. * Emissivie color used to self-illuminate the model.
  109133. */
  109134. emissiveColor: Color3;
  109135. /**
  109136. * Emissivie texture used to self-illuminate the model.
  109137. */
  109138. emissiveTexture: BaseTexture;
  109139. /**
  109140. * Occlusion Channel Strenght.
  109141. */
  109142. occlusionStrength: number;
  109143. /**
  109144. * Occlusion Texture of the material (adding extra occlusion effects).
  109145. */
  109146. occlusionTexture: BaseTexture;
  109147. /**
  109148. * Defines the alpha limits in alpha test mode.
  109149. */
  109150. alphaCutOff: number;
  109151. /**
  109152. * Gets the current double sided mode.
  109153. */
  109154. /**
  109155. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109156. */
  109157. doubleSided: boolean;
  109158. /**
  109159. * Stores the pre-calculated light information of a mesh in a texture.
  109160. */
  109161. lightmapTexture: BaseTexture;
  109162. /**
  109163. * If true, the light map contains occlusion information instead of lighting info.
  109164. */
  109165. useLightmapAsShadowmap: boolean;
  109166. /**
  109167. * Instantiates a new PBRMaterial instance.
  109168. *
  109169. * @param name The material name
  109170. * @param scene The scene the material will be use in.
  109171. */
  109172. constructor(name: string, scene: Scene);
  109173. getClassName(): string;
  109174. }
  109175. }
  109176. declare module BABYLON {
  109177. /**
  109178. * The PBR material of BJS following the metal roughness convention.
  109179. *
  109180. * This fits to the PBR convention in the GLTF definition:
  109181. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  109182. */
  109183. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  109184. /**
  109185. * The base color has two different interpretations depending on the value of metalness.
  109186. * When the material is a metal, the base color is the specific measured reflectance value
  109187. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  109188. * of the material.
  109189. */
  109190. baseColor: Color3;
  109191. /**
  109192. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  109193. * well as opacity information in the alpha channel.
  109194. */
  109195. baseTexture: BaseTexture;
  109196. /**
  109197. * Specifies the metallic scalar value of the material.
  109198. * Can also be used to scale the metalness values of the metallic texture.
  109199. */
  109200. metallic: number;
  109201. /**
  109202. * Specifies the roughness scalar value of the material.
  109203. * Can also be used to scale the roughness values of the metallic texture.
  109204. */
  109205. roughness: number;
  109206. /**
  109207. * Texture containing both the metallic value in the B channel and the
  109208. * roughness value in the G channel to keep better precision.
  109209. */
  109210. metallicRoughnessTexture: BaseTexture;
  109211. /**
  109212. * Instantiates a new PBRMetalRoughnessMaterial instance.
  109213. *
  109214. * @param name The material name
  109215. * @param scene The scene the material will be use in.
  109216. */
  109217. constructor(name: string, scene: Scene);
  109218. /**
  109219. * Return the currrent class name of the material.
  109220. */
  109221. getClassName(): string;
  109222. /**
  109223. * Makes a duplicate of the current material.
  109224. * @param name - name to use for the new material.
  109225. */
  109226. clone(name: string): PBRMetallicRoughnessMaterial;
  109227. /**
  109228. * Serialize the material to a parsable JSON object.
  109229. */
  109230. serialize(): any;
  109231. /**
  109232. * Parses a JSON object correponding to the serialize function.
  109233. */
  109234. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  109235. }
  109236. }
  109237. declare module BABYLON {
  109238. /**
  109239. * The PBR material of BJS following the specular glossiness convention.
  109240. *
  109241. * This fits to the PBR convention in the GLTF definition:
  109242. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  109243. */
  109244. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  109245. /**
  109246. * Specifies the diffuse color of the material.
  109247. */
  109248. diffuseColor: Color3;
  109249. /**
  109250. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  109251. * channel.
  109252. */
  109253. diffuseTexture: BaseTexture;
  109254. /**
  109255. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  109256. */
  109257. specularColor: Color3;
  109258. /**
  109259. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  109260. */
  109261. glossiness: number;
  109262. /**
  109263. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  109264. */
  109265. specularGlossinessTexture: BaseTexture;
  109266. /**
  109267. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  109268. *
  109269. * @param name The material name
  109270. * @param scene The scene the material will be use in.
  109271. */
  109272. constructor(name: string, scene: Scene);
  109273. /**
  109274. * Return the currrent class name of the material.
  109275. */
  109276. getClassName(): string;
  109277. /**
  109278. * Makes a duplicate of the current material.
  109279. * @param name - name to use for the new material.
  109280. */
  109281. clone(name: string): PBRSpecularGlossinessMaterial;
  109282. /**
  109283. * Serialize the material to a parsable JSON object.
  109284. */
  109285. serialize(): any;
  109286. /**
  109287. * Parses a JSON object correponding to the serialize function.
  109288. */
  109289. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  109290. }
  109291. }
  109292. declare module BABYLON {
  109293. /**
  109294. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  109295. * It can help converting any input color in a desired output one. This can then be used to create effects
  109296. * from sepia, black and white to sixties or futuristic rendering...
  109297. *
  109298. * The only supported format is currently 3dl.
  109299. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  109300. */
  109301. export class ColorGradingTexture extends BaseTexture {
  109302. /**
  109303. * The current texture matrix. (will always be identity in color grading texture)
  109304. */
  109305. private _textureMatrix;
  109306. /**
  109307. * The texture URL.
  109308. */
  109309. url: string;
  109310. /**
  109311. * Empty line regex stored for GC.
  109312. */
  109313. private static _noneEmptyLineRegex;
  109314. private _engine;
  109315. /**
  109316. * Instantiates a ColorGradingTexture from the following parameters.
  109317. *
  109318. * @param url The location of the color gradind data (currently only supporting 3dl)
  109319. * @param scene The scene the texture will be used in
  109320. */
  109321. constructor(url: string, scene: Scene);
  109322. /**
  109323. * Returns the texture matrix used in most of the material.
  109324. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  109325. */
  109326. getTextureMatrix(): Matrix;
  109327. /**
  109328. * Occurs when the file being loaded is a .3dl LUT file.
  109329. */
  109330. private load3dlTexture;
  109331. /**
  109332. * Starts the loading process of the texture.
  109333. */
  109334. private loadTexture;
  109335. /**
  109336. * Clones the color gradind texture.
  109337. */
  109338. clone(): ColorGradingTexture;
  109339. /**
  109340. * Called during delayed load for textures.
  109341. */
  109342. delayLoad(): void;
  109343. /**
  109344. * Parses a color grading texture serialized by Babylon.
  109345. * @param parsedTexture The texture information being parsedTexture
  109346. * @param scene The scene to load the texture in
  109347. * @param rootUrl The root url of the data assets to load
  109348. * @return A color gradind texture
  109349. */
  109350. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  109351. /**
  109352. * Serializes the LUT texture to json format.
  109353. */
  109354. serialize(): any;
  109355. }
  109356. }
  109357. declare module BABYLON {
  109358. /**
  109359. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  109360. */
  109361. export class EquiRectangularCubeTexture extends BaseTexture {
  109362. /** The six faces of the cube. */
  109363. private static _FacesMapping;
  109364. private _noMipmap;
  109365. private _onLoad;
  109366. private _onError;
  109367. /** The size of the cubemap. */
  109368. private _size;
  109369. /** The buffer of the image. */
  109370. private _buffer;
  109371. /** The width of the input image. */
  109372. private _width;
  109373. /** The height of the input image. */
  109374. private _height;
  109375. /** The URL to the image. */
  109376. url: string;
  109377. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  109378. coordinatesMode: number;
  109379. /**
  109380. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  109381. * @param url The location of the image
  109382. * @param scene The scene the texture will be used in
  109383. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  109384. * @param noMipmap Forces to not generate the mipmap if true
  109385. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  109386. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  109387. * @param onLoad — defines a callback called when texture is loaded
  109388. * @param onError — defines a callback called if there is an error
  109389. */
  109390. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  109391. /**
  109392. * Load the image data, by putting the image on a canvas and extracting its buffer.
  109393. */
  109394. private loadImage;
  109395. /**
  109396. * Convert the image buffer into a cubemap and create a CubeTexture.
  109397. */
  109398. private loadTexture;
  109399. /**
  109400. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  109401. * @param buffer The ArrayBuffer that should be converted.
  109402. * @returns The buffer as Float32Array.
  109403. */
  109404. private getFloat32ArrayFromArrayBuffer;
  109405. /**
  109406. * Get the current class name of the texture useful for serialization or dynamic coding.
  109407. * @returns "EquiRectangularCubeTexture"
  109408. */
  109409. getClassName(): string;
  109410. /**
  109411. * Create a clone of the current EquiRectangularCubeTexture and return it.
  109412. * @returns A clone of the current EquiRectangularCubeTexture.
  109413. */
  109414. clone(): EquiRectangularCubeTexture;
  109415. }
  109416. }
  109417. declare module BABYLON {
  109418. /**
  109419. * Based on jsTGALoader - Javascript loader for TGA file
  109420. * By Vincent Thibault
  109421. * @see http://blog.robrowser.com/javascript-tga-loader.html
  109422. */
  109423. export class TGATools {
  109424. private static _TYPE_INDEXED;
  109425. private static _TYPE_RGB;
  109426. private static _TYPE_GREY;
  109427. private static _TYPE_RLE_INDEXED;
  109428. private static _TYPE_RLE_RGB;
  109429. private static _TYPE_RLE_GREY;
  109430. private static _ORIGIN_MASK;
  109431. private static _ORIGIN_SHIFT;
  109432. private static _ORIGIN_BL;
  109433. private static _ORIGIN_BR;
  109434. private static _ORIGIN_UL;
  109435. private static _ORIGIN_UR;
  109436. /**
  109437. * Gets the header of a TGA file
  109438. * @param data defines the TGA data
  109439. * @returns the header
  109440. */
  109441. static GetTGAHeader(data: Uint8Array): any;
  109442. /**
  109443. * Uploads TGA content to a Babylon Texture
  109444. * @hidden
  109445. */
  109446. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  109447. /** @hidden */
  109448. 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;
  109449. /** @hidden */
  109450. 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;
  109451. /** @hidden */
  109452. 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;
  109453. /** @hidden */
  109454. 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;
  109455. /** @hidden */
  109456. 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;
  109457. /** @hidden */
  109458. 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;
  109459. }
  109460. }
  109461. declare module BABYLON {
  109462. /**
  109463. * Implementation of the TGA Texture Loader.
  109464. * @hidden
  109465. */
  109466. export class _TGATextureLoader implements IInternalTextureLoader {
  109467. /**
  109468. * Defines wether the loader supports cascade loading the different faces.
  109469. */
  109470. readonly supportCascades: boolean;
  109471. /**
  109472. * This returns if the loader support the current file information.
  109473. * @param extension defines the file extension of the file being loaded
  109474. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109475. * @param fallback defines the fallback internal texture if any
  109476. * @param isBase64 defines whether the texture is encoded as a base64
  109477. * @param isBuffer defines whether the texture data are stored as a buffer
  109478. * @returns true if the loader can load the specified file
  109479. */
  109480. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109481. /**
  109482. * Transform the url before loading if required.
  109483. * @param rootUrl the url of the texture
  109484. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109485. * @returns the transformed texture
  109486. */
  109487. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109488. /**
  109489. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109490. * @param rootUrl the url of the texture
  109491. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109492. * @returns the fallback texture
  109493. */
  109494. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109495. /**
  109496. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109497. * @param data contains the texture data
  109498. * @param texture defines the BabylonJS internal texture
  109499. * @param createPolynomials will be true if polynomials have been requested
  109500. * @param onLoad defines the callback to trigger once the texture is ready
  109501. * @param onError defines the callback to trigger in case of error
  109502. */
  109503. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109504. /**
  109505. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109506. * @param data contains the texture data
  109507. * @param texture defines the BabylonJS internal texture
  109508. * @param callback defines the method to call once ready to upload
  109509. */
  109510. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109511. }
  109512. }
  109513. declare module BABYLON {
  109514. /**
  109515. * 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.
  109516. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109517. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109518. */
  109519. export class CustomProceduralTexture extends ProceduralTexture {
  109520. private _animate;
  109521. private _time;
  109522. private _config;
  109523. private _texturePath;
  109524. /**
  109525. * Instantiates a new Custom Procedural Texture.
  109526. * 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.
  109527. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109528. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109529. * @param name Define the name of the texture
  109530. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  109531. * @param size Define the size of the texture to create
  109532. * @param scene Define the scene the texture belongs to
  109533. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  109534. * @param generateMipMaps Define if the texture should creates mip maps or not
  109535. */
  109536. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109537. private _loadJson;
  109538. /**
  109539. * Is the texture ready to be used ? (rendered at least once)
  109540. * @returns true if ready, otherwise, false.
  109541. */
  109542. isReady(): boolean;
  109543. /**
  109544. * Render the texture to its associated render target.
  109545. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  109546. */
  109547. render(useCameraPostProcess?: boolean): void;
  109548. /**
  109549. * Update the list of dependant textures samplers in the shader.
  109550. */
  109551. updateTextures(): void;
  109552. /**
  109553. * Update the uniform values of the procedural texture in the shader.
  109554. */
  109555. updateShaderUniforms(): void;
  109556. /**
  109557. * Define if the texture animates or not.
  109558. */
  109559. animate: boolean;
  109560. }
  109561. }
  109562. declare module BABYLON {
  109563. /** @hidden */
  109564. export var noisePixelShader: {
  109565. name: string;
  109566. shader: string;
  109567. };
  109568. }
  109569. declare module BABYLON {
  109570. /**
  109571. * Class used to generate noise procedural textures
  109572. */
  109573. export class NoiseProceduralTexture extends ProceduralTexture {
  109574. private _time;
  109575. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  109576. brightness: number;
  109577. /** Defines the number of octaves to process */
  109578. octaves: number;
  109579. /** Defines the level of persistence (0.8 by default) */
  109580. persistence: number;
  109581. /** Gets or sets animation speed factor (default is 1) */
  109582. animationSpeedFactor: number;
  109583. /**
  109584. * Creates a new NoiseProceduralTexture
  109585. * @param name defines the name fo the texture
  109586. * @param size defines the size of the texture (default is 256)
  109587. * @param scene defines the hosting scene
  109588. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  109589. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  109590. */
  109591. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109592. private _updateShaderUniforms;
  109593. protected _getDefines(): string;
  109594. /** Generate the current state of the procedural texture */
  109595. render(useCameraPostProcess?: boolean): void;
  109596. /**
  109597. * Serializes this noise procedural texture
  109598. * @returns a serialized noise procedural texture object
  109599. */
  109600. serialize(): any;
  109601. /**
  109602. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  109603. * @param parsedTexture defines parsed texture data
  109604. * @param scene defines the current scene
  109605. * @param rootUrl defines the root URL containing noise procedural texture information
  109606. * @returns a parsed NoiseProceduralTexture
  109607. */
  109608. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  109609. }
  109610. }
  109611. declare module BABYLON {
  109612. /**
  109613. * Raw cube texture where the raw buffers are passed in
  109614. */
  109615. export class RawCubeTexture extends CubeTexture {
  109616. /**
  109617. * Creates a cube texture where the raw buffers are passed in.
  109618. * @param scene defines the scene the texture is attached to
  109619. * @param data defines the array of data to use to create each face
  109620. * @param size defines the size of the textures
  109621. * @param format defines the format of the data
  109622. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  109623. * @param generateMipMaps defines if the engine should generate the mip levels
  109624. * @param invertY defines if data must be stored with Y axis inverted
  109625. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  109626. * @param compression defines the compression used (null by default)
  109627. */
  109628. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  109629. /**
  109630. * Updates the raw cube texture.
  109631. * @param data defines the data to store
  109632. * @param format defines the data format
  109633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  109634. * @param invertY defines if data must be stored with Y axis inverted
  109635. * @param compression defines the compression used (null by default)
  109636. * @param level defines which level of the texture to update
  109637. */
  109638. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  109639. /**
  109640. * Updates a raw cube texture with RGBD encoded data.
  109641. * @param data defines the array of data [mipmap][face] to use to create each face
  109642. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  109643. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  109644. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  109645. * @returns a promsie that resolves when the operation is complete
  109646. */
  109647. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  109648. /**
  109649. * Clones the raw cube texture.
  109650. * @return a new cube texture
  109651. */
  109652. clone(): CubeTexture;
  109653. /** @hidden */
  109654. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109655. }
  109656. }
  109657. declare module BABYLON {
  109658. /**
  109659. * Class used to store 3D textures containing user data
  109660. */
  109661. export class RawTexture3D extends Texture {
  109662. /** Gets or sets the texture format to use */
  109663. format: number;
  109664. private _engine;
  109665. /**
  109666. * Create a new RawTexture3D
  109667. * @param data defines the data of the texture
  109668. * @param width defines the width of the texture
  109669. * @param height defines the height of the texture
  109670. * @param depth defines the depth of the texture
  109671. * @param format defines the texture format to use
  109672. * @param scene defines the hosting scene
  109673. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  109674. * @param invertY defines if texture must be stored with Y axis inverted
  109675. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  109676. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  109677. */
  109678. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  109679. /** Gets or sets the texture format to use */
  109680. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  109681. /**
  109682. * Update the texture with new data
  109683. * @param data defines the data to store in the texture
  109684. */
  109685. update(data: ArrayBufferView): void;
  109686. }
  109687. }
  109688. declare module BABYLON {
  109689. /**
  109690. * Creates a refraction texture used by refraction channel of the standard material.
  109691. * It is like a mirror but to see through a material.
  109692. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109693. */
  109694. export class RefractionTexture extends RenderTargetTexture {
  109695. /**
  109696. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  109697. * 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.
  109698. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109699. */
  109700. refractionPlane: Plane;
  109701. /**
  109702. * Define how deep under the surface we should see.
  109703. */
  109704. depth: number;
  109705. /**
  109706. * Creates a refraction texture used by refraction channel of the standard material.
  109707. * It is like a mirror but to see through a material.
  109708. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109709. * @param name Define the texture name
  109710. * @param size Define the size of the underlying texture
  109711. * @param scene Define the scene the refraction belongs to
  109712. * @param generateMipMaps Define if we need to generate mips level for the refraction
  109713. */
  109714. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  109715. /**
  109716. * Clone the refraction texture.
  109717. * @returns the cloned texture
  109718. */
  109719. clone(): RefractionTexture;
  109720. /**
  109721. * Serialize the texture to a JSON representation you could use in Parse later on
  109722. * @returns the serialized JSON representation
  109723. */
  109724. serialize(): any;
  109725. }
  109726. }
  109727. declare module BABYLON {
  109728. /**
  109729. * Defines the options related to the creation of an HtmlElementTexture
  109730. */
  109731. export interface IHtmlElementTextureOptions {
  109732. /**
  109733. * Defines wether mip maps should be created or not.
  109734. */
  109735. generateMipMaps?: boolean;
  109736. /**
  109737. * Defines the sampling mode of the texture.
  109738. */
  109739. samplingMode?: number;
  109740. /**
  109741. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  109742. */
  109743. engine: Nullable<Engine>;
  109744. /**
  109745. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  109746. */
  109747. scene: Nullable<Scene>;
  109748. }
  109749. /**
  109750. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  109751. * To be as efficient as possible depending on your constraints nothing aside the first upload
  109752. * is automatically managed.
  109753. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  109754. * in your application.
  109755. *
  109756. * As the update is not automatic, you need to call them manually.
  109757. */
  109758. export class HtmlElementTexture extends BaseTexture {
  109759. /**
  109760. * The texture URL.
  109761. */
  109762. element: HTMLVideoElement | HTMLCanvasElement;
  109763. private static readonly DefaultOptions;
  109764. private _textureMatrix;
  109765. private _engine;
  109766. private _isVideo;
  109767. private _generateMipMaps;
  109768. private _samplingMode;
  109769. /**
  109770. * Instantiates a HtmlElementTexture from the following parameters.
  109771. *
  109772. * @param name Defines the name of the texture
  109773. * @param element Defines the video or canvas the texture is filled with
  109774. * @param options Defines the other none mandatory texture creation options
  109775. */
  109776. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  109777. private _createInternalTexture;
  109778. /**
  109779. * Returns the texture matrix used in most of the material.
  109780. */
  109781. getTextureMatrix(): Matrix;
  109782. /**
  109783. * Updates the content of the texture.
  109784. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  109785. */
  109786. update(invertY?: Nullable<boolean>): void;
  109787. }
  109788. }
  109789. declare module BABYLON {
  109790. /**
  109791. * Helper class to push actions to a pool of workers.
  109792. */
  109793. export class WorkerPool implements IDisposable {
  109794. private _workerInfos;
  109795. private _pendingActions;
  109796. /**
  109797. * Constructor
  109798. * @param workers Array of workers to use for actions
  109799. */
  109800. constructor(workers: Array<Worker>);
  109801. /**
  109802. * Terminates all workers and clears any pending actions.
  109803. */
  109804. dispose(): void;
  109805. /**
  109806. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109807. * pended until a worker has completed its action.
  109808. * @param action The action to perform. Call onComplete when the action is complete.
  109809. */
  109810. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109811. private _execute;
  109812. }
  109813. }
  109814. declare module BABYLON {
  109815. /**
  109816. * Configuration for Draco compression
  109817. */
  109818. export interface IDracoCompressionConfiguration {
  109819. /**
  109820. * Configuration for the decoder.
  109821. */
  109822. decoder: {
  109823. /**
  109824. * The url to the WebAssembly module.
  109825. */
  109826. wasmUrl?: string;
  109827. /**
  109828. * The url to the WebAssembly binary.
  109829. */
  109830. wasmBinaryUrl?: string;
  109831. /**
  109832. * The url to the fallback JavaScript module.
  109833. */
  109834. fallbackUrl?: string;
  109835. };
  109836. }
  109837. /**
  109838. * Draco compression (https://google.github.io/draco/)
  109839. *
  109840. * This class wraps the Draco module.
  109841. *
  109842. * **Encoder**
  109843. *
  109844. * The encoder is not currently implemented.
  109845. *
  109846. * **Decoder**
  109847. *
  109848. * 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.
  109849. *
  109850. * To update the configuration, use the following code:
  109851. * ```javascript
  109852. * DracoCompression.Configuration = {
  109853. * decoder: {
  109854. * wasmUrl: "<url to the WebAssembly library>",
  109855. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  109856. * fallbackUrl: "<url to the fallback JavaScript library>",
  109857. * }
  109858. * };
  109859. * ```
  109860. *
  109861. * 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.
  109862. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  109863. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  109864. *
  109865. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  109866. * ```javascript
  109867. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  109868. * ```
  109869. *
  109870. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  109871. */
  109872. export class DracoCompression implements IDisposable {
  109873. private _workerPoolPromise?;
  109874. private _decoderModulePromise?;
  109875. /**
  109876. * The configuration. Defaults to the following urls:
  109877. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  109878. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  109879. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  109880. */
  109881. static Configuration: IDracoCompressionConfiguration;
  109882. /**
  109883. * Returns true if the decoder configuration is available.
  109884. */
  109885. static readonly DecoderAvailable: boolean;
  109886. /**
  109887. * Default number of workers to create when creating the draco compression object.
  109888. */
  109889. static DefaultNumWorkers: number;
  109890. private static GetDefaultNumWorkers;
  109891. private static _Default;
  109892. /**
  109893. * Default instance for the draco compression object.
  109894. */
  109895. static readonly Default: DracoCompression;
  109896. /**
  109897. * Constructor
  109898. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  109899. */
  109900. constructor(numWorkers?: number);
  109901. /**
  109902. * Stop all async operations and release resources.
  109903. */
  109904. dispose(): void;
  109905. /**
  109906. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  109907. * @returns a promise that resolves when ready
  109908. */
  109909. whenReadyAsync(): Promise<void>;
  109910. /**
  109911. * Decode Draco compressed mesh data to vertex data.
  109912. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  109913. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  109914. * @returns A promise that resolves with the decoded vertex data
  109915. */
  109916. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  109917. [kind: string]: number;
  109918. }): Promise<VertexData>;
  109919. }
  109920. }
  109921. declare module BABYLON {
  109922. /**
  109923. * Class for building Constructive Solid Geometry
  109924. */
  109925. export class CSG {
  109926. private polygons;
  109927. /**
  109928. * The world matrix
  109929. */
  109930. matrix: Matrix;
  109931. /**
  109932. * Stores the position
  109933. */
  109934. position: Vector3;
  109935. /**
  109936. * Stores the rotation
  109937. */
  109938. rotation: Vector3;
  109939. /**
  109940. * Stores the rotation quaternion
  109941. */
  109942. rotationQuaternion: Nullable<Quaternion>;
  109943. /**
  109944. * Stores the scaling vector
  109945. */
  109946. scaling: Vector3;
  109947. /**
  109948. * Convert the Mesh to CSG
  109949. * @param mesh The Mesh to convert to CSG
  109950. * @returns A new CSG from the Mesh
  109951. */
  109952. static FromMesh(mesh: Mesh): CSG;
  109953. /**
  109954. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  109955. * @param polygons Polygons used to construct a CSG solid
  109956. */
  109957. private static FromPolygons;
  109958. /**
  109959. * Clones, or makes a deep copy, of the CSG
  109960. * @returns A new CSG
  109961. */
  109962. clone(): CSG;
  109963. /**
  109964. * Unions this CSG with another CSG
  109965. * @param csg The CSG to union against this CSG
  109966. * @returns The unioned CSG
  109967. */
  109968. union(csg: CSG): CSG;
  109969. /**
  109970. * Unions this CSG with another CSG in place
  109971. * @param csg The CSG to union against this CSG
  109972. */
  109973. unionInPlace(csg: CSG): void;
  109974. /**
  109975. * Subtracts this CSG with another CSG
  109976. * @param csg The CSG to subtract against this CSG
  109977. * @returns A new CSG
  109978. */
  109979. subtract(csg: CSG): CSG;
  109980. /**
  109981. * Subtracts this CSG with another CSG in place
  109982. * @param csg The CSG to subtact against this CSG
  109983. */
  109984. subtractInPlace(csg: CSG): void;
  109985. /**
  109986. * Intersect this CSG with another CSG
  109987. * @param csg The CSG to intersect against this CSG
  109988. * @returns A new CSG
  109989. */
  109990. intersect(csg: CSG): CSG;
  109991. /**
  109992. * Intersects this CSG with another CSG in place
  109993. * @param csg The CSG to intersect against this CSG
  109994. */
  109995. intersectInPlace(csg: CSG): void;
  109996. /**
  109997. * Return a new CSG solid with solid and empty space switched. This solid is
  109998. * not modified.
  109999. * @returns A new CSG solid with solid and empty space switched
  110000. */
  110001. inverse(): CSG;
  110002. /**
  110003. * Inverses the CSG in place
  110004. */
  110005. inverseInPlace(): void;
  110006. /**
  110007. * This is used to keep meshes transformations so they can be restored
  110008. * when we build back a Babylon Mesh
  110009. * NB : All CSG operations are performed in world coordinates
  110010. * @param csg The CSG to copy the transform attributes from
  110011. * @returns This CSG
  110012. */
  110013. copyTransformAttributes(csg: CSG): CSG;
  110014. /**
  110015. * Build Raw mesh from CSG
  110016. * Coordinates here are in world space
  110017. * @param name The name of the mesh geometry
  110018. * @param scene The Scene
  110019. * @param keepSubMeshes Specifies if the submeshes should be kept
  110020. * @returns A new Mesh
  110021. */
  110022. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  110023. /**
  110024. * Build Mesh from CSG taking material and transforms into account
  110025. * @param name The name of the Mesh
  110026. * @param material The material of the Mesh
  110027. * @param scene The Scene
  110028. * @param keepSubMeshes Specifies if submeshes should be kept
  110029. * @returns The new Mesh
  110030. */
  110031. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  110032. }
  110033. }
  110034. declare module BABYLON {
  110035. /**
  110036. * Class used to create a trail following a mesh
  110037. */
  110038. export class TrailMesh extends Mesh {
  110039. private _generator;
  110040. private _autoStart;
  110041. private _running;
  110042. private _diameter;
  110043. private _length;
  110044. private _sectionPolygonPointsCount;
  110045. private _sectionVectors;
  110046. private _sectionNormalVectors;
  110047. private _beforeRenderObserver;
  110048. /**
  110049. * @constructor
  110050. * @param name The value used by scene.getMeshByName() to do a lookup.
  110051. * @param generator The mesh to generate a trail.
  110052. * @param scene The scene to add this mesh to.
  110053. * @param diameter Diameter of trailing mesh. Default is 1.
  110054. * @param length Length of trailing mesh. Default is 60.
  110055. * @param autoStart Automatically start trailing mesh. Default true.
  110056. */
  110057. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  110058. /**
  110059. * "TrailMesh"
  110060. * @returns "TrailMesh"
  110061. */
  110062. getClassName(): string;
  110063. private _createMesh;
  110064. /**
  110065. * Start trailing mesh.
  110066. */
  110067. start(): void;
  110068. /**
  110069. * Stop trailing mesh.
  110070. */
  110071. stop(): void;
  110072. /**
  110073. * Update trailing mesh geometry.
  110074. */
  110075. update(): void;
  110076. /**
  110077. * Returns a new TrailMesh object.
  110078. * @param name is a string, the name given to the new mesh
  110079. * @param newGenerator use new generator object for cloned trail mesh
  110080. * @returns a new mesh
  110081. */
  110082. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  110083. /**
  110084. * Serializes this trail mesh
  110085. * @param serializationObject object to write serialization to
  110086. */
  110087. serialize(serializationObject: any): void;
  110088. /**
  110089. * Parses a serialized trail mesh
  110090. * @param parsedMesh the serialized mesh
  110091. * @param scene the scene to create the trail mesh in
  110092. * @returns the created trail mesh
  110093. */
  110094. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  110095. }
  110096. }
  110097. declare module BABYLON {
  110098. /**
  110099. * Class containing static functions to help procedurally build meshes
  110100. */
  110101. export class TorusKnotBuilder {
  110102. /**
  110103. * Creates a torus knot mesh
  110104. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  110105. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  110106. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  110107. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  110108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110111. * @param name defines the name of the mesh
  110112. * @param options defines the options used to create the mesh
  110113. * @param scene defines the hosting scene
  110114. * @returns the torus knot mesh
  110115. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  110116. */
  110117. static CreateTorusKnot(name: string, options: {
  110118. radius?: number;
  110119. tube?: number;
  110120. radialSegments?: number;
  110121. tubularSegments?: number;
  110122. p?: number;
  110123. q?: number;
  110124. updatable?: boolean;
  110125. sideOrientation?: number;
  110126. frontUVs?: Vector4;
  110127. backUVs?: Vector4;
  110128. }, scene: any): Mesh;
  110129. }
  110130. }
  110131. declare module BABYLON {
  110132. /**
  110133. * Polygon
  110134. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  110135. */
  110136. export class Polygon {
  110137. /**
  110138. * Creates a rectangle
  110139. * @param xmin bottom X coord
  110140. * @param ymin bottom Y coord
  110141. * @param xmax top X coord
  110142. * @param ymax top Y coord
  110143. * @returns points that make the resulting rectation
  110144. */
  110145. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  110146. /**
  110147. * Creates a circle
  110148. * @param radius radius of circle
  110149. * @param cx scale in x
  110150. * @param cy scale in y
  110151. * @param numberOfSides number of sides that make up the circle
  110152. * @returns points that make the resulting circle
  110153. */
  110154. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  110155. /**
  110156. * Creates a polygon from input string
  110157. * @param input Input polygon data
  110158. * @returns the parsed points
  110159. */
  110160. static Parse(input: string): Vector2[];
  110161. /**
  110162. * Starts building a polygon from x and y coordinates
  110163. * @param x x coordinate
  110164. * @param y y coordinate
  110165. * @returns the started path2
  110166. */
  110167. static StartingAt(x: number, y: number): Path2;
  110168. }
  110169. /**
  110170. * Builds a polygon
  110171. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  110172. */
  110173. export class PolygonMeshBuilder {
  110174. private _points;
  110175. private _outlinepoints;
  110176. private _holes;
  110177. private _name;
  110178. private _scene;
  110179. private _epoints;
  110180. private _eholes;
  110181. private _addToepoint;
  110182. /**
  110183. * Babylon reference to the earcut plugin.
  110184. */
  110185. bjsEarcut: any;
  110186. /**
  110187. * Creates a PolygonMeshBuilder
  110188. * @param name name of the builder
  110189. * @param contours Path of the polygon
  110190. * @param scene scene to add to when creating the mesh
  110191. * @param earcutInjection can be used to inject your own earcut reference
  110192. */
  110193. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  110194. /**
  110195. * Adds a whole within the polygon
  110196. * @param hole Array of points defining the hole
  110197. * @returns this
  110198. */
  110199. addHole(hole: Vector2[]): PolygonMeshBuilder;
  110200. /**
  110201. * Creates the polygon
  110202. * @param updatable If the mesh should be updatable
  110203. * @param depth The depth of the mesh created
  110204. * @returns the created mesh
  110205. */
  110206. build(updatable?: boolean, depth?: number): Mesh;
  110207. /**
  110208. * Creates the polygon
  110209. * @param depth The depth of the mesh created
  110210. * @returns the created VertexData
  110211. */
  110212. buildVertexData(depth?: number): VertexData;
  110213. /**
  110214. * Adds a side to the polygon
  110215. * @param positions points that make the polygon
  110216. * @param normals normals of the polygon
  110217. * @param uvs uvs of the polygon
  110218. * @param indices indices of the polygon
  110219. * @param bounds bounds of the polygon
  110220. * @param points points of the polygon
  110221. * @param depth depth of the polygon
  110222. * @param flip flip of the polygon
  110223. */
  110224. private addSide;
  110225. }
  110226. }
  110227. declare module BABYLON {
  110228. /**
  110229. * Class containing static functions to help procedurally build meshes
  110230. */
  110231. export class PolygonBuilder {
  110232. /**
  110233. * Creates a polygon mesh
  110234. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110235. * * 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
  110236. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110238. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110239. * * Remember you can only change the shape positions, not their number when updating a polygon
  110240. * @param name defines the name of the mesh
  110241. * @param options defines the options used to create the mesh
  110242. * @param scene defines the hosting scene
  110243. * @param earcutInjection can be used to inject your own earcut reference
  110244. * @returns the polygon mesh
  110245. */
  110246. static CreatePolygon(name: string, options: {
  110247. shape: Vector3[];
  110248. holes?: Vector3[][];
  110249. depth?: number;
  110250. faceUV?: Vector4[];
  110251. faceColors?: Color4[];
  110252. updatable?: boolean;
  110253. sideOrientation?: number;
  110254. frontUVs?: Vector4;
  110255. backUVs?: Vector4;
  110256. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110257. /**
  110258. * Creates an extruded polygon mesh, with depth in the Y direction.
  110259. * * 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)
  110260. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110261. * @param name defines the name of the mesh
  110262. * @param options defines the options used to create the mesh
  110263. * @param scene defines the hosting scene
  110264. * @param earcutInjection can be used to inject your own earcut reference
  110265. * @returns the polygon mesh
  110266. */
  110267. static ExtrudePolygon(name: string, options: {
  110268. shape: Vector3[];
  110269. holes?: Vector3[][];
  110270. depth?: number;
  110271. faceUV?: Vector4[];
  110272. faceColors?: Color4[];
  110273. updatable?: boolean;
  110274. sideOrientation?: number;
  110275. frontUVs?: Vector4;
  110276. backUVs?: Vector4;
  110277. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110278. }
  110279. }
  110280. declare module BABYLON {
  110281. /**
  110282. * Class containing static functions to help procedurally build meshes
  110283. */
  110284. export class LatheBuilder {
  110285. /**
  110286. * Creates lathe mesh.
  110287. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110288. * * 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
  110289. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110290. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110291. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110292. * * 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
  110293. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110294. * * 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
  110295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110296. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110297. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110299. * @param name defines the name of the mesh
  110300. * @param options defines the options used to create the mesh
  110301. * @param scene defines the hosting scene
  110302. * @returns the lathe mesh
  110303. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110304. */
  110305. static CreateLathe(name: string, options: {
  110306. shape: Vector3[];
  110307. radius?: number;
  110308. tessellation?: number;
  110309. clip?: number;
  110310. arc?: number;
  110311. closed?: boolean;
  110312. updatable?: boolean;
  110313. sideOrientation?: number;
  110314. frontUVs?: Vector4;
  110315. backUVs?: Vector4;
  110316. cap?: number;
  110317. invertUV?: boolean;
  110318. }, scene?: Nullable<Scene>): Mesh;
  110319. }
  110320. }
  110321. declare module BABYLON {
  110322. /**
  110323. * Class containing static functions to help procedurally build meshes
  110324. */
  110325. export class TubeBuilder {
  110326. /**
  110327. * Creates a tube mesh.
  110328. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110329. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110330. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110331. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110332. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110333. * * 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)
  110334. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110335. * * 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
  110336. * * 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
  110337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110339. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110341. * @param name defines the name of the mesh
  110342. * @param options defines the options used to create the mesh
  110343. * @param scene defines the hosting scene
  110344. * @returns the tube mesh
  110345. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110346. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110347. */
  110348. static CreateTube(name: string, options: {
  110349. path: Vector3[];
  110350. radius?: number;
  110351. tessellation?: number;
  110352. radiusFunction?: {
  110353. (i: number, distance: number): number;
  110354. };
  110355. cap?: number;
  110356. arc?: number;
  110357. updatable?: boolean;
  110358. sideOrientation?: number;
  110359. frontUVs?: Vector4;
  110360. backUVs?: Vector4;
  110361. instance?: Mesh;
  110362. invertUV?: boolean;
  110363. }, scene?: Nullable<Scene>): Mesh;
  110364. }
  110365. }
  110366. declare module BABYLON {
  110367. /**
  110368. * Class containing static functions to help procedurally build meshes
  110369. */
  110370. export class IcoSphereBuilder {
  110371. /**
  110372. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110373. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110374. * * 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`)
  110375. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110376. * * 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
  110377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110380. * @param name defines the name of the mesh
  110381. * @param options defines the options used to create the mesh
  110382. * @param scene defines the hosting scene
  110383. * @returns the icosahedron mesh
  110384. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110385. */
  110386. static CreateIcoSphere(name: string, options: {
  110387. radius?: number;
  110388. radiusX?: number;
  110389. radiusY?: number;
  110390. radiusZ?: number;
  110391. flat?: boolean;
  110392. subdivisions?: number;
  110393. sideOrientation?: number;
  110394. frontUVs?: Vector4;
  110395. backUVs?: Vector4;
  110396. updatable?: boolean;
  110397. }, scene?: Nullable<Scene>): Mesh;
  110398. }
  110399. }
  110400. declare module BABYLON {
  110401. /**
  110402. * Class containing static functions to help procedurally build meshes
  110403. */
  110404. export class DecalBuilder {
  110405. /**
  110406. * Creates a decal mesh.
  110407. * 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
  110408. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110409. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110410. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110411. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110412. * @param name defines the name of the mesh
  110413. * @param sourceMesh defines the mesh where the decal must be applied
  110414. * @param options defines the options used to create the mesh
  110415. * @param scene defines the hosting scene
  110416. * @returns the decal mesh
  110417. * @see https://doc.babylonjs.com/how_to/decals
  110418. */
  110419. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110420. position?: Vector3;
  110421. normal?: Vector3;
  110422. size?: Vector3;
  110423. angle?: number;
  110424. }): Mesh;
  110425. }
  110426. }
  110427. declare module BABYLON {
  110428. /**
  110429. * Class containing static functions to help procedurally build meshes
  110430. */
  110431. export class MeshBuilder {
  110432. /**
  110433. * Creates a box mesh
  110434. * * The parameter `size` sets the size (float) of each box side (default 1)
  110435. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110436. * * 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)
  110437. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110439. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110441. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110442. * @param name defines the name of the mesh
  110443. * @param options defines the options used to create the mesh
  110444. * @param scene defines the hosting scene
  110445. * @returns the box mesh
  110446. */
  110447. static CreateBox(name: string, options: {
  110448. size?: number;
  110449. width?: number;
  110450. height?: number;
  110451. depth?: number;
  110452. faceUV?: Vector4[];
  110453. faceColors?: Color4[];
  110454. sideOrientation?: number;
  110455. frontUVs?: Vector4;
  110456. backUVs?: Vector4;
  110457. updatable?: boolean;
  110458. }, scene?: Nullable<Scene>): Mesh;
  110459. /**
  110460. * Creates a sphere mesh
  110461. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110462. * * 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`)
  110463. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110464. * * 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
  110465. * * 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)
  110466. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110467. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110469. * @param name defines the name of the mesh
  110470. * @param options defines the options used to create the mesh
  110471. * @param scene defines the hosting scene
  110472. * @returns the sphere mesh
  110473. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110474. */
  110475. static CreateSphere(name: string, options: {
  110476. segments?: number;
  110477. diameter?: number;
  110478. diameterX?: number;
  110479. diameterY?: number;
  110480. diameterZ?: number;
  110481. arc?: number;
  110482. slice?: number;
  110483. sideOrientation?: number;
  110484. frontUVs?: Vector4;
  110485. backUVs?: Vector4;
  110486. updatable?: boolean;
  110487. }, scene?: Nullable<Scene>): Mesh;
  110488. /**
  110489. * Creates a plane polygonal mesh. By default, this is a disc
  110490. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110491. * * 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
  110492. * * 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
  110493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110494. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110496. * @param name defines the name of the mesh
  110497. * @param options defines the options used to create the mesh
  110498. * @param scene defines the hosting scene
  110499. * @returns the plane polygonal mesh
  110500. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110501. */
  110502. static CreateDisc(name: string, options: {
  110503. radius?: number;
  110504. tessellation?: number;
  110505. arc?: number;
  110506. updatable?: boolean;
  110507. sideOrientation?: number;
  110508. frontUVs?: Vector4;
  110509. backUVs?: Vector4;
  110510. }, scene?: Nullable<Scene>): Mesh;
  110511. /**
  110512. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110513. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110514. * * 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`)
  110515. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110516. * * 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
  110517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110518. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110520. * @param name defines the name of the mesh
  110521. * @param options defines the options used to create the mesh
  110522. * @param scene defines the hosting scene
  110523. * @returns the icosahedron mesh
  110524. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110525. */
  110526. static CreateIcoSphere(name: string, options: {
  110527. radius?: number;
  110528. radiusX?: number;
  110529. radiusY?: number;
  110530. radiusZ?: number;
  110531. flat?: boolean;
  110532. subdivisions?: number;
  110533. sideOrientation?: number;
  110534. frontUVs?: Vector4;
  110535. backUVs?: Vector4;
  110536. updatable?: boolean;
  110537. }, scene?: Nullable<Scene>): Mesh;
  110538. /**
  110539. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110540. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  110541. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  110542. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  110543. * * 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
  110544. * * 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
  110545. * * 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
  110546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110548. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110549. * * 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
  110550. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  110551. * * 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
  110552. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  110553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110554. * @param name defines the name of the mesh
  110555. * @param options defines the options used to create the mesh
  110556. * @param scene defines the hosting scene
  110557. * @returns the ribbon mesh
  110558. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  110559. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110560. */
  110561. static CreateRibbon(name: string, options: {
  110562. pathArray: Vector3[][];
  110563. closeArray?: boolean;
  110564. closePath?: boolean;
  110565. offset?: number;
  110566. updatable?: boolean;
  110567. sideOrientation?: number;
  110568. frontUVs?: Vector4;
  110569. backUVs?: Vector4;
  110570. instance?: Mesh;
  110571. invertUV?: boolean;
  110572. uvs?: Vector2[];
  110573. colors?: Color4[];
  110574. }, scene?: Nullable<Scene>): Mesh;
  110575. /**
  110576. * Creates a cylinder or a cone mesh
  110577. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110578. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110579. * * 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.
  110580. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110581. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110582. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110583. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110584. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110585. * * 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).
  110586. * * 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
  110587. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110588. * * 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
  110589. * * 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.
  110590. * * If `enclose` is false, a ring surface is one element.
  110591. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110592. * * 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
  110593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110594. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110596. * @param name defines the name of the mesh
  110597. * @param options defines the options used to create the mesh
  110598. * @param scene defines the hosting scene
  110599. * @returns the cylinder mesh
  110600. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110601. */
  110602. static CreateCylinder(name: string, options: {
  110603. height?: number;
  110604. diameterTop?: number;
  110605. diameterBottom?: number;
  110606. diameter?: number;
  110607. tessellation?: number;
  110608. subdivisions?: number;
  110609. arc?: number;
  110610. faceColors?: Color4[];
  110611. faceUV?: Vector4[];
  110612. updatable?: boolean;
  110613. hasRings?: boolean;
  110614. enclose?: boolean;
  110615. sideOrientation?: number;
  110616. frontUVs?: Vector4;
  110617. backUVs?: Vector4;
  110618. }, scene?: Nullable<Scene>): Mesh;
  110619. /**
  110620. * Creates a torus mesh
  110621. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110622. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110623. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110627. * @param name defines the name of the mesh
  110628. * @param options defines the options used to create the mesh
  110629. * @param scene defines the hosting scene
  110630. * @returns the torus mesh
  110631. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110632. */
  110633. static CreateTorus(name: string, options: {
  110634. diameter?: number;
  110635. thickness?: number;
  110636. tessellation?: number;
  110637. updatable?: boolean;
  110638. sideOrientation?: number;
  110639. frontUVs?: Vector4;
  110640. backUVs?: Vector4;
  110641. }, scene?: Nullable<Scene>): Mesh;
  110642. /**
  110643. * Creates a torus knot mesh
  110644. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  110645. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  110646. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  110647. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  110648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110651. * @param name defines the name of the mesh
  110652. * @param options defines the options used to create the mesh
  110653. * @param scene defines the hosting scene
  110654. * @returns the torus knot mesh
  110655. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  110656. */
  110657. static CreateTorusKnot(name: string, options: {
  110658. radius?: number;
  110659. tube?: number;
  110660. radialSegments?: number;
  110661. tubularSegments?: number;
  110662. p?: number;
  110663. q?: number;
  110664. updatable?: boolean;
  110665. sideOrientation?: number;
  110666. frontUVs?: Vector4;
  110667. backUVs?: Vector4;
  110668. }, scene?: Nullable<Scene>): Mesh;
  110669. /**
  110670. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110671. * * 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
  110672. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110673. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110674. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110675. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110676. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110677. * * 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
  110678. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110680. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110681. * @param name defines the name of the new line system
  110682. * @param options defines the options used to create the line system
  110683. * @param scene defines the hosting scene
  110684. * @returns a new line system mesh
  110685. */
  110686. static CreateLineSystem(name: string, options: {
  110687. lines: Vector3[][];
  110688. updatable?: boolean;
  110689. instance?: Nullable<LinesMesh>;
  110690. colors?: Nullable<Color4[][]>;
  110691. useVertexAlpha?: boolean;
  110692. }, scene: Nullable<Scene>): LinesMesh;
  110693. /**
  110694. * Creates a line mesh
  110695. * 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
  110696. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110697. * * The parameter `points` is an array successive Vector3
  110698. * * 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
  110699. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110700. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110701. * * When updating an instance, remember that only point positions can change, not the number of points
  110702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110704. * @param name defines the name of the new line system
  110705. * @param options defines the options used to create the line system
  110706. * @param scene defines the hosting scene
  110707. * @returns a new line mesh
  110708. */
  110709. static CreateLines(name: string, options: {
  110710. points: Vector3[];
  110711. updatable?: boolean;
  110712. instance?: Nullable<LinesMesh>;
  110713. colors?: Color4[];
  110714. useVertexAlpha?: boolean;
  110715. }, scene?: Nullable<Scene>): LinesMesh;
  110716. /**
  110717. * Creates a dashed line mesh
  110718. * * 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
  110719. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110720. * * The parameter `points` is an array successive Vector3
  110721. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110722. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110723. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110724. * * 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
  110725. * * When updating an instance, remember that only point positions can change, not the number of points
  110726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110727. * @param name defines the name of the mesh
  110728. * @param options defines the options used to create the mesh
  110729. * @param scene defines the hosting scene
  110730. * @returns the dashed line mesh
  110731. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110732. */
  110733. static CreateDashedLines(name: string, options: {
  110734. points: Vector3[];
  110735. dashSize?: number;
  110736. gapSize?: number;
  110737. dashNb?: number;
  110738. updatable?: boolean;
  110739. instance?: LinesMesh;
  110740. }, scene?: Nullable<Scene>): LinesMesh;
  110741. /**
  110742. * 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.
  110743. * * 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.
  110744. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110745. * * 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.
  110746. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  110747. * * 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
  110748. * * 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
  110749. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  110750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110752. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  110753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110754. * @param name defines the name of the mesh
  110755. * @param options defines the options used to create the mesh
  110756. * @param scene defines the hosting scene
  110757. * @returns the extruded shape mesh
  110758. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110759. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110760. */
  110761. static ExtrudeShape(name: string, options: {
  110762. shape: Vector3[];
  110763. path: Vector3[];
  110764. scale?: number;
  110765. rotation?: number;
  110766. cap?: number;
  110767. updatable?: boolean;
  110768. sideOrientation?: number;
  110769. frontUVs?: Vector4;
  110770. backUVs?: Vector4;
  110771. instance?: Mesh;
  110772. invertUV?: boolean;
  110773. }, scene?: Nullable<Scene>): Mesh;
  110774. /**
  110775. * Creates an custom extruded shape mesh.
  110776. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  110777. * * 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.
  110778. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110779. * * 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
  110780. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  110781. * * 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
  110782. * * It must returns a float value that will be the scale value applied to the shape on each path point
  110783. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  110784. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  110785. * * 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
  110786. * * 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
  110787. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  110788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110790. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110792. * @param name defines the name of the mesh
  110793. * @param options defines the options used to create the mesh
  110794. * @param scene defines the hosting scene
  110795. * @returns the custom extruded shape mesh
  110796. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  110797. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110798. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110799. */
  110800. static ExtrudeShapeCustom(name: string, options: {
  110801. shape: Vector3[];
  110802. path: Vector3[];
  110803. scaleFunction?: any;
  110804. rotationFunction?: any;
  110805. ribbonCloseArray?: boolean;
  110806. ribbonClosePath?: boolean;
  110807. cap?: number;
  110808. updatable?: boolean;
  110809. sideOrientation?: number;
  110810. frontUVs?: Vector4;
  110811. backUVs?: Vector4;
  110812. instance?: Mesh;
  110813. invertUV?: boolean;
  110814. }, scene?: Nullable<Scene>): Mesh;
  110815. /**
  110816. * Creates lathe mesh.
  110817. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110818. * * 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
  110819. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110820. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110821. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110822. * * 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
  110823. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110824. * * 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
  110825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110827. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110829. * @param name defines the name of the mesh
  110830. * @param options defines the options used to create the mesh
  110831. * @param scene defines the hosting scene
  110832. * @returns the lathe mesh
  110833. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110834. */
  110835. static CreateLathe(name: string, options: {
  110836. shape: Vector3[];
  110837. radius?: number;
  110838. tessellation?: number;
  110839. clip?: number;
  110840. arc?: number;
  110841. closed?: boolean;
  110842. updatable?: boolean;
  110843. sideOrientation?: number;
  110844. frontUVs?: Vector4;
  110845. backUVs?: Vector4;
  110846. cap?: number;
  110847. invertUV?: boolean;
  110848. }, scene?: Nullable<Scene>): Mesh;
  110849. /**
  110850. * Creates a plane mesh
  110851. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  110852. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  110853. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  110854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110857. * @param name defines the name of the mesh
  110858. * @param options defines the options used to create the mesh
  110859. * @param scene defines the hosting scene
  110860. * @returns the plane mesh
  110861. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  110862. */
  110863. static CreatePlane(name: string, options: {
  110864. size?: number;
  110865. width?: number;
  110866. height?: number;
  110867. sideOrientation?: number;
  110868. frontUVs?: Vector4;
  110869. backUVs?: Vector4;
  110870. updatable?: boolean;
  110871. sourcePlane?: Plane;
  110872. }, scene?: Nullable<Scene>): Mesh;
  110873. /**
  110874. * Creates a ground mesh
  110875. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110876. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110878. * @param name defines the name of the mesh
  110879. * @param options defines the options used to create the mesh
  110880. * @param scene defines the hosting scene
  110881. * @returns the ground mesh
  110882. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110883. */
  110884. static CreateGround(name: string, options: {
  110885. width?: number;
  110886. height?: number;
  110887. subdivisions?: number;
  110888. subdivisionsX?: number;
  110889. subdivisionsY?: number;
  110890. updatable?: boolean;
  110891. }, scene?: Nullable<Scene>): Mesh;
  110892. /**
  110893. * Creates a tiled ground mesh
  110894. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110895. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110896. * * 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
  110897. * * 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
  110898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110899. * @param name defines the name of the mesh
  110900. * @param options defines the options used to create the mesh
  110901. * @param scene defines the hosting scene
  110902. * @returns the tiled ground mesh
  110903. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110904. */
  110905. static CreateTiledGround(name: string, options: {
  110906. xmin: number;
  110907. zmin: number;
  110908. xmax: number;
  110909. zmax: number;
  110910. subdivisions?: {
  110911. w: number;
  110912. h: number;
  110913. };
  110914. precision?: {
  110915. w: number;
  110916. h: number;
  110917. };
  110918. updatable?: boolean;
  110919. }, scene?: Nullable<Scene>): Mesh;
  110920. /**
  110921. * Creates a ground mesh from a height map
  110922. * * The parameter `url` sets the URL of the height map image resource.
  110923. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110924. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110925. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110926. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110927. * * 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.
  110928. * * 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).
  110929. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110931. * @param name defines the name of the mesh
  110932. * @param url defines the url to the height map
  110933. * @param options defines the options used to create the mesh
  110934. * @param scene defines the hosting scene
  110935. * @returns the ground mesh
  110936. * @see https://doc.babylonjs.com/babylon101/height_map
  110937. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110938. */
  110939. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110940. width?: number;
  110941. height?: number;
  110942. subdivisions?: number;
  110943. minHeight?: number;
  110944. maxHeight?: number;
  110945. colorFilter?: Color3;
  110946. alphaFilter?: number;
  110947. updatable?: boolean;
  110948. onReady?: (mesh: GroundMesh) => void;
  110949. }, scene?: Nullable<Scene>): GroundMesh;
  110950. /**
  110951. * Creates a polygon mesh
  110952. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110953. * * 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
  110954. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110956. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110957. * * Remember you can only change the shape positions, not their number when updating a polygon
  110958. * @param name defines the name of the mesh
  110959. * @param options defines the options used to create the mesh
  110960. * @param scene defines the hosting scene
  110961. * @param earcutInjection can be used to inject your own earcut reference
  110962. * @returns the polygon mesh
  110963. */
  110964. static CreatePolygon(name: string, options: {
  110965. shape: Vector3[];
  110966. holes?: Vector3[][];
  110967. depth?: number;
  110968. faceUV?: Vector4[];
  110969. faceColors?: Color4[];
  110970. updatable?: boolean;
  110971. sideOrientation?: number;
  110972. frontUVs?: Vector4;
  110973. backUVs?: Vector4;
  110974. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110975. /**
  110976. * Creates an extruded polygon mesh, with depth in the Y direction.
  110977. * * 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)
  110978. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110979. * @param name defines the name of the mesh
  110980. * @param options defines the options used to create the mesh
  110981. * @param scene defines the hosting scene
  110982. * @param earcutInjection can be used to inject your own earcut reference
  110983. * @returns the polygon mesh
  110984. */
  110985. static ExtrudePolygon(name: string, options: {
  110986. shape: Vector3[];
  110987. holes?: Vector3[][];
  110988. depth?: number;
  110989. faceUV?: Vector4[];
  110990. faceColors?: Color4[];
  110991. updatable?: boolean;
  110992. sideOrientation?: number;
  110993. frontUVs?: Vector4;
  110994. backUVs?: Vector4;
  110995. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110996. /**
  110997. * Creates a tube mesh.
  110998. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110999. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  111000. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  111001. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  111002. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  111003. * * 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)
  111004. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  111005. * * 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
  111006. * * 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
  111007. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111008. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111009. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111011. * @param name defines the name of the mesh
  111012. * @param options defines the options used to create the mesh
  111013. * @param scene defines the hosting scene
  111014. * @returns the tube mesh
  111015. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111016. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  111017. */
  111018. static CreateTube(name: string, options: {
  111019. path: Vector3[];
  111020. radius?: number;
  111021. tessellation?: number;
  111022. radiusFunction?: {
  111023. (i: number, distance: number): number;
  111024. };
  111025. cap?: number;
  111026. arc?: number;
  111027. updatable?: boolean;
  111028. sideOrientation?: number;
  111029. frontUVs?: Vector4;
  111030. backUVs?: Vector4;
  111031. instance?: Mesh;
  111032. invertUV?: boolean;
  111033. }, scene?: Nullable<Scene>): Mesh;
  111034. /**
  111035. * Creates a polyhedron mesh
  111036. * * 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
  111037. * * The parameter `size` (positive float, default 1) sets the polygon size
  111038. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  111039. * * 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`
  111040. * * 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
  111041. * * 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)`)
  111042. * * 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
  111043. * * 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
  111044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111045. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111047. * @param name defines the name of the mesh
  111048. * @param options defines the options used to create the mesh
  111049. * @param scene defines the hosting scene
  111050. * @returns the polyhedron mesh
  111051. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  111052. */
  111053. static CreatePolyhedron(name: string, options: {
  111054. type?: number;
  111055. size?: number;
  111056. sizeX?: number;
  111057. sizeY?: number;
  111058. sizeZ?: number;
  111059. custom?: any;
  111060. faceUV?: Vector4[];
  111061. faceColors?: Color4[];
  111062. flat?: boolean;
  111063. updatable?: boolean;
  111064. sideOrientation?: number;
  111065. frontUVs?: Vector4;
  111066. backUVs?: Vector4;
  111067. }, scene?: Nullable<Scene>): Mesh;
  111068. /**
  111069. * Creates a decal mesh.
  111070. * 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
  111071. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  111072. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  111073. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  111074. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  111075. * @param name defines the name of the mesh
  111076. * @param sourceMesh defines the mesh where the decal must be applied
  111077. * @param options defines the options used to create the mesh
  111078. * @param scene defines the hosting scene
  111079. * @returns the decal mesh
  111080. * @see https://doc.babylonjs.com/how_to/decals
  111081. */
  111082. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  111083. position?: Vector3;
  111084. normal?: Vector3;
  111085. size?: Vector3;
  111086. angle?: number;
  111087. }): Mesh;
  111088. }
  111089. }
  111090. declare module BABYLON {
  111091. /**
  111092. * A simplifier interface for future simplification implementations
  111093. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111094. */
  111095. export interface ISimplifier {
  111096. /**
  111097. * Simplification of a given mesh according to the given settings.
  111098. * Since this requires computation, it is assumed that the function runs async.
  111099. * @param settings The settings of the simplification, including quality and distance
  111100. * @param successCallback A callback that will be called after the mesh was simplified.
  111101. * @param errorCallback in case of an error, this callback will be called. optional.
  111102. */
  111103. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  111104. }
  111105. /**
  111106. * Expected simplification settings.
  111107. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  111108. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111109. */
  111110. export interface ISimplificationSettings {
  111111. /**
  111112. * Gets or sets the expected quality
  111113. */
  111114. quality: number;
  111115. /**
  111116. * Gets or sets the distance when this optimized version should be used
  111117. */
  111118. distance: number;
  111119. /**
  111120. * Gets an already optimized mesh
  111121. */
  111122. optimizeMesh?: boolean;
  111123. }
  111124. /**
  111125. * Class used to specify simplification options
  111126. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111127. */
  111128. export class SimplificationSettings implements ISimplificationSettings {
  111129. /** expected quality */
  111130. quality: number;
  111131. /** distance when this optimized version should be used */
  111132. distance: number;
  111133. /** already optimized mesh */
  111134. optimizeMesh?: boolean | undefined;
  111135. /**
  111136. * Creates a SimplificationSettings
  111137. * @param quality expected quality
  111138. * @param distance distance when this optimized version should be used
  111139. * @param optimizeMesh already optimized mesh
  111140. */
  111141. constructor(
  111142. /** expected quality */
  111143. quality: number,
  111144. /** distance when this optimized version should be used */
  111145. distance: number,
  111146. /** already optimized mesh */
  111147. optimizeMesh?: boolean | undefined);
  111148. }
  111149. /**
  111150. * Interface used to define a simplification task
  111151. */
  111152. export interface ISimplificationTask {
  111153. /**
  111154. * Array of settings
  111155. */
  111156. settings: Array<ISimplificationSettings>;
  111157. /**
  111158. * Simplification type
  111159. */
  111160. simplificationType: SimplificationType;
  111161. /**
  111162. * Mesh to simplify
  111163. */
  111164. mesh: Mesh;
  111165. /**
  111166. * Callback called on success
  111167. */
  111168. successCallback?: () => void;
  111169. /**
  111170. * Defines if parallel processing can be used
  111171. */
  111172. parallelProcessing: boolean;
  111173. }
  111174. /**
  111175. * Queue used to order the simplification tasks
  111176. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111177. */
  111178. export class SimplificationQueue {
  111179. private _simplificationArray;
  111180. /**
  111181. * Gets a boolean indicating that the process is still running
  111182. */
  111183. running: boolean;
  111184. /**
  111185. * Creates a new queue
  111186. */
  111187. constructor();
  111188. /**
  111189. * Adds a new simplification task
  111190. * @param task defines a task to add
  111191. */
  111192. addTask(task: ISimplificationTask): void;
  111193. /**
  111194. * Execute next task
  111195. */
  111196. executeNext(): void;
  111197. /**
  111198. * Execute a simplification task
  111199. * @param task defines the task to run
  111200. */
  111201. runSimplification(task: ISimplificationTask): void;
  111202. private getSimplifier;
  111203. }
  111204. /**
  111205. * The implemented types of simplification
  111206. * At the moment only Quadratic Error Decimation is implemented
  111207. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111208. */
  111209. export enum SimplificationType {
  111210. /** Quadratic error decimation */
  111211. QUADRATIC = 0
  111212. }
  111213. }
  111214. declare module BABYLON {
  111215. interface Scene {
  111216. /** @hidden (Backing field) */
  111217. _simplificationQueue: SimplificationQueue;
  111218. /**
  111219. * Gets or sets the simplification queue attached to the scene
  111220. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111221. */
  111222. simplificationQueue: SimplificationQueue;
  111223. }
  111224. interface Mesh {
  111225. /**
  111226. * Simplify the mesh according to the given array of settings.
  111227. * Function will return immediately and will simplify async
  111228. * @param settings a collection of simplification settings
  111229. * @param parallelProcessing should all levels calculate parallel or one after the other
  111230. * @param simplificationType the type of simplification to run
  111231. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  111232. * @returns the current mesh
  111233. */
  111234. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  111235. }
  111236. /**
  111237. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  111238. * created in a scene
  111239. */
  111240. export class SimplicationQueueSceneComponent implements ISceneComponent {
  111241. /**
  111242. * The component name helpfull to identify the component in the list of scene components.
  111243. */
  111244. readonly name: string;
  111245. /**
  111246. * The scene the component belongs to.
  111247. */
  111248. scene: Scene;
  111249. /**
  111250. * Creates a new instance of the component for the given scene
  111251. * @param scene Defines the scene to register the component in
  111252. */
  111253. constructor(scene: Scene);
  111254. /**
  111255. * Registers the component in a given scene
  111256. */
  111257. register(): void;
  111258. /**
  111259. * Rebuilds the elements related to this component in case of
  111260. * context lost for instance.
  111261. */
  111262. rebuild(): void;
  111263. /**
  111264. * Disposes the component and the associated ressources
  111265. */
  111266. dispose(): void;
  111267. private _beforeCameraUpdate;
  111268. }
  111269. }
  111270. declare module BABYLON {
  111271. /**
  111272. * Class used to enable access to IndexedDB
  111273. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  111274. */
  111275. export class Database implements IOfflineProvider {
  111276. private _callbackManifestChecked;
  111277. private _currentSceneUrl;
  111278. private _db;
  111279. private _enableSceneOffline;
  111280. private _enableTexturesOffline;
  111281. private _manifestVersionFound;
  111282. private _mustUpdateRessources;
  111283. private _hasReachedQuota;
  111284. private _isSupported;
  111285. private _idbFactory;
  111286. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  111287. private static IsUASupportingBlobStorage;
  111288. /**
  111289. * Gets a boolean indicating if Database storate is enabled (off by default)
  111290. */
  111291. static IDBStorageEnabled: boolean;
  111292. /**
  111293. * Gets a boolean indicating if scene must be saved in the database
  111294. */
  111295. readonly enableSceneOffline: boolean;
  111296. /**
  111297. * Gets a boolean indicating if textures must be saved in the database
  111298. */
  111299. readonly enableTexturesOffline: boolean;
  111300. /**
  111301. * Creates a new Database
  111302. * @param urlToScene defines the url to load the scene
  111303. * @param callbackManifestChecked defines the callback to use when manifest is checked
  111304. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  111305. */
  111306. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  111307. private static _ParseURL;
  111308. private static _ReturnFullUrlLocation;
  111309. private _checkManifestFile;
  111310. /**
  111311. * Open the database and make it available
  111312. * @param successCallback defines the callback to call on success
  111313. * @param errorCallback defines the callback to call on error
  111314. */
  111315. open(successCallback: () => void, errorCallback: () => void): void;
  111316. /**
  111317. * Loads an image from the database
  111318. * @param url defines the url to load from
  111319. * @param image defines the target DOM image
  111320. */
  111321. loadImage(url: string, image: HTMLImageElement): void;
  111322. private _loadImageFromDBAsync;
  111323. private _saveImageIntoDBAsync;
  111324. private _checkVersionFromDB;
  111325. private _loadVersionFromDBAsync;
  111326. private _saveVersionIntoDBAsync;
  111327. /**
  111328. * Loads a file from database
  111329. * @param url defines the URL to load from
  111330. * @param sceneLoaded defines a callback to call on success
  111331. * @param progressCallBack defines a callback to call when progress changed
  111332. * @param errorCallback defines a callback to call on error
  111333. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  111334. */
  111335. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  111336. private _loadFileAsync;
  111337. private _saveFileAsync;
  111338. /**
  111339. * Validates if xhr data is correct
  111340. * @param xhr defines the request to validate
  111341. * @param dataType defines the expected data type
  111342. * @returns true if data is correct
  111343. */
  111344. private static _ValidateXHRData;
  111345. }
  111346. }
  111347. declare module BABYLON {
  111348. /** @hidden */
  111349. export var gpuUpdateParticlesPixelShader: {
  111350. name: string;
  111351. shader: string;
  111352. };
  111353. }
  111354. declare module BABYLON {
  111355. /** @hidden */
  111356. export var gpuUpdateParticlesVertexShader: {
  111357. name: string;
  111358. shader: string;
  111359. };
  111360. }
  111361. declare module BABYLON {
  111362. /** @hidden */
  111363. export var clipPlaneFragmentDeclaration2: {
  111364. name: string;
  111365. shader: string;
  111366. };
  111367. }
  111368. declare module BABYLON {
  111369. /** @hidden */
  111370. export var gpuRenderParticlesPixelShader: {
  111371. name: string;
  111372. shader: string;
  111373. };
  111374. }
  111375. declare module BABYLON {
  111376. /** @hidden */
  111377. export var clipPlaneVertexDeclaration2: {
  111378. name: string;
  111379. shader: string;
  111380. };
  111381. }
  111382. declare module BABYLON {
  111383. /** @hidden */
  111384. export var gpuRenderParticlesVertexShader: {
  111385. name: string;
  111386. shader: string;
  111387. };
  111388. }
  111389. declare module BABYLON {
  111390. /**
  111391. * This represents a GPU particle system in Babylon
  111392. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  111393. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  111394. */
  111395. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  111396. /**
  111397. * The layer mask we are rendering the particles through.
  111398. */
  111399. layerMask: number;
  111400. private _capacity;
  111401. private _activeCount;
  111402. private _currentActiveCount;
  111403. private _accumulatedCount;
  111404. private _renderEffect;
  111405. private _updateEffect;
  111406. private _buffer0;
  111407. private _buffer1;
  111408. private _spriteBuffer;
  111409. private _updateVAO;
  111410. private _renderVAO;
  111411. private _targetIndex;
  111412. private _sourceBuffer;
  111413. private _targetBuffer;
  111414. private _engine;
  111415. private _currentRenderId;
  111416. private _started;
  111417. private _stopped;
  111418. private _timeDelta;
  111419. private _randomTexture;
  111420. private _randomTexture2;
  111421. private _attributesStrideSize;
  111422. private _updateEffectOptions;
  111423. private _randomTextureSize;
  111424. private _actualFrame;
  111425. private readonly _rawTextureWidth;
  111426. /**
  111427. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  111428. */
  111429. static readonly IsSupported: boolean;
  111430. /**
  111431. * An event triggered when the system is disposed.
  111432. */
  111433. onDisposeObservable: Observable<GPUParticleSystem>;
  111434. /**
  111435. * Gets the maximum number of particles active at the same time.
  111436. * @returns The max number of active particles.
  111437. */
  111438. getCapacity(): number;
  111439. /**
  111440. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  111441. * to override the particles.
  111442. */
  111443. forceDepthWrite: boolean;
  111444. /**
  111445. * Gets or set the number of active particles
  111446. */
  111447. activeParticleCount: number;
  111448. private _preWarmDone;
  111449. /**
  111450. * Is this system ready to be used/rendered
  111451. * @return true if the system is ready
  111452. */
  111453. isReady(): boolean;
  111454. /**
  111455. * Gets if the system has been started. (Note: this will still be true after stop is called)
  111456. * @returns True if it has been started, otherwise false.
  111457. */
  111458. isStarted(): boolean;
  111459. /**
  111460. * Starts the particle system and begins to emit
  111461. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  111462. */
  111463. start(delay?: number): void;
  111464. /**
  111465. * Stops the particle system.
  111466. */
  111467. stop(): void;
  111468. /**
  111469. * Remove all active particles
  111470. */
  111471. reset(): void;
  111472. /**
  111473. * Returns the string "GPUParticleSystem"
  111474. * @returns a string containing the class name
  111475. */
  111476. getClassName(): string;
  111477. private _colorGradientsTexture;
  111478. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  111479. /**
  111480. * Adds a new color gradient
  111481. * @param gradient defines the gradient to use (between 0 and 1)
  111482. * @param color1 defines the color to affect to the specified gradient
  111483. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  111484. * @returns the current particle system
  111485. */
  111486. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  111487. /**
  111488. * Remove a specific color gradient
  111489. * @param gradient defines the gradient to remove
  111490. * @returns the current particle system
  111491. */
  111492. removeColorGradient(gradient: number): GPUParticleSystem;
  111493. private _angularSpeedGradientsTexture;
  111494. private _sizeGradientsTexture;
  111495. private _velocityGradientsTexture;
  111496. private _limitVelocityGradientsTexture;
  111497. private _dragGradientsTexture;
  111498. private _addFactorGradient;
  111499. /**
  111500. * Adds a new size gradient
  111501. * @param gradient defines the gradient to use (between 0 and 1)
  111502. * @param factor defines the size factor to affect to the specified gradient
  111503. * @returns the current particle system
  111504. */
  111505. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  111506. /**
  111507. * Remove a specific size gradient
  111508. * @param gradient defines the gradient to remove
  111509. * @returns the current particle system
  111510. */
  111511. removeSizeGradient(gradient: number): GPUParticleSystem;
  111512. /**
  111513. * Adds a new angular speed gradient
  111514. * @param gradient defines the gradient to use (between 0 and 1)
  111515. * @param factor defines the angular speed to affect to the specified gradient
  111516. * @returns the current particle system
  111517. */
  111518. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  111519. /**
  111520. * Remove a specific angular speed gradient
  111521. * @param gradient defines the gradient to remove
  111522. * @returns the current particle system
  111523. */
  111524. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  111525. /**
  111526. * Adds a new velocity gradient
  111527. * @param gradient defines the gradient to use (between 0 and 1)
  111528. * @param factor defines the velocity to affect to the specified gradient
  111529. * @returns the current particle system
  111530. */
  111531. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111532. /**
  111533. * Remove a specific velocity gradient
  111534. * @param gradient defines the gradient to remove
  111535. * @returns the current particle system
  111536. */
  111537. removeVelocityGradient(gradient: number): GPUParticleSystem;
  111538. /**
  111539. * Adds a new limit velocity gradient
  111540. * @param gradient defines the gradient to use (between 0 and 1)
  111541. * @param factor defines the limit velocity value to affect to the specified gradient
  111542. * @returns the current particle system
  111543. */
  111544. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111545. /**
  111546. * Remove a specific limit velocity gradient
  111547. * @param gradient defines the gradient to remove
  111548. * @returns the current particle system
  111549. */
  111550. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  111551. /**
  111552. * Adds a new drag gradient
  111553. * @param gradient defines the gradient to use (between 0 and 1)
  111554. * @param factor defines the drag value to affect to the specified gradient
  111555. * @returns the current particle system
  111556. */
  111557. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  111558. /**
  111559. * Remove a specific drag gradient
  111560. * @param gradient defines the gradient to remove
  111561. * @returns the current particle system
  111562. */
  111563. removeDragGradient(gradient: number): GPUParticleSystem;
  111564. /**
  111565. * Not supported by GPUParticleSystem
  111566. * @param gradient defines the gradient to use (between 0 and 1)
  111567. * @param factor defines the emit rate value to affect to the specified gradient
  111568. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111569. * @returns the current particle system
  111570. */
  111571. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111572. /**
  111573. * Not supported by GPUParticleSystem
  111574. * @param gradient defines the gradient to remove
  111575. * @returns the current particle system
  111576. */
  111577. removeEmitRateGradient(gradient: number): IParticleSystem;
  111578. /**
  111579. * Not supported by GPUParticleSystem
  111580. * @param gradient defines the gradient to use (between 0 and 1)
  111581. * @param factor defines the start size value to affect to the specified gradient
  111582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111583. * @returns the current particle system
  111584. */
  111585. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111586. /**
  111587. * Not supported by GPUParticleSystem
  111588. * @param gradient defines the gradient to remove
  111589. * @returns the current particle system
  111590. */
  111591. removeStartSizeGradient(gradient: number): IParticleSystem;
  111592. /**
  111593. * Not supported by GPUParticleSystem
  111594. * @param gradient defines the gradient to use (between 0 and 1)
  111595. * @param min defines the color remap minimal range
  111596. * @param max defines the color remap maximal range
  111597. * @returns the current particle system
  111598. */
  111599. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111600. /**
  111601. * Not supported by GPUParticleSystem
  111602. * @param gradient defines the gradient to remove
  111603. * @returns the current particle system
  111604. */
  111605. removeColorRemapGradient(): IParticleSystem;
  111606. /**
  111607. * Not supported by GPUParticleSystem
  111608. * @param gradient defines the gradient to use (between 0 and 1)
  111609. * @param min defines the alpha remap minimal range
  111610. * @param max defines the alpha remap maximal range
  111611. * @returns the current particle system
  111612. */
  111613. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111614. /**
  111615. * Not supported by GPUParticleSystem
  111616. * @param gradient defines the gradient to remove
  111617. * @returns the current particle system
  111618. */
  111619. removeAlphaRemapGradient(): IParticleSystem;
  111620. /**
  111621. * Not supported by GPUParticleSystem
  111622. * @param gradient defines the gradient to use (between 0 and 1)
  111623. * @param color defines the color to affect to the specified gradient
  111624. * @returns the current particle system
  111625. */
  111626. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  111627. /**
  111628. * Not supported by GPUParticleSystem
  111629. * @param gradient defines the gradient to remove
  111630. * @returns the current particle system
  111631. */
  111632. removeRampGradient(): IParticleSystem;
  111633. /**
  111634. * Not supported by GPUParticleSystem
  111635. * @returns the list of ramp gradients
  111636. */
  111637. getRampGradients(): Nullable<Array<Color3Gradient>>;
  111638. /**
  111639. * Not supported by GPUParticleSystem
  111640. * Gets or sets a boolean indicating that ramp gradients must be used
  111641. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  111642. */
  111643. useRampGradients: boolean;
  111644. /**
  111645. * Not supported by GPUParticleSystem
  111646. * @param gradient defines the gradient to use (between 0 and 1)
  111647. * @param factor defines the life time factor to affect to the specified gradient
  111648. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111649. * @returns the current particle system
  111650. */
  111651. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111652. /**
  111653. * Not supported by GPUParticleSystem
  111654. * @param gradient defines the gradient to remove
  111655. * @returns the current particle system
  111656. */
  111657. removeLifeTimeGradient(gradient: number): IParticleSystem;
  111658. /**
  111659. * Instantiates a GPU particle system.
  111660. * 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.
  111661. * @param name The name of the particle system
  111662. * @param options The options used to create the system
  111663. * @param scene The scene the particle system belongs to
  111664. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  111665. */
  111666. constructor(name: string, options: Partial<{
  111667. capacity: number;
  111668. randomTextureSize: number;
  111669. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  111670. protected _reset(): void;
  111671. private _createUpdateVAO;
  111672. private _createRenderVAO;
  111673. private _initialize;
  111674. /** @hidden */
  111675. _recreateUpdateEffect(): void;
  111676. /** @hidden */
  111677. _recreateRenderEffect(): void;
  111678. /**
  111679. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  111680. * @param preWarm defines if we are in the pre-warmimg phase
  111681. */
  111682. animate(preWarm?: boolean): void;
  111683. private _createFactorGradientTexture;
  111684. private _createSizeGradientTexture;
  111685. private _createAngularSpeedGradientTexture;
  111686. private _createVelocityGradientTexture;
  111687. private _createLimitVelocityGradientTexture;
  111688. private _createDragGradientTexture;
  111689. private _createColorGradientTexture;
  111690. /**
  111691. * Renders the particle system in its current state
  111692. * @param preWarm defines if the system should only update the particles but not render them
  111693. * @returns the current number of particles
  111694. */
  111695. render(preWarm?: boolean): number;
  111696. /**
  111697. * Rebuilds the particle system
  111698. */
  111699. rebuild(): void;
  111700. private _releaseBuffers;
  111701. private _releaseVAOs;
  111702. /**
  111703. * Disposes the particle system and free the associated resources
  111704. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  111705. */
  111706. dispose(disposeTexture?: boolean): void;
  111707. /**
  111708. * Clones the particle system.
  111709. * @param name The name of the cloned object
  111710. * @param newEmitter The new emitter to use
  111711. * @returns the cloned particle system
  111712. */
  111713. clone(name: string, newEmitter: any): GPUParticleSystem;
  111714. /**
  111715. * Serializes the particle system to a JSON object.
  111716. * @returns the JSON object
  111717. */
  111718. serialize(): any;
  111719. /**
  111720. * Parses a JSON object to create a GPU particle system.
  111721. * @param parsedParticleSystem The JSON object to parse
  111722. * @param scene The scene to create the particle system in
  111723. * @param rootUrl The root url to use to load external dependencies like texture
  111724. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  111725. * @returns the parsed GPU particle system
  111726. */
  111727. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  111728. }
  111729. }
  111730. declare module BABYLON {
  111731. /**
  111732. * Represents a set of particle systems working together to create a specific effect
  111733. */
  111734. export class ParticleSystemSet implements IDisposable {
  111735. private _emitterCreationOptions;
  111736. private _emitterNode;
  111737. /**
  111738. * Gets the particle system list
  111739. */
  111740. systems: IParticleSystem[];
  111741. /**
  111742. * Gets the emitter node used with this set
  111743. */
  111744. readonly emitterNode: Nullable<TransformNode>;
  111745. /**
  111746. * Creates a new emitter mesh as a sphere
  111747. * @param options defines the options used to create the sphere
  111748. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  111749. * @param scene defines the hosting scene
  111750. */
  111751. setEmitterAsSphere(options: {
  111752. diameter: number;
  111753. segments: number;
  111754. color: Color3;
  111755. }, renderingGroupId: number, scene: Scene): void;
  111756. /**
  111757. * Starts all particle systems of the set
  111758. * @param emitter defines an optional mesh to use as emitter for the particle systems
  111759. */
  111760. start(emitter?: AbstractMesh): void;
  111761. /**
  111762. * Release all associated resources
  111763. */
  111764. dispose(): void;
  111765. /**
  111766. * Serialize the set into a JSON compatible object
  111767. * @returns a JSON compatible representation of the set
  111768. */
  111769. serialize(): any;
  111770. /**
  111771. * Parse a new ParticleSystemSet from a serialized source
  111772. * @param data defines a JSON compatible representation of the set
  111773. * @param scene defines the hosting scene
  111774. * @param gpu defines if we want GPU particles or CPU particles
  111775. * @returns a new ParticleSystemSet
  111776. */
  111777. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  111778. }
  111779. }
  111780. declare module BABYLON {
  111781. /**
  111782. * This class is made for on one-liner static method to help creating particle system set.
  111783. */
  111784. export class ParticleHelper {
  111785. /**
  111786. * Gets or sets base Assets URL
  111787. */
  111788. static BaseAssetsUrl: string;
  111789. /**
  111790. * Create a default particle system that you can tweak
  111791. * @param emitter defines the emitter to use
  111792. * @param capacity defines the system capacity (default is 500 particles)
  111793. * @param scene defines the hosting scene
  111794. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  111795. * @returns the new Particle system
  111796. */
  111797. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  111798. /**
  111799. * This is the main static method (one-liner) of this helper to create different particle systems
  111800. * @param type This string represents the type to the particle system to create
  111801. * @param scene The scene where the particle system should live
  111802. * @param gpu If the system will use gpu
  111803. * @returns the ParticleSystemSet created
  111804. */
  111805. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  111806. /**
  111807. * Static function used to export a particle system to a ParticleSystemSet variable.
  111808. * Please note that the emitter shape is not exported
  111809. * @param systems defines the particle systems to export
  111810. * @returns the created particle system set
  111811. */
  111812. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  111813. }
  111814. }
  111815. declare module BABYLON {
  111816. interface Engine {
  111817. /**
  111818. * Create an effect to use with particle systems.
  111819. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  111820. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  111821. * @param uniformsNames defines a list of attribute names
  111822. * @param samplers defines an array of string used to represent textures
  111823. * @param defines defines the string containing the defines to use to compile the shaders
  111824. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111825. * @param onCompiled defines a function to call when the effect creation is successful
  111826. * @param onError defines a function to call when the effect creation has failed
  111827. * @returns the new Effect
  111828. */
  111829. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  111830. }
  111831. interface Mesh {
  111832. /**
  111833. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  111834. * @returns an array of IParticleSystem
  111835. */
  111836. getEmittedParticleSystems(): IParticleSystem[];
  111837. /**
  111838. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  111839. * @returns an array of IParticleSystem
  111840. */
  111841. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  111842. }
  111843. /**
  111844. * @hidden
  111845. */
  111846. export var _IDoNeedToBeInTheBuild: number;
  111847. }
  111848. declare module BABYLON {
  111849. interface Scene {
  111850. /** @hidden (Backing field) */
  111851. _physicsEngine: Nullable<IPhysicsEngine>;
  111852. /**
  111853. * Gets the current physics engine
  111854. * @returns a IPhysicsEngine or null if none attached
  111855. */
  111856. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  111857. /**
  111858. * Enables physics to the current scene
  111859. * @param gravity defines the scene's gravity for the physics engine
  111860. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  111861. * @return a boolean indicating if the physics engine was initialized
  111862. */
  111863. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  111864. /**
  111865. * Disables and disposes the physics engine associated with the scene
  111866. */
  111867. disablePhysicsEngine(): void;
  111868. /**
  111869. * Gets a boolean indicating if there is an active physics engine
  111870. * @returns a boolean indicating if there is an active physics engine
  111871. */
  111872. isPhysicsEnabled(): boolean;
  111873. /**
  111874. * Deletes a physics compound impostor
  111875. * @param compound defines the compound to delete
  111876. */
  111877. deleteCompoundImpostor(compound: any): void;
  111878. /**
  111879. * An event triggered when physic simulation is about to be run
  111880. */
  111881. onBeforePhysicsObservable: Observable<Scene>;
  111882. /**
  111883. * An event triggered when physic simulation has been done
  111884. */
  111885. onAfterPhysicsObservable: Observable<Scene>;
  111886. }
  111887. interface AbstractMesh {
  111888. /** @hidden */
  111889. _physicsImpostor: Nullable<PhysicsImpostor>;
  111890. /**
  111891. * Gets or sets impostor used for physic simulation
  111892. * @see http://doc.babylonjs.com/features/physics_engine
  111893. */
  111894. physicsImpostor: Nullable<PhysicsImpostor>;
  111895. /**
  111896. * Gets the current physics impostor
  111897. * @see http://doc.babylonjs.com/features/physics_engine
  111898. * @returns a physics impostor or null
  111899. */
  111900. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  111901. /** Apply a physic impulse to the mesh
  111902. * @param force defines the force to apply
  111903. * @param contactPoint defines where to apply the force
  111904. * @returns the current mesh
  111905. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111906. */
  111907. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  111908. /**
  111909. * Creates a physic joint between two meshes
  111910. * @param otherMesh defines the other mesh to use
  111911. * @param pivot1 defines the pivot to use on this mesh
  111912. * @param pivot2 defines the pivot to use on the other mesh
  111913. * @param options defines additional options (can be plugin dependent)
  111914. * @returns the current mesh
  111915. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111916. */
  111917. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  111918. /** @hidden */
  111919. _disposePhysicsObserver: Nullable<Observer<Node>>;
  111920. }
  111921. /**
  111922. * Defines the physics engine scene component responsible to manage a physics engine
  111923. */
  111924. export class PhysicsEngineSceneComponent implements ISceneComponent {
  111925. /**
  111926. * The component name helpful to identify the component in the list of scene components.
  111927. */
  111928. readonly name: string;
  111929. /**
  111930. * The scene the component belongs to.
  111931. */
  111932. scene: Scene;
  111933. /**
  111934. * Creates a new instance of the component for the given scene
  111935. * @param scene Defines the scene to register the component in
  111936. */
  111937. constructor(scene: Scene);
  111938. /**
  111939. * Registers the component in a given scene
  111940. */
  111941. register(): void;
  111942. /**
  111943. * Rebuilds the elements related to this component in case of
  111944. * context lost for instance.
  111945. */
  111946. rebuild(): void;
  111947. /**
  111948. * Disposes the component and the associated ressources
  111949. */
  111950. dispose(): void;
  111951. }
  111952. }
  111953. declare module BABYLON {
  111954. /**
  111955. * A helper for physics simulations
  111956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111957. */
  111958. export class PhysicsHelper {
  111959. private _scene;
  111960. private _physicsEngine;
  111961. /**
  111962. * Initializes the Physics helper
  111963. * @param scene Babylon.js scene
  111964. */
  111965. constructor(scene: Scene);
  111966. /**
  111967. * Applies a radial explosion impulse
  111968. * @param origin the origin of the explosion
  111969. * @param radiusOrEventOptions the radius or the options of radial explosion
  111970. * @param strength the explosion strength
  111971. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111972. * @returns A physics radial explosion event, or null
  111973. */
  111974. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111975. /**
  111976. * Applies a radial explosion force
  111977. * @param origin the origin of the explosion
  111978. * @param radiusOrEventOptions the radius or the options of radial explosion
  111979. * @param strength the explosion strength
  111980. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111981. * @returns A physics radial explosion event, or null
  111982. */
  111983. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111984. /**
  111985. * Creates a gravitational field
  111986. * @param origin the origin of the explosion
  111987. * @param radiusOrEventOptions the radius or the options of radial explosion
  111988. * @param strength the explosion strength
  111989. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111990. * @returns A physics gravitational field event, or null
  111991. */
  111992. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  111993. /**
  111994. * Creates a physics updraft event
  111995. * @param origin the origin of the updraft
  111996. * @param radiusOrEventOptions the radius or the options of the updraft
  111997. * @param strength the strength of the updraft
  111998. * @param height the height of the updraft
  111999. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  112000. * @returns A physics updraft event, or null
  112001. */
  112002. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  112003. /**
  112004. * Creates a physics vortex event
  112005. * @param origin the of the vortex
  112006. * @param radiusOrEventOptions the radius or the options of the vortex
  112007. * @param strength the strength of the vortex
  112008. * @param height the height of the vortex
  112009. * @returns a Physics vortex event, or null
  112010. * A physics vortex event or null
  112011. */
  112012. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  112013. }
  112014. /**
  112015. * Represents a physics radial explosion event
  112016. */
  112017. class PhysicsRadialExplosionEvent {
  112018. private _scene;
  112019. private _options;
  112020. private _sphere;
  112021. private _dataFetched;
  112022. /**
  112023. * Initializes a radial explosioin event
  112024. * @param _scene BabylonJS scene
  112025. * @param _options The options for the vortex event
  112026. */
  112027. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  112028. /**
  112029. * Returns the data related to the radial explosion event (sphere).
  112030. * @returns The radial explosion event data
  112031. */
  112032. getData(): PhysicsRadialExplosionEventData;
  112033. /**
  112034. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  112035. * @param impostor A physics imposter
  112036. * @param origin the origin of the explosion
  112037. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  112038. */
  112039. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  112040. /**
  112041. * Triggers affecterd impostors callbacks
  112042. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  112043. */
  112044. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  112045. /**
  112046. * Disposes the sphere.
  112047. * @param force Specifies if the sphere should be disposed by force
  112048. */
  112049. dispose(force?: boolean): void;
  112050. /*** Helpers ***/
  112051. private _prepareSphere;
  112052. private _intersectsWithSphere;
  112053. }
  112054. /**
  112055. * Represents a gravitational field event
  112056. */
  112057. class PhysicsGravitationalFieldEvent {
  112058. private _physicsHelper;
  112059. private _scene;
  112060. private _origin;
  112061. private _options;
  112062. private _tickCallback;
  112063. private _sphere;
  112064. private _dataFetched;
  112065. /**
  112066. * Initializes the physics gravitational field event
  112067. * @param _physicsHelper A physics helper
  112068. * @param _scene BabylonJS scene
  112069. * @param _origin The origin position of the gravitational field event
  112070. * @param _options The options for the vortex event
  112071. */
  112072. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  112073. /**
  112074. * Returns the data related to the gravitational field event (sphere).
  112075. * @returns A gravitational field event
  112076. */
  112077. getData(): PhysicsGravitationalFieldEventData;
  112078. /**
  112079. * Enables the gravitational field.
  112080. */
  112081. enable(): void;
  112082. /**
  112083. * Disables the gravitational field.
  112084. */
  112085. disable(): void;
  112086. /**
  112087. * Disposes the sphere.
  112088. * @param force The force to dispose from the gravitational field event
  112089. */
  112090. dispose(force?: boolean): void;
  112091. private _tick;
  112092. }
  112093. /**
  112094. * Represents a physics updraft event
  112095. */
  112096. class PhysicsUpdraftEvent {
  112097. private _scene;
  112098. private _origin;
  112099. private _options;
  112100. private _physicsEngine;
  112101. private _originTop;
  112102. private _originDirection;
  112103. private _tickCallback;
  112104. private _cylinder;
  112105. private _cylinderPosition;
  112106. private _dataFetched;
  112107. /**
  112108. * Initializes the physics updraft event
  112109. * @param _scene BabylonJS scene
  112110. * @param _origin The origin position of the updraft
  112111. * @param _options The options for the updraft event
  112112. */
  112113. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  112114. /**
  112115. * Returns the data related to the updraft event (cylinder).
  112116. * @returns A physics updraft event
  112117. */
  112118. getData(): PhysicsUpdraftEventData;
  112119. /**
  112120. * Enables the updraft.
  112121. */
  112122. enable(): void;
  112123. /**
  112124. * Disables the updraft.
  112125. */
  112126. disable(): void;
  112127. /**
  112128. * Disposes the cylinder.
  112129. * @param force Specifies if the updraft should be disposed by force
  112130. */
  112131. dispose(force?: boolean): void;
  112132. private getImpostorHitData;
  112133. private _tick;
  112134. /*** Helpers ***/
  112135. private _prepareCylinder;
  112136. private _intersectsWithCylinder;
  112137. }
  112138. /**
  112139. * Represents a physics vortex event
  112140. */
  112141. class PhysicsVortexEvent {
  112142. private _scene;
  112143. private _origin;
  112144. private _options;
  112145. private _physicsEngine;
  112146. private _originTop;
  112147. private _tickCallback;
  112148. private _cylinder;
  112149. private _cylinderPosition;
  112150. private _dataFetched;
  112151. /**
  112152. * Initializes the physics vortex event
  112153. * @param _scene The BabylonJS scene
  112154. * @param _origin The origin position of the vortex
  112155. * @param _options The options for the vortex event
  112156. */
  112157. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  112158. /**
  112159. * Returns the data related to the vortex event (cylinder).
  112160. * @returns The physics vortex event data
  112161. */
  112162. getData(): PhysicsVortexEventData;
  112163. /**
  112164. * Enables the vortex.
  112165. */
  112166. enable(): void;
  112167. /**
  112168. * Disables the cortex.
  112169. */
  112170. disable(): void;
  112171. /**
  112172. * Disposes the sphere.
  112173. * @param force
  112174. */
  112175. dispose(force?: boolean): void;
  112176. private getImpostorHitData;
  112177. private _tick;
  112178. /*** Helpers ***/
  112179. private _prepareCylinder;
  112180. private _intersectsWithCylinder;
  112181. }
  112182. /**
  112183. * Options fot the radial explosion event
  112184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112185. */
  112186. export class PhysicsRadialExplosionEventOptions {
  112187. /**
  112188. * The radius of the sphere for the radial explosion.
  112189. */
  112190. radius: number;
  112191. /**
  112192. * The strenth of the explosion.
  112193. */
  112194. strength: number;
  112195. /**
  112196. * The strenght of the force in correspondence to the distance of the affected object
  112197. */
  112198. falloff: PhysicsRadialImpulseFalloff;
  112199. /**
  112200. * Sphere options for the radial explosion.
  112201. */
  112202. sphere: {
  112203. segments: number;
  112204. diameter: number;
  112205. };
  112206. /**
  112207. * Sphere options for the radial explosion.
  112208. */
  112209. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  112210. }
  112211. /**
  112212. * Options fot the updraft event
  112213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112214. */
  112215. export class PhysicsUpdraftEventOptions {
  112216. /**
  112217. * The radius of the cylinder for the vortex
  112218. */
  112219. radius: number;
  112220. /**
  112221. * The strenth of the updraft.
  112222. */
  112223. strength: number;
  112224. /**
  112225. * The height of the cylinder for the updraft.
  112226. */
  112227. height: number;
  112228. /**
  112229. * The mode for the the updraft.
  112230. */
  112231. updraftMode: PhysicsUpdraftMode;
  112232. }
  112233. /**
  112234. * Options fot the vortex event
  112235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112236. */
  112237. export class PhysicsVortexEventOptions {
  112238. /**
  112239. * The radius of the cylinder for the vortex
  112240. */
  112241. radius: number;
  112242. /**
  112243. * The strenth of the vortex.
  112244. */
  112245. strength: number;
  112246. /**
  112247. * The height of the cylinder for the vortex.
  112248. */
  112249. height: number;
  112250. /**
  112251. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  112252. */
  112253. centripetalForceThreshold: number;
  112254. /**
  112255. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  112256. */
  112257. centripetalForceMultiplier: number;
  112258. /**
  112259. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  112260. */
  112261. centrifugalForceMultiplier: number;
  112262. /**
  112263. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  112264. */
  112265. updraftForceMultiplier: number;
  112266. }
  112267. /**
  112268. * The strenght of the force in correspondence to the distance of the affected object
  112269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112270. */
  112271. export enum PhysicsRadialImpulseFalloff {
  112272. /** Defines that impulse is constant in strength across it's whole radius */
  112273. Constant = 0,
  112274. /** Defines that impulse gets weaker if it's further from the origin */
  112275. Linear = 1
  112276. }
  112277. /**
  112278. * The strength of the force in correspondence to the distance of the affected object
  112279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112280. */
  112281. export enum PhysicsUpdraftMode {
  112282. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  112283. Center = 0,
  112284. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  112285. Perpendicular = 1
  112286. }
  112287. /**
  112288. * Interface for a physics hit data
  112289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112290. */
  112291. export interface PhysicsHitData {
  112292. /**
  112293. * The force applied at the contact point
  112294. */
  112295. force: Vector3;
  112296. /**
  112297. * The contact point
  112298. */
  112299. contactPoint: Vector3;
  112300. /**
  112301. * The distance from the origin to the contact point
  112302. */
  112303. distanceFromOrigin: number;
  112304. }
  112305. /**
  112306. * Interface for radial explosion event data
  112307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112308. */
  112309. export interface PhysicsRadialExplosionEventData {
  112310. /**
  112311. * A sphere used for the radial explosion event
  112312. */
  112313. sphere: Mesh;
  112314. }
  112315. /**
  112316. * Interface for gravitational field event data
  112317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112318. */
  112319. export interface PhysicsGravitationalFieldEventData {
  112320. /**
  112321. * A sphere mesh used for the gravitational field event
  112322. */
  112323. sphere: Mesh;
  112324. }
  112325. /**
  112326. * Interface for updraft event data
  112327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112328. */
  112329. export interface PhysicsUpdraftEventData {
  112330. /**
  112331. * A cylinder used for the updraft event
  112332. */
  112333. cylinder: Mesh;
  112334. }
  112335. /**
  112336. * Interface for vortex event data
  112337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112338. */
  112339. export interface PhysicsVortexEventData {
  112340. /**
  112341. * A cylinder used for the vortex event
  112342. */
  112343. cylinder: Mesh;
  112344. }
  112345. /**
  112346. * Interface for an affected physics impostor
  112347. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112348. */
  112349. export interface PhysicsAffectedImpostorWithData {
  112350. /**
  112351. * The impostor affected by the effect
  112352. */
  112353. impostor: PhysicsImpostor;
  112354. /**
  112355. * The data about the hit/horce from the explosion
  112356. */
  112357. hitData: PhysicsHitData;
  112358. }
  112359. }
  112360. declare module BABYLON {
  112361. /** @hidden */
  112362. export var blackAndWhitePixelShader: {
  112363. name: string;
  112364. shader: string;
  112365. };
  112366. }
  112367. declare module BABYLON {
  112368. /**
  112369. * Post process used to render in black and white
  112370. */
  112371. export class BlackAndWhitePostProcess extends PostProcess {
  112372. /**
  112373. * Linear about to convert he result to black and white (default: 1)
  112374. */
  112375. degree: number;
  112376. /**
  112377. * Creates a black and white post process
  112378. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  112379. * @param name The name of the effect.
  112380. * @param options The required width/height ratio to downsize to before computing the render pass.
  112381. * @param camera The camera to apply the render pass to.
  112382. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112383. * @param engine The engine which the post process will be applied. (default: current engine)
  112384. * @param reusable If the post process can be reused on the same frame. (default: false)
  112385. */
  112386. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112387. }
  112388. }
  112389. declare module BABYLON {
  112390. /**
  112391. * This represents a set of one or more post processes in Babylon.
  112392. * A post process can be used to apply a shader to a texture after it is rendered.
  112393. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112394. */
  112395. export class PostProcessRenderEffect {
  112396. private _postProcesses;
  112397. private _getPostProcesses;
  112398. private _singleInstance;
  112399. private _cameras;
  112400. private _indicesForCamera;
  112401. /**
  112402. * Name of the effect
  112403. * @hidden
  112404. */
  112405. _name: string;
  112406. /**
  112407. * Instantiates a post process render effect.
  112408. * A post process can be used to apply a shader to a texture after it is rendered.
  112409. * @param engine The engine the effect is tied to
  112410. * @param name The name of the effect
  112411. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  112412. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  112413. */
  112414. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  112415. /**
  112416. * Checks if all the post processes in the effect are supported.
  112417. */
  112418. readonly isSupported: boolean;
  112419. /**
  112420. * Updates the current state of the effect
  112421. * @hidden
  112422. */
  112423. _update(): void;
  112424. /**
  112425. * Attaches the effect on cameras
  112426. * @param cameras The camera to attach to.
  112427. * @hidden
  112428. */
  112429. _attachCameras(cameras: Camera): void;
  112430. /**
  112431. * Attaches the effect on cameras
  112432. * @param cameras The camera to attach to.
  112433. * @hidden
  112434. */
  112435. _attachCameras(cameras: Camera[]): void;
  112436. /**
  112437. * Detaches the effect on cameras
  112438. * @param cameras The camera to detatch from.
  112439. * @hidden
  112440. */
  112441. _detachCameras(cameras: Camera): void;
  112442. /**
  112443. * Detatches the effect on cameras
  112444. * @param cameras The camera to detatch from.
  112445. * @hidden
  112446. */
  112447. _detachCameras(cameras: Camera[]): void;
  112448. /**
  112449. * Enables the effect on given cameras
  112450. * @param cameras The camera to enable.
  112451. * @hidden
  112452. */
  112453. _enable(cameras: Camera): void;
  112454. /**
  112455. * Enables the effect on given cameras
  112456. * @param cameras The camera to enable.
  112457. * @hidden
  112458. */
  112459. _enable(cameras: Nullable<Camera[]>): void;
  112460. /**
  112461. * Disables the effect on the given cameras
  112462. * @param cameras The camera to disable.
  112463. * @hidden
  112464. */
  112465. _disable(cameras: Camera): void;
  112466. /**
  112467. * Disables the effect on the given cameras
  112468. * @param cameras The camera to disable.
  112469. * @hidden
  112470. */
  112471. _disable(cameras: Nullable<Camera[]>): void;
  112472. /**
  112473. * Gets a list of the post processes contained in the effect.
  112474. * @param camera The camera to get the post processes on.
  112475. * @returns The list of the post processes in the effect.
  112476. */
  112477. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  112478. }
  112479. }
  112480. declare module BABYLON {
  112481. /** @hidden */
  112482. export var extractHighlightsPixelShader: {
  112483. name: string;
  112484. shader: string;
  112485. };
  112486. }
  112487. declare module BABYLON {
  112488. /**
  112489. * 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.
  112490. */
  112491. export class ExtractHighlightsPostProcess extends PostProcess {
  112492. /**
  112493. * The luminance threshold, pixels below this value will be set to black.
  112494. */
  112495. threshold: number;
  112496. /** @hidden */
  112497. _exposure: number;
  112498. /**
  112499. * Post process which has the input texture to be used when performing highlight extraction
  112500. * @hidden
  112501. */
  112502. _inputPostProcess: Nullable<PostProcess>;
  112503. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112504. }
  112505. }
  112506. declare module BABYLON {
  112507. /** @hidden */
  112508. export var bloomMergePixelShader: {
  112509. name: string;
  112510. shader: string;
  112511. };
  112512. }
  112513. declare module BABYLON {
  112514. /**
  112515. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112516. */
  112517. export class BloomMergePostProcess extends PostProcess {
  112518. /** Weight of the bloom to be added to the original input. */
  112519. weight: number;
  112520. /**
  112521. * Creates a new instance of @see BloomMergePostProcess
  112522. * @param name The name of the effect.
  112523. * @param originalFromInput Post process which's input will be used for the merge.
  112524. * @param blurred Blurred highlights post process which's output will be used.
  112525. * @param weight Weight of the bloom to be added to the original input.
  112526. * @param options The required width/height ratio to downsize to before computing the render pass.
  112527. * @param camera The camera to apply the render pass to.
  112528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112529. * @param engine The engine which the post process will be applied. (default: current engine)
  112530. * @param reusable If the post process can be reused on the same frame. (default: false)
  112531. * @param textureType Type of textures used when performing the post process. (default: 0)
  112532. * @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)
  112533. */
  112534. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  112535. /** Weight of the bloom to be added to the original input. */
  112536. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112537. }
  112538. }
  112539. declare module BABYLON {
  112540. /**
  112541. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  112542. */
  112543. export class BloomEffect extends PostProcessRenderEffect {
  112544. private bloomScale;
  112545. /**
  112546. * @hidden Internal
  112547. */
  112548. _effects: Array<PostProcess>;
  112549. /**
  112550. * @hidden Internal
  112551. */
  112552. _downscale: ExtractHighlightsPostProcess;
  112553. private _blurX;
  112554. private _blurY;
  112555. private _merge;
  112556. /**
  112557. * The luminance threshold to find bright areas of the image to bloom.
  112558. */
  112559. threshold: number;
  112560. /**
  112561. * The strength of the bloom.
  112562. */
  112563. weight: number;
  112564. /**
  112565. * Specifies the size of the bloom blur kernel, relative to the final output size
  112566. */
  112567. kernel: number;
  112568. /**
  112569. * Creates a new instance of @see BloomEffect
  112570. * @param scene The scene the effect belongs to.
  112571. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  112572. * @param bloomKernel The size of the kernel to be used when applying the blur.
  112573. * @param bloomWeight The the strength of bloom.
  112574. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112575. * @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)
  112576. */
  112577. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  112578. /**
  112579. * Disposes each of the internal effects for a given camera.
  112580. * @param camera The camera to dispose the effect on.
  112581. */
  112582. disposeEffects(camera: Camera): void;
  112583. /**
  112584. * @hidden Internal
  112585. */
  112586. _updateEffects(): void;
  112587. /**
  112588. * Internal
  112589. * @returns if all the contained post processes are ready.
  112590. * @hidden
  112591. */
  112592. _isReady(): boolean;
  112593. }
  112594. }
  112595. declare module BABYLON {
  112596. /** @hidden */
  112597. export var chromaticAberrationPixelShader: {
  112598. name: string;
  112599. shader: string;
  112600. };
  112601. }
  112602. declare module BABYLON {
  112603. /**
  112604. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  112605. */
  112606. export class ChromaticAberrationPostProcess extends PostProcess {
  112607. /**
  112608. * The amount of seperation of rgb channels (default: 30)
  112609. */
  112610. aberrationAmount: number;
  112611. /**
  112612. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  112613. */
  112614. radialIntensity: number;
  112615. /**
  112616. * 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))
  112617. */
  112618. direction: Vector2;
  112619. /**
  112620. * 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))
  112621. */
  112622. centerPosition: Vector2;
  112623. /**
  112624. * Creates a new instance ChromaticAberrationPostProcess
  112625. * @param name The name of the effect.
  112626. * @param screenWidth The width of the screen to apply the effect on.
  112627. * @param screenHeight The height of the screen to apply the effect on.
  112628. * @param options The required width/height ratio to downsize to before computing the render pass.
  112629. * @param camera The camera to apply the render pass to.
  112630. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112631. * @param engine The engine which the post process will be applied. (default: current engine)
  112632. * @param reusable If the post process can be reused on the same frame. (default: false)
  112633. * @param textureType Type of textures used when performing the post process. (default: 0)
  112634. * @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)
  112635. */
  112636. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112637. }
  112638. }
  112639. declare module BABYLON {
  112640. /** @hidden */
  112641. export var circleOfConfusionPixelShader: {
  112642. name: string;
  112643. shader: string;
  112644. };
  112645. }
  112646. declare module BABYLON {
  112647. /**
  112648. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  112649. */
  112650. export class CircleOfConfusionPostProcess extends PostProcess {
  112651. /**
  112652. * 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.
  112653. */
  112654. lensSize: number;
  112655. /**
  112656. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112657. */
  112658. fStop: number;
  112659. /**
  112660. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112661. */
  112662. focusDistance: number;
  112663. /**
  112664. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  112665. */
  112666. focalLength: number;
  112667. private _depthTexture;
  112668. /**
  112669. * Creates a new instance CircleOfConfusionPostProcess
  112670. * @param name The name of the effect.
  112671. * @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.
  112672. * @param options The required width/height ratio to downsize to before computing the render pass.
  112673. * @param camera The camera to apply the render pass to.
  112674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112675. * @param engine The engine which the post process will be applied. (default: current engine)
  112676. * @param reusable If the post process can be reused on the same frame. (default: false)
  112677. * @param textureType Type of textures used when performing the post process. (default: 0)
  112678. * @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)
  112679. */
  112680. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112681. /**
  112682. * 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.
  112683. */
  112684. depthTexture: RenderTargetTexture;
  112685. }
  112686. }
  112687. declare module BABYLON {
  112688. /** @hidden */
  112689. export var colorCorrectionPixelShader: {
  112690. name: string;
  112691. shader: string;
  112692. };
  112693. }
  112694. declare module BABYLON {
  112695. /**
  112696. *
  112697. * This post-process allows the modification of rendered colors by using
  112698. * a 'look-up table' (LUT). This effect is also called Color Grading.
  112699. *
  112700. * The object needs to be provided an url to a texture containing the color
  112701. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  112702. * Use an image editing software to tweak the LUT to match your needs.
  112703. *
  112704. * For an example of a color LUT, see here:
  112705. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  112706. * For explanations on color grading, see here:
  112707. * @see http://udn.epicgames.com/Three/ColorGrading.html
  112708. *
  112709. */
  112710. export class ColorCorrectionPostProcess extends PostProcess {
  112711. private _colorTableTexture;
  112712. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112713. }
  112714. }
  112715. declare module BABYLON {
  112716. /** @hidden */
  112717. export var convolutionPixelShader: {
  112718. name: string;
  112719. shader: string;
  112720. };
  112721. }
  112722. declare module BABYLON {
  112723. /**
  112724. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  112725. * input texture to perform effects such as edge detection or sharpening
  112726. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112727. */
  112728. export class ConvolutionPostProcess extends PostProcess {
  112729. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112730. kernel: number[];
  112731. /**
  112732. * Creates a new instance ConvolutionPostProcess
  112733. * @param name The name of the effect.
  112734. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  112735. * @param options The required width/height ratio to downsize to before computing the render pass.
  112736. * @param camera The camera to apply the render pass to.
  112737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112738. * @param engine The engine which the post process will be applied. (default: current engine)
  112739. * @param reusable If the post process can be reused on the same frame. (default: false)
  112740. * @param textureType Type of textures used when performing the post process. (default: 0)
  112741. */
  112742. constructor(name: string,
  112743. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112744. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112745. /**
  112746. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112747. */
  112748. static EdgeDetect0Kernel: number[];
  112749. /**
  112750. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112751. */
  112752. static EdgeDetect1Kernel: number[];
  112753. /**
  112754. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112755. */
  112756. static EdgeDetect2Kernel: number[];
  112757. /**
  112758. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112759. */
  112760. static SharpenKernel: number[];
  112761. /**
  112762. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112763. */
  112764. static EmbossKernel: number[];
  112765. /**
  112766. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112767. */
  112768. static GaussianKernel: number[];
  112769. }
  112770. }
  112771. declare module BABYLON {
  112772. /**
  112773. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  112774. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  112775. * based on samples that have a large difference in distance than the center pixel.
  112776. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  112777. */
  112778. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  112779. direction: Vector2;
  112780. /**
  112781. * Creates a new instance CircleOfConfusionPostProcess
  112782. * @param name The name of the effect.
  112783. * @param scene The scene the effect belongs to.
  112784. * @param direction The direction the blur should be applied.
  112785. * @param kernel The size of the kernel used to blur.
  112786. * @param options The required width/height ratio to downsize to before computing the render pass.
  112787. * @param camera The camera to apply the render pass to.
  112788. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  112789. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  112790. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112791. * @param engine The engine which the post process will be applied. (default: current engine)
  112792. * @param reusable If the post process can be reused on the same frame. (default: false)
  112793. * @param textureType Type of textures used when performing the post process. (default: 0)
  112794. * @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)
  112795. */
  112796. 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);
  112797. }
  112798. }
  112799. declare module BABYLON {
  112800. /** @hidden */
  112801. export var depthOfFieldMergePixelShader: {
  112802. name: string;
  112803. shader: string;
  112804. };
  112805. }
  112806. declare module BABYLON {
  112807. /**
  112808. * Options to be set when merging outputs from the default pipeline.
  112809. */
  112810. export class DepthOfFieldMergePostProcessOptions {
  112811. /**
  112812. * The original image to merge on top of
  112813. */
  112814. originalFromInput: PostProcess;
  112815. /**
  112816. * Parameters to perform the merge of the depth of field effect
  112817. */
  112818. depthOfField?: {
  112819. circleOfConfusion: PostProcess;
  112820. blurSteps: Array<PostProcess>;
  112821. };
  112822. /**
  112823. * Parameters to perform the merge of bloom effect
  112824. */
  112825. bloom?: {
  112826. blurred: PostProcess;
  112827. weight: number;
  112828. };
  112829. }
  112830. /**
  112831. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112832. */
  112833. export class DepthOfFieldMergePostProcess extends PostProcess {
  112834. private blurSteps;
  112835. /**
  112836. * Creates a new instance of DepthOfFieldMergePostProcess
  112837. * @param name The name of the effect.
  112838. * @param originalFromInput Post process which's input will be used for the merge.
  112839. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  112840. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  112841. * @param options The required width/height ratio to downsize to before computing the render pass.
  112842. * @param camera The camera to apply the render pass to.
  112843. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112844. * @param engine The engine which the post process will be applied. (default: current engine)
  112845. * @param reusable If the post process can be reused on the same frame. (default: false)
  112846. * @param textureType Type of textures used when performing the post process. (default: 0)
  112847. * @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)
  112848. */
  112849. 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);
  112850. /**
  112851. * Updates the effect with the current post process compile time values and recompiles the shader.
  112852. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  112853. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  112854. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  112855. * @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
  112856. * @param onCompiled Called when the shader has been compiled.
  112857. * @param onError Called if there is an error when compiling a shader.
  112858. */
  112859. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  112860. }
  112861. }
  112862. declare module BABYLON {
  112863. /**
  112864. * Specifies the level of max blur that should be applied when using the depth of field effect
  112865. */
  112866. export enum DepthOfFieldEffectBlurLevel {
  112867. /**
  112868. * Subtle blur
  112869. */
  112870. Low = 0,
  112871. /**
  112872. * Medium blur
  112873. */
  112874. Medium = 1,
  112875. /**
  112876. * Large blur
  112877. */
  112878. High = 2
  112879. }
  112880. /**
  112881. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  112882. */
  112883. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  112884. private _circleOfConfusion;
  112885. /**
  112886. * @hidden Internal, blurs from high to low
  112887. */
  112888. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  112889. private _depthOfFieldBlurY;
  112890. private _dofMerge;
  112891. /**
  112892. * @hidden Internal post processes in depth of field effect
  112893. */
  112894. _effects: Array<PostProcess>;
  112895. /**
  112896. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  112897. */
  112898. focalLength: number;
  112899. /**
  112900. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112901. */
  112902. fStop: number;
  112903. /**
  112904. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112905. */
  112906. focusDistance: number;
  112907. /**
  112908. * 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.
  112909. */
  112910. lensSize: number;
  112911. /**
  112912. * Creates a new instance DepthOfFieldEffect
  112913. * @param scene The scene the effect belongs to.
  112914. * @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.
  112915. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112916. * @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)
  112917. */
  112918. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  112919. /**
  112920. * Get the current class name of the current effet
  112921. * @returns "DepthOfFieldEffect"
  112922. */
  112923. getClassName(): string;
  112924. /**
  112925. * 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.
  112926. */
  112927. depthTexture: RenderTargetTexture;
  112928. /**
  112929. * Disposes each of the internal effects for a given camera.
  112930. * @param camera The camera to dispose the effect on.
  112931. */
  112932. disposeEffects(camera: Camera): void;
  112933. /**
  112934. * @hidden Internal
  112935. */
  112936. _updateEffects(): void;
  112937. /**
  112938. * Internal
  112939. * @returns if all the contained post processes are ready.
  112940. * @hidden
  112941. */
  112942. _isReady(): boolean;
  112943. }
  112944. }
  112945. declare module BABYLON {
  112946. /** @hidden */
  112947. export var displayPassPixelShader: {
  112948. name: string;
  112949. shader: string;
  112950. };
  112951. }
  112952. declare module BABYLON {
  112953. /**
  112954. * DisplayPassPostProcess which produces an output the same as it's input
  112955. */
  112956. export class DisplayPassPostProcess extends PostProcess {
  112957. /**
  112958. * Creates the DisplayPassPostProcess
  112959. * @param name The name of the effect.
  112960. * @param options The required width/height ratio to downsize to before computing the render pass.
  112961. * @param camera The camera to apply the render pass to.
  112962. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112963. * @param engine The engine which the post process will be applied. (default: current engine)
  112964. * @param reusable If the post process can be reused on the same frame. (default: false)
  112965. */
  112966. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112967. }
  112968. }
  112969. declare module BABYLON {
  112970. /** @hidden */
  112971. export var filterPixelShader: {
  112972. name: string;
  112973. shader: string;
  112974. };
  112975. }
  112976. declare module BABYLON {
  112977. /**
  112978. * Applies a kernel filter to the image
  112979. */
  112980. export class FilterPostProcess extends PostProcess {
  112981. /** The matrix to be applied to the image */
  112982. kernelMatrix: Matrix;
  112983. /**
  112984. *
  112985. * @param name The name of the effect.
  112986. * @param kernelMatrix The matrix to be applied to the image
  112987. * @param options The required width/height ratio to downsize to before computing the render pass.
  112988. * @param camera The camera to apply the render pass to.
  112989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112990. * @param engine The engine which the post process will be applied. (default: current engine)
  112991. * @param reusable If the post process can be reused on the same frame. (default: false)
  112992. */
  112993. constructor(name: string,
  112994. /** The matrix to be applied to the image */
  112995. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112996. }
  112997. }
  112998. declare module BABYLON {
  112999. /** @hidden */
  113000. export var fxaaPixelShader: {
  113001. name: string;
  113002. shader: string;
  113003. };
  113004. }
  113005. declare module BABYLON {
  113006. /** @hidden */
  113007. export var fxaaVertexShader: {
  113008. name: string;
  113009. shader: string;
  113010. };
  113011. }
  113012. declare module BABYLON {
  113013. /**
  113014. * Fxaa post process
  113015. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  113016. */
  113017. export class FxaaPostProcess extends PostProcess {
  113018. /** @hidden */
  113019. texelWidth: number;
  113020. /** @hidden */
  113021. texelHeight: number;
  113022. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  113023. private _getDefines;
  113024. }
  113025. }
  113026. declare module BABYLON {
  113027. /** @hidden */
  113028. export var grainPixelShader: {
  113029. name: string;
  113030. shader: string;
  113031. };
  113032. }
  113033. declare module BABYLON {
  113034. /**
  113035. * The GrainPostProcess adds noise to the image at mid luminance levels
  113036. */
  113037. export class GrainPostProcess extends PostProcess {
  113038. /**
  113039. * The intensity of the grain added (default: 30)
  113040. */
  113041. intensity: number;
  113042. /**
  113043. * If the grain should be randomized on every frame
  113044. */
  113045. animated: boolean;
  113046. /**
  113047. * Creates a new instance of @see GrainPostProcess
  113048. * @param name The name of the effect.
  113049. * @param options The required width/height ratio to downsize to before computing the render pass.
  113050. * @param camera The camera to apply the render pass to.
  113051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113052. * @param engine The engine which the post process will be applied. (default: current engine)
  113053. * @param reusable If the post process can be reused on the same frame. (default: false)
  113054. * @param textureType Type of textures used when performing the post process. (default: 0)
  113055. * @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)
  113056. */
  113057. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113058. }
  113059. }
  113060. declare module BABYLON {
  113061. /** @hidden */
  113062. export var highlightsPixelShader: {
  113063. name: string;
  113064. shader: string;
  113065. };
  113066. }
  113067. declare module BABYLON {
  113068. /**
  113069. * Extracts highlights from the image
  113070. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  113071. */
  113072. export class HighlightsPostProcess extends PostProcess {
  113073. /**
  113074. * Extracts highlights from the image
  113075. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  113076. * @param name The name of the effect.
  113077. * @param options The required width/height ratio to downsize to before computing the render pass.
  113078. * @param camera The camera to apply the render pass to.
  113079. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113080. * @param engine The engine which the post process will be applied. (default: current engine)
  113081. * @param reusable If the post process can be reused on the same frame. (default: false)
  113082. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  113083. */
  113084. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  113085. }
  113086. }
  113087. declare module BABYLON {
  113088. /** @hidden */
  113089. export var mrtFragmentDeclaration: {
  113090. name: string;
  113091. shader: string;
  113092. };
  113093. }
  113094. declare module BABYLON {
  113095. /** @hidden */
  113096. export var geometryPixelShader: {
  113097. name: string;
  113098. shader: string;
  113099. };
  113100. }
  113101. declare module BABYLON {
  113102. /** @hidden */
  113103. export var geometryVertexShader: {
  113104. name: string;
  113105. shader: string;
  113106. };
  113107. }
  113108. declare module BABYLON {
  113109. /** @hidden */
  113110. interface ISavedTransformationMatrix {
  113111. world: Matrix;
  113112. viewProjection: Matrix;
  113113. }
  113114. /**
  113115. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  113116. */
  113117. export class GeometryBufferRenderer {
  113118. /**
  113119. * Constant used to retrieve the position texture index in the G-Buffer textures array
  113120. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  113121. */
  113122. static readonly POSITION_TEXTURE_TYPE: number;
  113123. /**
  113124. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  113125. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  113126. */
  113127. static readonly VELOCITY_TEXTURE_TYPE: number;
  113128. /**
  113129. * Dictionary used to store the previous transformation matrices of each rendered mesh
  113130. * in order to compute objects velocities when enableVelocity is set to "true"
  113131. * @hidden
  113132. */
  113133. _previousTransformationMatrices: {
  113134. [index: number]: ISavedTransformationMatrix;
  113135. };
  113136. /**
  113137. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  113138. * in order to compute objects velocities when enableVelocity is set to "true"
  113139. * @hidden
  113140. */
  113141. _previousBonesTransformationMatrices: {
  113142. [index: number]: Float32Array;
  113143. };
  113144. /**
  113145. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  113146. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  113147. */
  113148. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  113149. private _scene;
  113150. private _multiRenderTarget;
  113151. private _ratio;
  113152. private _enablePosition;
  113153. private _enableVelocity;
  113154. private _positionIndex;
  113155. private _velocityIndex;
  113156. protected _effect: Effect;
  113157. protected _cachedDefines: string;
  113158. /**
  113159. * Set the render list (meshes to be rendered) used in the G buffer.
  113160. */
  113161. renderList: Mesh[];
  113162. /**
  113163. * Gets wether or not G buffer are supported by the running hardware.
  113164. * This requires draw buffer supports
  113165. */
  113166. readonly isSupported: boolean;
  113167. /**
  113168. * Returns the index of the given texture type in the G-Buffer textures array
  113169. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  113170. * @returns the index of the given texture type in the G-Buffer textures array
  113171. */
  113172. getTextureIndex(textureType: number): number;
  113173. /**
  113174. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  113175. */
  113176. /**
  113177. * Sets whether or not objects positions are enabled for the G buffer.
  113178. */
  113179. enablePosition: boolean;
  113180. /**
  113181. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  113182. */
  113183. /**
  113184. * Sets wether or not objects velocities are enabled for the G buffer.
  113185. */
  113186. enableVelocity: boolean;
  113187. /**
  113188. * Gets the scene associated with the buffer.
  113189. */
  113190. readonly scene: Scene;
  113191. /**
  113192. * Gets the ratio used by the buffer during its creation.
  113193. * How big is the buffer related to the main canvas.
  113194. */
  113195. readonly ratio: number;
  113196. /** @hidden */
  113197. static _SceneComponentInitialization: (scene: Scene) => void;
  113198. /**
  113199. * Creates a new G Buffer for the scene
  113200. * @param scene The scene the buffer belongs to
  113201. * @param ratio How big is the buffer related to the main canvas.
  113202. */
  113203. constructor(scene: Scene, ratio?: number);
  113204. /**
  113205. * Checks wether everything is ready to render a submesh to the G buffer.
  113206. * @param subMesh the submesh to check readiness for
  113207. * @param useInstances is the mesh drawn using instance or not
  113208. * @returns true if ready otherwise false
  113209. */
  113210. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113211. /**
  113212. * Gets the current underlying G Buffer.
  113213. * @returns the buffer
  113214. */
  113215. getGBuffer(): MultiRenderTarget;
  113216. /**
  113217. * Gets the number of samples used to render the buffer (anti aliasing).
  113218. */
  113219. /**
  113220. * Sets the number of samples used to render the buffer (anti aliasing).
  113221. */
  113222. samples: number;
  113223. /**
  113224. * Disposes the renderer and frees up associated resources.
  113225. */
  113226. dispose(): void;
  113227. protected _createRenderTargets(): void;
  113228. private _copyBonesTransformationMatrices;
  113229. }
  113230. }
  113231. declare module BABYLON {
  113232. interface Scene {
  113233. /** @hidden (Backing field) */
  113234. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113235. /**
  113236. * Gets or Sets the current geometry buffer associated to the scene.
  113237. */
  113238. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113239. /**
  113240. * Enables a GeometryBufferRender and associates it with the scene
  113241. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  113242. * @returns the GeometryBufferRenderer
  113243. */
  113244. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  113245. /**
  113246. * Disables the GeometryBufferRender associated with the scene
  113247. */
  113248. disableGeometryBufferRenderer(): void;
  113249. }
  113250. /**
  113251. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  113252. * in several rendering techniques.
  113253. */
  113254. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  113255. /**
  113256. * The component name helpful to identify the component in the list of scene components.
  113257. */
  113258. readonly name: string;
  113259. /**
  113260. * The scene the component belongs to.
  113261. */
  113262. scene: Scene;
  113263. /**
  113264. * Creates a new instance of the component for the given scene
  113265. * @param scene Defines the scene to register the component in
  113266. */
  113267. constructor(scene: Scene);
  113268. /**
  113269. * Registers the component in a given scene
  113270. */
  113271. register(): void;
  113272. /**
  113273. * Rebuilds the elements related to this component in case of
  113274. * context lost for instance.
  113275. */
  113276. rebuild(): void;
  113277. /**
  113278. * Disposes the component and the associated ressources
  113279. */
  113280. dispose(): void;
  113281. private _gatherRenderTargets;
  113282. }
  113283. }
  113284. declare module BABYLON {
  113285. /** @hidden */
  113286. export var motionBlurPixelShader: {
  113287. name: string;
  113288. shader: string;
  113289. };
  113290. }
  113291. declare module BABYLON {
  113292. /**
  113293. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  113294. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  113295. * As an example, all you have to do is to create the post-process:
  113296. * var mb = new BABYLON.MotionBlurPostProcess(
  113297. * 'mb', // The name of the effect.
  113298. * scene, // The scene containing the objects to blur according to their velocity.
  113299. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  113300. * camera // The camera to apply the render pass to.
  113301. * );
  113302. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  113303. */
  113304. export class MotionBlurPostProcess extends PostProcess {
  113305. /**
  113306. * Defines how much the image is blurred by the movement. Default value is equal to 1
  113307. */
  113308. motionStrength: number;
  113309. /**
  113310. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  113311. */
  113312. /**
  113313. * Sets the number of iterations to be used for motion blur quality
  113314. */
  113315. motionBlurSamples: number;
  113316. private _motionBlurSamples;
  113317. private _geometryBufferRenderer;
  113318. /**
  113319. * Creates a new instance MotionBlurPostProcess
  113320. * @param name The name of the effect.
  113321. * @param scene The scene containing the objects to blur according to their velocity.
  113322. * @param options The required width/height ratio to downsize to before computing the render pass.
  113323. * @param camera The camera to apply the render pass to.
  113324. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113325. * @param engine The engine which the post process will be applied. (default: current engine)
  113326. * @param reusable If the post process can be reused on the same frame. (default: false)
  113327. * @param textureType Type of textures used when performing the post process. (default: 0)
  113328. * @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)
  113329. */
  113330. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113331. /**
  113332. * Excludes the given skinned mesh from computing bones velocities.
  113333. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  113334. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  113335. */
  113336. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  113337. /**
  113338. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  113339. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  113340. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  113341. */
  113342. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  113343. /**
  113344. * Disposes the post process.
  113345. * @param camera The camera to dispose the post process on.
  113346. */
  113347. dispose(camera?: Camera): void;
  113348. }
  113349. }
  113350. declare module BABYLON {
  113351. /** @hidden */
  113352. export var refractionPixelShader: {
  113353. name: string;
  113354. shader: string;
  113355. };
  113356. }
  113357. declare module BABYLON {
  113358. /**
  113359. * Post process which applies a refractin texture
  113360. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113361. */
  113362. export class RefractionPostProcess extends PostProcess {
  113363. /** the base color of the refraction (used to taint the rendering) */
  113364. color: Color3;
  113365. /** simulated refraction depth */
  113366. depth: number;
  113367. /** the coefficient of the base color (0 to remove base color tainting) */
  113368. colorLevel: number;
  113369. private _refTexture;
  113370. private _ownRefractionTexture;
  113371. /**
  113372. * Gets or sets the refraction texture
  113373. * Please note that you are responsible for disposing the texture if you set it manually
  113374. */
  113375. refractionTexture: Texture;
  113376. /**
  113377. * Initializes the RefractionPostProcess
  113378. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113379. * @param name The name of the effect.
  113380. * @param refractionTextureUrl Url of the refraction texture to use
  113381. * @param color the base color of the refraction (used to taint the rendering)
  113382. * @param depth simulated refraction depth
  113383. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  113384. * @param camera The camera to apply the render pass to.
  113385. * @param options The required width/height ratio to downsize to before computing the render pass.
  113386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113387. * @param engine The engine which the post process will be applied. (default: current engine)
  113388. * @param reusable If the post process can be reused on the same frame. (default: false)
  113389. */
  113390. constructor(name: string, refractionTextureUrl: string,
  113391. /** the base color of the refraction (used to taint the rendering) */
  113392. color: Color3,
  113393. /** simulated refraction depth */
  113394. depth: number,
  113395. /** the coefficient of the base color (0 to remove base color tainting) */
  113396. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  113397. /**
  113398. * Disposes of the post process
  113399. * @param camera Camera to dispose post process on
  113400. */
  113401. dispose(camera: Camera): void;
  113402. }
  113403. }
  113404. declare module BABYLON {
  113405. /** @hidden */
  113406. export var sharpenPixelShader: {
  113407. name: string;
  113408. shader: string;
  113409. };
  113410. }
  113411. declare module BABYLON {
  113412. /**
  113413. * The SharpenPostProcess applies a sharpen kernel to every pixel
  113414. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  113415. */
  113416. export class SharpenPostProcess extends PostProcess {
  113417. /**
  113418. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  113419. */
  113420. colorAmount: number;
  113421. /**
  113422. * How much sharpness should be applied (default: 0.3)
  113423. */
  113424. edgeAmount: number;
  113425. /**
  113426. * Creates a new instance ConvolutionPostProcess
  113427. * @param name The name of the effect.
  113428. * @param options The required width/height ratio to downsize to before computing the render pass.
  113429. * @param camera The camera to apply the render pass to.
  113430. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113431. * @param engine The engine which the post process will be applied. (default: current engine)
  113432. * @param reusable If the post process can be reused on the same frame. (default: false)
  113433. * @param textureType Type of textures used when performing the post process. (default: 0)
  113434. * @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)
  113435. */
  113436. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113437. }
  113438. }
  113439. declare module BABYLON {
  113440. /**
  113441. * PostProcessRenderPipeline
  113442. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113443. */
  113444. export class PostProcessRenderPipeline {
  113445. private engine;
  113446. private _renderEffects;
  113447. private _renderEffectsForIsolatedPass;
  113448. /**
  113449. * List of inspectable custom properties (used by the Inspector)
  113450. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113451. */
  113452. inspectableCustomProperties: IInspectable[];
  113453. /**
  113454. * @hidden
  113455. */
  113456. protected _cameras: Camera[];
  113457. /** @hidden */
  113458. _name: string;
  113459. /**
  113460. * Gets pipeline name
  113461. */
  113462. readonly name: string;
  113463. /**
  113464. * Initializes a PostProcessRenderPipeline
  113465. * @param engine engine to add the pipeline to
  113466. * @param name name of the pipeline
  113467. */
  113468. constructor(engine: Engine, name: string);
  113469. /**
  113470. * Gets the class name
  113471. * @returns "PostProcessRenderPipeline"
  113472. */
  113473. getClassName(): string;
  113474. /**
  113475. * If all the render effects in the pipeline are supported
  113476. */
  113477. readonly isSupported: boolean;
  113478. /**
  113479. * Adds an effect to the pipeline
  113480. * @param renderEffect the effect to add
  113481. */
  113482. addEffect(renderEffect: PostProcessRenderEffect): void;
  113483. /** @hidden */
  113484. _rebuild(): void;
  113485. /** @hidden */
  113486. _enableEffect(renderEffectName: string, cameras: Camera): void;
  113487. /** @hidden */
  113488. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  113489. /** @hidden */
  113490. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113491. /** @hidden */
  113492. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113493. /** @hidden */
  113494. _attachCameras(cameras: Camera, unique: boolean): void;
  113495. /** @hidden */
  113496. _attachCameras(cameras: Camera[], unique: boolean): void;
  113497. /** @hidden */
  113498. _detachCameras(cameras: Camera): void;
  113499. /** @hidden */
  113500. _detachCameras(cameras: Nullable<Camera[]>): void;
  113501. /** @hidden */
  113502. _update(): void;
  113503. /** @hidden */
  113504. _reset(): void;
  113505. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  113506. /**
  113507. * Disposes of the pipeline
  113508. */
  113509. dispose(): void;
  113510. }
  113511. }
  113512. declare module BABYLON {
  113513. /**
  113514. * PostProcessRenderPipelineManager class
  113515. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113516. */
  113517. export class PostProcessRenderPipelineManager {
  113518. private _renderPipelines;
  113519. /**
  113520. * Initializes a PostProcessRenderPipelineManager
  113521. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113522. */
  113523. constructor();
  113524. /**
  113525. * Gets the list of supported render pipelines
  113526. */
  113527. readonly supportedPipelines: PostProcessRenderPipeline[];
  113528. /**
  113529. * Adds a pipeline to the manager
  113530. * @param renderPipeline The pipeline to add
  113531. */
  113532. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  113533. /**
  113534. * Attaches a camera to the pipeline
  113535. * @param renderPipelineName The name of the pipeline to attach to
  113536. * @param cameras the camera to attach
  113537. * @param unique if the camera can be attached multiple times to the pipeline
  113538. */
  113539. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  113540. /**
  113541. * Detaches a camera from the pipeline
  113542. * @param renderPipelineName The name of the pipeline to detach from
  113543. * @param cameras the camera to detach
  113544. */
  113545. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  113546. /**
  113547. * Enables an effect by name on a pipeline
  113548. * @param renderPipelineName the name of the pipeline to enable the effect in
  113549. * @param renderEffectName the name of the effect to enable
  113550. * @param cameras the cameras that the effect should be enabled on
  113551. */
  113552. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113553. /**
  113554. * Disables an effect by name on a pipeline
  113555. * @param renderPipelineName the name of the pipeline to disable the effect in
  113556. * @param renderEffectName the name of the effect to disable
  113557. * @param cameras the cameras that the effect should be disabled on
  113558. */
  113559. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113560. /**
  113561. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  113562. */
  113563. update(): void;
  113564. /** @hidden */
  113565. _rebuild(): void;
  113566. /**
  113567. * Disposes of the manager and pipelines
  113568. */
  113569. dispose(): void;
  113570. }
  113571. }
  113572. declare module BABYLON {
  113573. interface Scene {
  113574. /** @hidden (Backing field) */
  113575. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113576. /**
  113577. * Gets the postprocess render pipeline manager
  113578. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113579. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113580. */
  113581. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113582. }
  113583. /**
  113584. * Defines the Render Pipeline scene component responsible to rendering pipelines
  113585. */
  113586. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  113587. /**
  113588. * The component name helpfull to identify the component in the list of scene components.
  113589. */
  113590. readonly name: string;
  113591. /**
  113592. * The scene the component belongs to.
  113593. */
  113594. scene: Scene;
  113595. /**
  113596. * Creates a new instance of the component for the given scene
  113597. * @param scene Defines the scene to register the component in
  113598. */
  113599. constructor(scene: Scene);
  113600. /**
  113601. * Registers the component in a given scene
  113602. */
  113603. register(): void;
  113604. /**
  113605. * Rebuilds the elements related to this component in case of
  113606. * context lost for instance.
  113607. */
  113608. rebuild(): void;
  113609. /**
  113610. * Disposes the component and the associated ressources
  113611. */
  113612. dispose(): void;
  113613. private _gatherRenderTargets;
  113614. }
  113615. }
  113616. declare module BABYLON {
  113617. /**
  113618. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  113619. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113620. */
  113621. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113622. private _scene;
  113623. private _camerasToBeAttached;
  113624. /**
  113625. * ID of the sharpen post process,
  113626. */
  113627. private readonly SharpenPostProcessId;
  113628. /**
  113629. * @ignore
  113630. * ID of the image processing post process;
  113631. */
  113632. readonly ImageProcessingPostProcessId: string;
  113633. /**
  113634. * @ignore
  113635. * ID of the Fast Approximate Anti-Aliasing post process;
  113636. */
  113637. readonly FxaaPostProcessId: string;
  113638. /**
  113639. * ID of the chromatic aberration post process,
  113640. */
  113641. private readonly ChromaticAberrationPostProcessId;
  113642. /**
  113643. * ID of the grain post process
  113644. */
  113645. private readonly GrainPostProcessId;
  113646. /**
  113647. * Sharpen post process which will apply a sharpen convolution to enhance edges
  113648. */
  113649. sharpen: SharpenPostProcess;
  113650. private _sharpenEffect;
  113651. private bloom;
  113652. /**
  113653. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  113654. */
  113655. depthOfField: DepthOfFieldEffect;
  113656. /**
  113657. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113658. */
  113659. fxaa: FxaaPostProcess;
  113660. /**
  113661. * Image post processing pass used to perform operations such as tone mapping or color grading.
  113662. */
  113663. imageProcessing: ImageProcessingPostProcess;
  113664. /**
  113665. * Chromatic aberration post process which will shift rgb colors in the image
  113666. */
  113667. chromaticAberration: ChromaticAberrationPostProcess;
  113668. private _chromaticAberrationEffect;
  113669. /**
  113670. * Grain post process which add noise to the image
  113671. */
  113672. grain: GrainPostProcess;
  113673. private _grainEffect;
  113674. /**
  113675. * Glow post process which adds a glow to emissive areas of the image
  113676. */
  113677. private _glowLayer;
  113678. /**
  113679. * Animations which can be used to tweak settings over a period of time
  113680. */
  113681. animations: Animation[];
  113682. private _imageProcessingConfigurationObserver;
  113683. private _sharpenEnabled;
  113684. private _bloomEnabled;
  113685. private _depthOfFieldEnabled;
  113686. private _depthOfFieldBlurLevel;
  113687. private _fxaaEnabled;
  113688. private _imageProcessingEnabled;
  113689. private _defaultPipelineTextureType;
  113690. private _bloomScale;
  113691. private _chromaticAberrationEnabled;
  113692. private _grainEnabled;
  113693. private _buildAllowed;
  113694. /**
  113695. * Gets active scene
  113696. */
  113697. readonly scene: Scene;
  113698. /**
  113699. * Enable or disable the sharpen process from the pipeline
  113700. */
  113701. sharpenEnabled: boolean;
  113702. private _resizeObserver;
  113703. private _hardwareScaleLevel;
  113704. private _bloomKernel;
  113705. /**
  113706. * Specifies the size of the bloom blur kernel, relative to the final output size
  113707. */
  113708. bloomKernel: number;
  113709. /**
  113710. * Specifies the weight of the bloom in the final rendering
  113711. */
  113712. private _bloomWeight;
  113713. /**
  113714. * Specifies the luma threshold for the area that will be blurred by the bloom
  113715. */
  113716. private _bloomThreshold;
  113717. private _hdr;
  113718. /**
  113719. * The strength of the bloom.
  113720. */
  113721. bloomWeight: number;
  113722. /**
  113723. * The strength of the bloom.
  113724. */
  113725. bloomThreshold: number;
  113726. /**
  113727. * The scale of the bloom, lower value will provide better performance.
  113728. */
  113729. bloomScale: number;
  113730. /**
  113731. * Enable or disable the bloom from the pipeline
  113732. */
  113733. bloomEnabled: boolean;
  113734. private _rebuildBloom;
  113735. /**
  113736. * If the depth of field is enabled.
  113737. */
  113738. depthOfFieldEnabled: boolean;
  113739. /**
  113740. * Blur level of the depth of field effect. (Higher blur will effect performance)
  113741. */
  113742. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  113743. /**
  113744. * If the anti aliasing is enabled.
  113745. */
  113746. fxaaEnabled: boolean;
  113747. private _samples;
  113748. /**
  113749. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113750. */
  113751. samples: number;
  113752. /**
  113753. * If image processing is enabled.
  113754. */
  113755. imageProcessingEnabled: boolean;
  113756. /**
  113757. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  113758. */
  113759. glowLayerEnabled: boolean;
  113760. /**
  113761. * Gets the glow layer (or null if not defined)
  113762. */
  113763. readonly glowLayer: Nullable<GlowLayer>;
  113764. /**
  113765. * Enable or disable the chromaticAberration process from the pipeline
  113766. */
  113767. chromaticAberrationEnabled: boolean;
  113768. /**
  113769. * Enable or disable the grain process from the pipeline
  113770. */
  113771. grainEnabled: boolean;
  113772. /**
  113773. * @constructor
  113774. * @param name - The rendering pipeline name (default: "")
  113775. * @param hdr - If high dynamic range textures should be used (default: true)
  113776. * @param scene - The scene linked to this pipeline (default: the last created scene)
  113777. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  113778. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  113779. */
  113780. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  113781. /**
  113782. * Get the class name
  113783. * @returns "DefaultRenderingPipeline"
  113784. */
  113785. getClassName(): string;
  113786. /**
  113787. * Force the compilation of the entire pipeline.
  113788. */
  113789. prepare(): void;
  113790. private _hasCleared;
  113791. private _prevPostProcess;
  113792. private _prevPrevPostProcess;
  113793. private _setAutoClearAndTextureSharing;
  113794. private _depthOfFieldSceneObserver;
  113795. private _buildPipeline;
  113796. private _disposePostProcesses;
  113797. /**
  113798. * Adds a camera to the pipeline
  113799. * @param camera the camera to be added
  113800. */
  113801. addCamera(camera: Camera): void;
  113802. /**
  113803. * Removes a camera from the pipeline
  113804. * @param camera the camera to remove
  113805. */
  113806. removeCamera(camera: Camera): void;
  113807. /**
  113808. * Dispose of the pipeline and stop all post processes
  113809. */
  113810. dispose(): void;
  113811. /**
  113812. * Serialize the rendering pipeline (Used when exporting)
  113813. * @returns the serialized object
  113814. */
  113815. serialize(): any;
  113816. /**
  113817. * Parse the serialized pipeline
  113818. * @param source Source pipeline.
  113819. * @param scene The scene to load the pipeline to.
  113820. * @param rootUrl The URL of the serialized pipeline.
  113821. * @returns An instantiated pipeline from the serialized object.
  113822. */
  113823. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  113824. }
  113825. }
  113826. declare module BABYLON {
  113827. /** @hidden */
  113828. export var lensHighlightsPixelShader: {
  113829. name: string;
  113830. shader: string;
  113831. };
  113832. }
  113833. declare module BABYLON {
  113834. /** @hidden */
  113835. export var depthOfFieldPixelShader: {
  113836. name: string;
  113837. shader: string;
  113838. };
  113839. }
  113840. declare module BABYLON {
  113841. /**
  113842. * BABYLON.JS Chromatic Aberration GLSL Shader
  113843. * Author: Olivier Guyot
  113844. * Separates very slightly R, G and B colors on the edges of the screen
  113845. * Inspired by Francois Tarlier & Martins Upitis
  113846. */
  113847. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  113848. /**
  113849. * @ignore
  113850. * The chromatic aberration PostProcess id in the pipeline
  113851. */
  113852. LensChromaticAberrationEffect: string;
  113853. /**
  113854. * @ignore
  113855. * The highlights enhancing PostProcess id in the pipeline
  113856. */
  113857. HighlightsEnhancingEffect: string;
  113858. /**
  113859. * @ignore
  113860. * The depth-of-field PostProcess id in the pipeline
  113861. */
  113862. LensDepthOfFieldEffect: string;
  113863. private _scene;
  113864. private _depthTexture;
  113865. private _grainTexture;
  113866. private _chromaticAberrationPostProcess;
  113867. private _highlightsPostProcess;
  113868. private _depthOfFieldPostProcess;
  113869. private _edgeBlur;
  113870. private _grainAmount;
  113871. private _chromaticAberration;
  113872. private _distortion;
  113873. private _highlightsGain;
  113874. private _highlightsThreshold;
  113875. private _dofDistance;
  113876. private _dofAperture;
  113877. private _dofDarken;
  113878. private _dofPentagon;
  113879. private _blurNoise;
  113880. /**
  113881. * @constructor
  113882. *
  113883. * Effect parameters are as follow:
  113884. * {
  113885. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113886. * edge_blur: number; // from 0 to x (1 for realism)
  113887. * distortion: number; // from 0 to x (1 for realism)
  113888. * grain_amount: number; // from 0 to 1
  113889. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113890. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113891. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113892. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113893. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113894. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113895. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113896. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113897. * }
  113898. * Note: if an effect parameter is unset, effect is disabled
  113899. *
  113900. * @param name The rendering pipeline name
  113901. * @param parameters - An object containing all parameters (see above)
  113902. * @param scene The scene linked to this pipeline
  113903. * @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)
  113904. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113905. */
  113906. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  113907. /**
  113908. * Get the class name
  113909. * @returns "LensRenderingPipeline"
  113910. */
  113911. getClassName(): string;
  113912. /**
  113913. * Gets associated scene
  113914. */
  113915. readonly scene: Scene;
  113916. /**
  113917. * Gets or sets the edge blur
  113918. */
  113919. edgeBlur: number;
  113920. /**
  113921. * Gets or sets the grain amount
  113922. */
  113923. grainAmount: number;
  113924. /**
  113925. * Gets or sets the chromatic aberration amount
  113926. */
  113927. chromaticAberration: number;
  113928. /**
  113929. * Gets or sets the depth of field aperture
  113930. */
  113931. dofAperture: number;
  113932. /**
  113933. * Gets or sets the edge distortion
  113934. */
  113935. edgeDistortion: number;
  113936. /**
  113937. * Gets or sets the depth of field distortion
  113938. */
  113939. dofDistortion: number;
  113940. /**
  113941. * Gets or sets the darken out of focus amount
  113942. */
  113943. darkenOutOfFocus: number;
  113944. /**
  113945. * Gets or sets a boolean indicating if blur noise is enabled
  113946. */
  113947. blurNoise: boolean;
  113948. /**
  113949. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  113950. */
  113951. pentagonBokeh: boolean;
  113952. /**
  113953. * Gets or sets the highlight grain amount
  113954. */
  113955. highlightsGain: number;
  113956. /**
  113957. * Gets or sets the highlight threshold
  113958. */
  113959. highlightsThreshold: number;
  113960. /**
  113961. * Sets the amount of blur at the edges
  113962. * @param amount blur amount
  113963. */
  113964. setEdgeBlur(amount: number): void;
  113965. /**
  113966. * Sets edge blur to 0
  113967. */
  113968. disableEdgeBlur(): void;
  113969. /**
  113970. * Sets the amout of grain
  113971. * @param amount Amount of grain
  113972. */
  113973. setGrainAmount(amount: number): void;
  113974. /**
  113975. * Set grain amount to 0
  113976. */
  113977. disableGrain(): void;
  113978. /**
  113979. * Sets the chromatic aberration amount
  113980. * @param amount amount of chromatic aberration
  113981. */
  113982. setChromaticAberration(amount: number): void;
  113983. /**
  113984. * Sets chromatic aberration amount to 0
  113985. */
  113986. disableChromaticAberration(): void;
  113987. /**
  113988. * Sets the EdgeDistortion amount
  113989. * @param amount amount of EdgeDistortion
  113990. */
  113991. setEdgeDistortion(amount: number): void;
  113992. /**
  113993. * Sets edge distortion to 0
  113994. */
  113995. disableEdgeDistortion(): void;
  113996. /**
  113997. * Sets the FocusDistance amount
  113998. * @param amount amount of FocusDistance
  113999. */
  114000. setFocusDistance(amount: number): void;
  114001. /**
  114002. * Disables depth of field
  114003. */
  114004. disableDepthOfField(): void;
  114005. /**
  114006. * Sets the Aperture amount
  114007. * @param amount amount of Aperture
  114008. */
  114009. setAperture(amount: number): void;
  114010. /**
  114011. * Sets the DarkenOutOfFocus amount
  114012. * @param amount amount of DarkenOutOfFocus
  114013. */
  114014. setDarkenOutOfFocus(amount: number): void;
  114015. private _pentagonBokehIsEnabled;
  114016. /**
  114017. * Creates a pentagon bokeh effect
  114018. */
  114019. enablePentagonBokeh(): void;
  114020. /**
  114021. * Disables the pentagon bokeh effect
  114022. */
  114023. disablePentagonBokeh(): void;
  114024. /**
  114025. * Enables noise blur
  114026. */
  114027. enableNoiseBlur(): void;
  114028. /**
  114029. * Disables noise blur
  114030. */
  114031. disableNoiseBlur(): void;
  114032. /**
  114033. * Sets the HighlightsGain amount
  114034. * @param amount amount of HighlightsGain
  114035. */
  114036. setHighlightsGain(amount: number): void;
  114037. /**
  114038. * Sets the HighlightsThreshold amount
  114039. * @param amount amount of HighlightsThreshold
  114040. */
  114041. setHighlightsThreshold(amount: number): void;
  114042. /**
  114043. * Disables highlights
  114044. */
  114045. disableHighlights(): void;
  114046. /**
  114047. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  114048. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  114049. */
  114050. dispose(disableDepthRender?: boolean): void;
  114051. private _createChromaticAberrationPostProcess;
  114052. private _createHighlightsPostProcess;
  114053. private _createDepthOfFieldPostProcess;
  114054. private _createGrainTexture;
  114055. }
  114056. }
  114057. declare module BABYLON {
  114058. /** @hidden */
  114059. export var ssao2PixelShader: {
  114060. name: string;
  114061. shader: string;
  114062. };
  114063. }
  114064. declare module BABYLON {
  114065. /** @hidden */
  114066. export var ssaoCombinePixelShader: {
  114067. name: string;
  114068. shader: string;
  114069. };
  114070. }
  114071. declare module BABYLON {
  114072. /**
  114073. * Render pipeline to produce ssao effect
  114074. */
  114075. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  114076. /**
  114077. * @ignore
  114078. * The PassPostProcess id in the pipeline that contains the original scene color
  114079. */
  114080. SSAOOriginalSceneColorEffect: string;
  114081. /**
  114082. * @ignore
  114083. * The SSAO PostProcess id in the pipeline
  114084. */
  114085. SSAORenderEffect: string;
  114086. /**
  114087. * @ignore
  114088. * The horizontal blur PostProcess id in the pipeline
  114089. */
  114090. SSAOBlurHRenderEffect: string;
  114091. /**
  114092. * @ignore
  114093. * The vertical blur PostProcess id in the pipeline
  114094. */
  114095. SSAOBlurVRenderEffect: string;
  114096. /**
  114097. * @ignore
  114098. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114099. */
  114100. SSAOCombineRenderEffect: string;
  114101. /**
  114102. * The output strength of the SSAO post-process. Default value is 1.0.
  114103. */
  114104. totalStrength: number;
  114105. /**
  114106. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  114107. */
  114108. maxZ: number;
  114109. /**
  114110. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  114111. */
  114112. minZAspect: number;
  114113. private _samples;
  114114. /**
  114115. * Number of samples used for the SSAO calculations. Default value is 8
  114116. */
  114117. samples: number;
  114118. private _textureSamples;
  114119. /**
  114120. * Number of samples to use for antialiasing
  114121. */
  114122. textureSamples: number;
  114123. /**
  114124. * Ratio object used for SSAO ratio and blur ratio
  114125. */
  114126. private _ratio;
  114127. /**
  114128. * Dynamically generated sphere sampler.
  114129. */
  114130. private _sampleSphere;
  114131. /**
  114132. * Blur filter offsets
  114133. */
  114134. private _samplerOffsets;
  114135. private _expensiveBlur;
  114136. /**
  114137. * If bilateral blur should be used
  114138. */
  114139. expensiveBlur: boolean;
  114140. /**
  114141. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  114142. */
  114143. radius: number;
  114144. /**
  114145. * The base color of the SSAO post-process
  114146. * The final result is "base + ssao" between [0, 1]
  114147. */
  114148. base: number;
  114149. /**
  114150. * Support test.
  114151. */
  114152. static readonly IsSupported: boolean;
  114153. private _scene;
  114154. private _depthTexture;
  114155. private _normalTexture;
  114156. private _randomTexture;
  114157. private _originalColorPostProcess;
  114158. private _ssaoPostProcess;
  114159. private _blurHPostProcess;
  114160. private _blurVPostProcess;
  114161. private _ssaoCombinePostProcess;
  114162. private _firstUpdate;
  114163. /**
  114164. * Gets active scene
  114165. */
  114166. readonly scene: Scene;
  114167. /**
  114168. * @constructor
  114169. * @param name The rendering pipeline name
  114170. * @param scene The scene linked to this pipeline
  114171. * @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 }
  114172. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114173. */
  114174. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  114175. /**
  114176. * Get the class name
  114177. * @returns "SSAO2RenderingPipeline"
  114178. */
  114179. getClassName(): string;
  114180. /**
  114181. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114182. */
  114183. dispose(disableGeometryBufferRenderer?: boolean): void;
  114184. private _createBlurPostProcess;
  114185. /** @hidden */
  114186. _rebuild(): void;
  114187. private _bits;
  114188. private _radicalInverse_VdC;
  114189. private _hammersley;
  114190. private _hemisphereSample_uniform;
  114191. private _generateHemisphere;
  114192. private _createSSAOPostProcess;
  114193. private _createSSAOCombinePostProcess;
  114194. private _createRandomTexture;
  114195. /**
  114196. * Serialize the rendering pipeline (Used when exporting)
  114197. * @returns the serialized object
  114198. */
  114199. serialize(): any;
  114200. /**
  114201. * Parse the serialized pipeline
  114202. * @param source Source pipeline.
  114203. * @param scene The scene to load the pipeline to.
  114204. * @param rootUrl The URL of the serialized pipeline.
  114205. * @returns An instantiated pipeline from the serialized object.
  114206. */
  114207. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  114208. }
  114209. }
  114210. declare module BABYLON {
  114211. /** @hidden */
  114212. export var ssaoPixelShader: {
  114213. name: string;
  114214. shader: string;
  114215. };
  114216. }
  114217. declare module BABYLON {
  114218. /**
  114219. * Render pipeline to produce ssao effect
  114220. */
  114221. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  114222. /**
  114223. * @ignore
  114224. * The PassPostProcess id in the pipeline that contains the original scene color
  114225. */
  114226. SSAOOriginalSceneColorEffect: string;
  114227. /**
  114228. * @ignore
  114229. * The SSAO PostProcess id in the pipeline
  114230. */
  114231. SSAORenderEffect: string;
  114232. /**
  114233. * @ignore
  114234. * The horizontal blur PostProcess id in the pipeline
  114235. */
  114236. SSAOBlurHRenderEffect: string;
  114237. /**
  114238. * @ignore
  114239. * The vertical blur PostProcess id in the pipeline
  114240. */
  114241. SSAOBlurVRenderEffect: string;
  114242. /**
  114243. * @ignore
  114244. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114245. */
  114246. SSAOCombineRenderEffect: string;
  114247. /**
  114248. * The output strength of the SSAO post-process. Default value is 1.0.
  114249. */
  114250. totalStrength: number;
  114251. /**
  114252. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  114253. */
  114254. radius: number;
  114255. /**
  114256. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  114257. * Must not be equal to fallOff and superior to fallOff.
  114258. * Default value is 0.0075
  114259. */
  114260. area: number;
  114261. /**
  114262. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  114263. * Must not be equal to area and inferior to area.
  114264. * Default value is 0.000001
  114265. */
  114266. fallOff: number;
  114267. /**
  114268. * The base color of the SSAO post-process
  114269. * The final result is "base + ssao" between [0, 1]
  114270. */
  114271. base: number;
  114272. private _scene;
  114273. private _depthTexture;
  114274. private _randomTexture;
  114275. private _originalColorPostProcess;
  114276. private _ssaoPostProcess;
  114277. private _blurHPostProcess;
  114278. private _blurVPostProcess;
  114279. private _ssaoCombinePostProcess;
  114280. private _firstUpdate;
  114281. /**
  114282. * Gets active scene
  114283. */
  114284. readonly scene: Scene;
  114285. /**
  114286. * @constructor
  114287. * @param name - The rendering pipeline name
  114288. * @param scene - The scene linked to this pipeline
  114289. * @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 }
  114290. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  114291. */
  114292. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  114293. /**
  114294. * Get the class name
  114295. * @returns "SSAORenderingPipeline"
  114296. */
  114297. getClassName(): string;
  114298. /**
  114299. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114300. */
  114301. dispose(disableDepthRender?: boolean): void;
  114302. private _createBlurPostProcess;
  114303. /** @hidden */
  114304. _rebuild(): void;
  114305. private _createSSAOPostProcess;
  114306. private _createSSAOCombinePostProcess;
  114307. private _createRandomTexture;
  114308. }
  114309. }
  114310. declare module BABYLON {
  114311. /** @hidden */
  114312. export var standardPixelShader: {
  114313. name: string;
  114314. shader: string;
  114315. };
  114316. }
  114317. declare module BABYLON {
  114318. /**
  114319. * Standard rendering pipeline
  114320. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114321. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  114322. */
  114323. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  114324. /**
  114325. * Public members
  114326. */
  114327. /**
  114328. * Post-process which contains the original scene color before the pipeline applies all the effects
  114329. */
  114330. originalPostProcess: Nullable<PostProcess>;
  114331. /**
  114332. * Post-process used to down scale an image x4
  114333. */
  114334. downSampleX4PostProcess: Nullable<PostProcess>;
  114335. /**
  114336. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  114337. */
  114338. brightPassPostProcess: Nullable<PostProcess>;
  114339. /**
  114340. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  114341. */
  114342. blurHPostProcesses: PostProcess[];
  114343. /**
  114344. * Post-process array storing all the vertical blur post-processes used by the pipeline
  114345. */
  114346. blurVPostProcesses: PostProcess[];
  114347. /**
  114348. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  114349. */
  114350. textureAdderPostProcess: Nullable<PostProcess>;
  114351. /**
  114352. * Post-process used to create volumetric lighting effect
  114353. */
  114354. volumetricLightPostProcess: Nullable<PostProcess>;
  114355. /**
  114356. * Post-process used to smooth the previous volumetric light post-process on the X axis
  114357. */
  114358. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  114359. /**
  114360. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  114361. */
  114362. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  114363. /**
  114364. * Post-process used to merge the volumetric light effect and the real scene color
  114365. */
  114366. volumetricLightMergePostProces: Nullable<PostProcess>;
  114367. /**
  114368. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  114369. */
  114370. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  114371. /**
  114372. * Base post-process used to calculate the average luminance of the final image for HDR
  114373. */
  114374. luminancePostProcess: Nullable<PostProcess>;
  114375. /**
  114376. * Post-processes used to create down sample post-processes in order to get
  114377. * the average luminance of the final image for HDR
  114378. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  114379. */
  114380. luminanceDownSamplePostProcesses: PostProcess[];
  114381. /**
  114382. * Post-process used to create a HDR effect (light adaptation)
  114383. */
  114384. hdrPostProcess: Nullable<PostProcess>;
  114385. /**
  114386. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  114387. */
  114388. textureAdderFinalPostProcess: Nullable<PostProcess>;
  114389. /**
  114390. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  114391. */
  114392. lensFlareFinalPostProcess: Nullable<PostProcess>;
  114393. /**
  114394. * Post-process used to merge the final HDR post-process and the real scene color
  114395. */
  114396. hdrFinalPostProcess: Nullable<PostProcess>;
  114397. /**
  114398. * Post-process used to create a lens flare effect
  114399. */
  114400. lensFlarePostProcess: Nullable<PostProcess>;
  114401. /**
  114402. * Post-process that merges the result of the lens flare post-process and the real scene color
  114403. */
  114404. lensFlareComposePostProcess: Nullable<PostProcess>;
  114405. /**
  114406. * Post-process used to create a motion blur effect
  114407. */
  114408. motionBlurPostProcess: Nullable<PostProcess>;
  114409. /**
  114410. * Post-process used to create a depth of field effect
  114411. */
  114412. depthOfFieldPostProcess: Nullable<PostProcess>;
  114413. /**
  114414. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  114415. */
  114416. fxaaPostProcess: Nullable<FxaaPostProcess>;
  114417. /**
  114418. * Represents the brightness threshold in order to configure the illuminated surfaces
  114419. */
  114420. brightThreshold: number;
  114421. /**
  114422. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  114423. */
  114424. blurWidth: number;
  114425. /**
  114426. * Sets if the blur for highlighted surfaces must be only horizontal
  114427. */
  114428. horizontalBlur: boolean;
  114429. /**
  114430. * Gets the overall exposure used by the pipeline
  114431. */
  114432. /**
  114433. * Sets the overall exposure used by the pipeline
  114434. */
  114435. exposure: number;
  114436. /**
  114437. * Texture used typically to simulate "dirty" on camera lens
  114438. */
  114439. lensTexture: Nullable<Texture>;
  114440. /**
  114441. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  114442. */
  114443. volumetricLightCoefficient: number;
  114444. /**
  114445. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  114446. */
  114447. volumetricLightPower: number;
  114448. /**
  114449. * Used the set the blur intensity to smooth the volumetric lights
  114450. */
  114451. volumetricLightBlurScale: number;
  114452. /**
  114453. * Light (spot or directional) used to generate the volumetric lights rays
  114454. * The source light must have a shadow generate so the pipeline can get its
  114455. * depth map
  114456. */
  114457. sourceLight: Nullable<SpotLight | DirectionalLight>;
  114458. /**
  114459. * For eye adaptation, represents the minimum luminance the eye can see
  114460. */
  114461. hdrMinimumLuminance: number;
  114462. /**
  114463. * For eye adaptation, represents the decrease luminance speed
  114464. */
  114465. hdrDecreaseRate: number;
  114466. /**
  114467. * For eye adaptation, represents the increase luminance speed
  114468. */
  114469. hdrIncreaseRate: number;
  114470. /**
  114471. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114472. */
  114473. /**
  114474. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114475. */
  114476. hdrAutoExposure: boolean;
  114477. /**
  114478. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  114479. */
  114480. lensColorTexture: Nullable<Texture>;
  114481. /**
  114482. * The overall strengh for the lens flare effect
  114483. */
  114484. lensFlareStrength: number;
  114485. /**
  114486. * Dispersion coefficient for lens flare ghosts
  114487. */
  114488. lensFlareGhostDispersal: number;
  114489. /**
  114490. * Main lens flare halo width
  114491. */
  114492. lensFlareHaloWidth: number;
  114493. /**
  114494. * Based on the lens distortion effect, defines how much the lens flare result
  114495. * is distorted
  114496. */
  114497. lensFlareDistortionStrength: number;
  114498. /**
  114499. * Lens star texture must be used to simulate rays on the flares and is available
  114500. * in the documentation
  114501. */
  114502. lensStarTexture: Nullable<Texture>;
  114503. /**
  114504. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  114505. * flare effect by taking account of the dirt texture
  114506. */
  114507. lensFlareDirtTexture: Nullable<Texture>;
  114508. /**
  114509. * Represents the focal length for the depth of field effect
  114510. */
  114511. depthOfFieldDistance: number;
  114512. /**
  114513. * Represents the blur intensity for the blurred part of the depth of field effect
  114514. */
  114515. depthOfFieldBlurWidth: number;
  114516. /**
  114517. * For motion blur, defines how much the image is blurred by the movement
  114518. */
  114519. motionStrength: number;
  114520. /**
  114521. * List of animations for the pipeline (IAnimatable implementation)
  114522. */
  114523. animations: Animation[];
  114524. /**
  114525. * Private members
  114526. */
  114527. private _scene;
  114528. private _currentDepthOfFieldSource;
  114529. private _basePostProcess;
  114530. private _fixedExposure;
  114531. private _currentExposure;
  114532. private _hdrAutoExposure;
  114533. private _hdrCurrentLuminance;
  114534. private _floatTextureType;
  114535. private _ratio;
  114536. private _bloomEnabled;
  114537. private _depthOfFieldEnabled;
  114538. private _vlsEnabled;
  114539. private _lensFlareEnabled;
  114540. private _hdrEnabled;
  114541. private _motionBlurEnabled;
  114542. private _fxaaEnabled;
  114543. private _motionBlurSamples;
  114544. private _volumetricLightStepsCount;
  114545. private _samples;
  114546. /**
  114547. * @ignore
  114548. * Specifies if the bloom pipeline is enabled
  114549. */
  114550. BloomEnabled: boolean;
  114551. /**
  114552. * @ignore
  114553. * Specifies if the depth of field pipeline is enabed
  114554. */
  114555. DepthOfFieldEnabled: boolean;
  114556. /**
  114557. * @ignore
  114558. * Specifies if the lens flare pipeline is enabed
  114559. */
  114560. LensFlareEnabled: boolean;
  114561. /**
  114562. * @ignore
  114563. * Specifies if the HDR pipeline is enabled
  114564. */
  114565. HDREnabled: boolean;
  114566. /**
  114567. * @ignore
  114568. * Specifies if the volumetric lights scattering effect is enabled
  114569. */
  114570. VLSEnabled: boolean;
  114571. /**
  114572. * @ignore
  114573. * Specifies if the motion blur effect is enabled
  114574. */
  114575. MotionBlurEnabled: boolean;
  114576. /**
  114577. * Specifies if anti-aliasing is enabled
  114578. */
  114579. fxaaEnabled: boolean;
  114580. /**
  114581. * Specifies the number of steps used to calculate the volumetric lights
  114582. * Typically in interval [50, 200]
  114583. */
  114584. volumetricLightStepsCount: number;
  114585. /**
  114586. * Specifies the number of samples used for the motion blur effect
  114587. * Typically in interval [16, 64]
  114588. */
  114589. motionBlurSamples: number;
  114590. /**
  114591. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  114592. */
  114593. samples: number;
  114594. /**
  114595. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114596. * @constructor
  114597. * @param name The rendering pipeline name
  114598. * @param scene The scene linked to this pipeline
  114599. * @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)
  114600. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  114601. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114602. */
  114603. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  114604. private _buildPipeline;
  114605. private _createDownSampleX4PostProcess;
  114606. private _createBrightPassPostProcess;
  114607. private _createBlurPostProcesses;
  114608. private _createTextureAdderPostProcess;
  114609. private _createVolumetricLightPostProcess;
  114610. private _createLuminancePostProcesses;
  114611. private _createHdrPostProcess;
  114612. private _createLensFlarePostProcess;
  114613. private _createDepthOfFieldPostProcess;
  114614. private _createMotionBlurPostProcess;
  114615. private _getDepthTexture;
  114616. private _disposePostProcesses;
  114617. /**
  114618. * Dispose of the pipeline and stop all post processes
  114619. */
  114620. dispose(): void;
  114621. /**
  114622. * Serialize the rendering pipeline (Used when exporting)
  114623. * @returns the serialized object
  114624. */
  114625. serialize(): any;
  114626. /**
  114627. * Parse the serialized pipeline
  114628. * @param source Source pipeline.
  114629. * @param scene The scene to load the pipeline to.
  114630. * @param rootUrl The URL of the serialized pipeline.
  114631. * @returns An instantiated pipeline from the serialized object.
  114632. */
  114633. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  114634. /**
  114635. * Luminance steps
  114636. */
  114637. static LuminanceSteps: number;
  114638. }
  114639. }
  114640. declare module BABYLON {
  114641. /** @hidden */
  114642. export var tonemapPixelShader: {
  114643. name: string;
  114644. shader: string;
  114645. };
  114646. }
  114647. declare module BABYLON {
  114648. /** Defines operator used for tonemapping */
  114649. export enum TonemappingOperator {
  114650. /** Hable */
  114651. Hable = 0,
  114652. /** Reinhard */
  114653. Reinhard = 1,
  114654. /** HejiDawson */
  114655. HejiDawson = 2,
  114656. /** Photographic */
  114657. Photographic = 3
  114658. }
  114659. /**
  114660. * Defines a post process to apply tone mapping
  114661. */
  114662. export class TonemapPostProcess extends PostProcess {
  114663. private _operator;
  114664. /** Defines the required exposure adjustement */
  114665. exposureAdjustment: number;
  114666. /**
  114667. * Creates a new TonemapPostProcess
  114668. * @param name defines the name of the postprocess
  114669. * @param _operator defines the operator to use
  114670. * @param exposureAdjustment defines the required exposure adjustement
  114671. * @param camera defines the camera to use (can be null)
  114672. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  114673. * @param engine defines the hosting engine (can be ignore if camera is set)
  114674. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  114675. */
  114676. constructor(name: string, _operator: TonemappingOperator,
  114677. /** Defines the required exposure adjustement */
  114678. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  114679. }
  114680. }
  114681. declare module BABYLON {
  114682. /** @hidden */
  114683. export var depthVertexShader: {
  114684. name: string;
  114685. shader: string;
  114686. };
  114687. }
  114688. declare module BABYLON {
  114689. /** @hidden */
  114690. export var volumetricLightScatteringPixelShader: {
  114691. name: string;
  114692. shader: string;
  114693. };
  114694. }
  114695. declare module BABYLON {
  114696. /** @hidden */
  114697. export var volumetricLightScatteringPassPixelShader: {
  114698. name: string;
  114699. shader: string;
  114700. };
  114701. }
  114702. declare module BABYLON {
  114703. /**
  114704. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  114705. */
  114706. export class VolumetricLightScatteringPostProcess extends PostProcess {
  114707. private _volumetricLightScatteringPass;
  114708. private _volumetricLightScatteringRTT;
  114709. private _viewPort;
  114710. private _screenCoordinates;
  114711. private _cachedDefines;
  114712. /**
  114713. * If not undefined, the mesh position is computed from the attached node position
  114714. */
  114715. attachedNode: {
  114716. position: Vector3;
  114717. };
  114718. /**
  114719. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  114720. */
  114721. customMeshPosition: Vector3;
  114722. /**
  114723. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  114724. */
  114725. useCustomMeshPosition: boolean;
  114726. /**
  114727. * If the post-process should inverse the light scattering direction
  114728. */
  114729. invert: boolean;
  114730. /**
  114731. * The internal mesh used by the post-process
  114732. */
  114733. mesh: Mesh;
  114734. /**
  114735. * @hidden
  114736. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  114737. */
  114738. useDiffuseColor: boolean;
  114739. /**
  114740. * Array containing the excluded meshes not rendered in the internal pass
  114741. */
  114742. excludedMeshes: AbstractMesh[];
  114743. /**
  114744. * Controls the overall intensity of the post-process
  114745. */
  114746. exposure: number;
  114747. /**
  114748. * Dissipates each sample's contribution in range [0, 1]
  114749. */
  114750. decay: number;
  114751. /**
  114752. * Controls the overall intensity of each sample
  114753. */
  114754. weight: number;
  114755. /**
  114756. * Controls the density of each sample
  114757. */
  114758. density: number;
  114759. /**
  114760. * @constructor
  114761. * @param name The post-process name
  114762. * @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)
  114763. * @param camera The camera that the post-process will be attached to
  114764. * @param mesh The mesh used to create the light scattering
  114765. * @param samples The post-process quality, default 100
  114766. * @param samplingModeThe post-process filtering mode
  114767. * @param engine The babylon engine
  114768. * @param reusable If the post-process is reusable
  114769. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  114770. */
  114771. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  114772. /**
  114773. * Returns the string "VolumetricLightScatteringPostProcess"
  114774. * @returns "VolumetricLightScatteringPostProcess"
  114775. */
  114776. getClassName(): string;
  114777. private _isReady;
  114778. /**
  114779. * Sets the new light position for light scattering effect
  114780. * @param position The new custom light position
  114781. */
  114782. setCustomMeshPosition(position: Vector3): void;
  114783. /**
  114784. * Returns the light position for light scattering effect
  114785. * @return Vector3 The custom light position
  114786. */
  114787. getCustomMeshPosition(): Vector3;
  114788. /**
  114789. * Disposes the internal assets and detaches the post-process from the camera
  114790. */
  114791. dispose(camera: Camera): void;
  114792. /**
  114793. * Returns the render target texture used by the post-process
  114794. * @return the render target texture used by the post-process
  114795. */
  114796. getPass(): RenderTargetTexture;
  114797. private _meshExcluded;
  114798. private _createPass;
  114799. private _updateMeshScreenCoordinates;
  114800. /**
  114801. * Creates a default mesh for the Volumeric Light Scattering post-process
  114802. * @param name The mesh name
  114803. * @param scene The scene where to create the mesh
  114804. * @return the default mesh
  114805. */
  114806. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  114807. }
  114808. }
  114809. declare module BABYLON {
  114810. interface Scene {
  114811. /** @hidden (Backing field) */
  114812. _boundingBoxRenderer: BoundingBoxRenderer;
  114813. /** @hidden (Backing field) */
  114814. _forceShowBoundingBoxes: boolean;
  114815. /**
  114816. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  114817. */
  114818. forceShowBoundingBoxes: boolean;
  114819. /**
  114820. * Gets the bounding box renderer associated with the scene
  114821. * @returns a BoundingBoxRenderer
  114822. */
  114823. getBoundingBoxRenderer(): BoundingBoxRenderer;
  114824. }
  114825. interface AbstractMesh {
  114826. /** @hidden (Backing field) */
  114827. _showBoundingBox: boolean;
  114828. /**
  114829. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  114830. */
  114831. showBoundingBox: boolean;
  114832. }
  114833. /**
  114834. * Component responsible of rendering the bounding box of the meshes in a scene.
  114835. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  114836. */
  114837. export class BoundingBoxRenderer implements ISceneComponent {
  114838. /**
  114839. * The component name helpfull to identify the component in the list of scene components.
  114840. */
  114841. readonly name: string;
  114842. /**
  114843. * The scene the component belongs to.
  114844. */
  114845. scene: Scene;
  114846. /**
  114847. * Color of the bounding box lines placed in front of an object
  114848. */
  114849. frontColor: Color3;
  114850. /**
  114851. * Color of the bounding box lines placed behind an object
  114852. */
  114853. backColor: Color3;
  114854. /**
  114855. * Defines if the renderer should show the back lines or not
  114856. */
  114857. showBackLines: boolean;
  114858. /**
  114859. * @hidden
  114860. */
  114861. renderList: SmartArray<BoundingBox>;
  114862. private _colorShader;
  114863. private _vertexBuffers;
  114864. private _indexBuffer;
  114865. /**
  114866. * Instantiates a new bounding box renderer in a scene.
  114867. * @param scene the scene the renderer renders in
  114868. */
  114869. constructor(scene: Scene);
  114870. /**
  114871. * Registers the component in a given scene
  114872. */
  114873. register(): void;
  114874. private _evaluateSubMesh;
  114875. private _activeMesh;
  114876. private _prepareRessources;
  114877. private _createIndexBuffer;
  114878. /**
  114879. * Rebuilds the elements related to this component in case of
  114880. * context lost for instance.
  114881. */
  114882. rebuild(): void;
  114883. /**
  114884. * @hidden
  114885. */
  114886. reset(): void;
  114887. /**
  114888. * Render the bounding boxes of a specific rendering group
  114889. * @param renderingGroupId defines the rendering group to render
  114890. */
  114891. render(renderingGroupId: number): void;
  114892. /**
  114893. * In case of occlusion queries, we can render the occlusion bounding box through this method
  114894. * @param mesh Define the mesh to render the occlusion bounding box for
  114895. */
  114896. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  114897. /**
  114898. * Dispose and release the resources attached to this renderer.
  114899. */
  114900. dispose(): void;
  114901. }
  114902. }
  114903. declare module BABYLON {
  114904. /** @hidden */
  114905. export var depthPixelShader: {
  114906. name: string;
  114907. shader: string;
  114908. };
  114909. }
  114910. declare module BABYLON {
  114911. /**
  114912. * This represents a depth renderer in Babylon.
  114913. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  114914. */
  114915. export class DepthRenderer {
  114916. private _scene;
  114917. private _depthMap;
  114918. private _effect;
  114919. private _cachedDefines;
  114920. private _camera;
  114921. /**
  114922. * Specifiess that the depth renderer will only be used within
  114923. * the camera it is created for.
  114924. * This can help forcing its rendering during the camera processing.
  114925. */
  114926. useOnlyInActiveCamera: boolean;
  114927. /** @hidden */
  114928. static _SceneComponentInitialization: (scene: Scene) => void;
  114929. /**
  114930. * Instantiates a depth renderer
  114931. * @param scene The scene the renderer belongs to
  114932. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  114933. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  114934. */
  114935. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  114936. /**
  114937. * Creates the depth rendering effect and checks if the effect is ready.
  114938. * @param subMesh The submesh to be used to render the depth map of
  114939. * @param useInstances If multiple world instances should be used
  114940. * @returns if the depth renderer is ready to render the depth map
  114941. */
  114942. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114943. /**
  114944. * Gets the texture which the depth map will be written to.
  114945. * @returns The depth map texture
  114946. */
  114947. getDepthMap(): RenderTargetTexture;
  114948. /**
  114949. * Disposes of the depth renderer.
  114950. */
  114951. dispose(): void;
  114952. }
  114953. }
  114954. declare module BABYLON {
  114955. interface Scene {
  114956. /** @hidden (Backing field) */
  114957. _depthRenderer: {
  114958. [id: string]: DepthRenderer;
  114959. };
  114960. /**
  114961. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  114962. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  114963. * @returns the created depth renderer
  114964. */
  114965. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  114966. /**
  114967. * Disables a depth renderer for a given camera
  114968. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  114969. */
  114970. disableDepthRenderer(camera?: Nullable<Camera>): void;
  114971. }
  114972. /**
  114973. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  114974. * in several rendering techniques.
  114975. */
  114976. export class DepthRendererSceneComponent implements ISceneComponent {
  114977. /**
  114978. * The component name helpfull to identify the component in the list of scene components.
  114979. */
  114980. readonly name: string;
  114981. /**
  114982. * The scene the component belongs to.
  114983. */
  114984. scene: Scene;
  114985. /**
  114986. * Creates a new instance of the component for the given scene
  114987. * @param scene Defines the scene to register the component in
  114988. */
  114989. constructor(scene: Scene);
  114990. /**
  114991. * Registers the component in a given scene
  114992. */
  114993. register(): void;
  114994. /**
  114995. * Rebuilds the elements related to this component in case of
  114996. * context lost for instance.
  114997. */
  114998. rebuild(): void;
  114999. /**
  115000. * Disposes the component and the associated ressources
  115001. */
  115002. dispose(): void;
  115003. private _gatherRenderTargets;
  115004. private _gatherActiveCameraRenderTargets;
  115005. }
  115006. }
  115007. declare module BABYLON {
  115008. /** @hidden */
  115009. export var outlinePixelShader: {
  115010. name: string;
  115011. shader: string;
  115012. };
  115013. }
  115014. declare module BABYLON {
  115015. /** @hidden */
  115016. export var outlineVertexShader: {
  115017. name: string;
  115018. shader: string;
  115019. };
  115020. }
  115021. declare module BABYLON {
  115022. interface Scene {
  115023. /** @hidden */
  115024. _outlineRenderer: OutlineRenderer;
  115025. /**
  115026. * Gets the outline renderer associated with the scene
  115027. * @returns a OutlineRenderer
  115028. */
  115029. getOutlineRenderer(): OutlineRenderer;
  115030. }
  115031. interface AbstractMesh {
  115032. /** @hidden (Backing field) */
  115033. _renderOutline: boolean;
  115034. /**
  115035. * Gets or sets a boolean indicating if the outline must be rendered as well
  115036. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  115037. */
  115038. renderOutline: boolean;
  115039. /** @hidden (Backing field) */
  115040. _renderOverlay: boolean;
  115041. /**
  115042. * Gets or sets a boolean indicating if the overlay must be rendered as well
  115043. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  115044. */
  115045. renderOverlay: boolean;
  115046. }
  115047. /**
  115048. * This class is responsible to draw bothe outline/overlay of meshes.
  115049. * It should not be used directly but through the available method on mesh.
  115050. */
  115051. export class OutlineRenderer implements ISceneComponent {
  115052. /**
  115053. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  115054. */
  115055. private static _StencilReference;
  115056. /**
  115057. * The name of the component. Each component must have a unique name.
  115058. */
  115059. name: string;
  115060. /**
  115061. * The scene the component belongs to.
  115062. */
  115063. scene: Scene;
  115064. /**
  115065. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  115066. */
  115067. zOffset: number;
  115068. private _engine;
  115069. private _effect;
  115070. private _cachedDefines;
  115071. private _savedDepthWrite;
  115072. /**
  115073. * Instantiates a new outline renderer. (There could be only one per scene).
  115074. * @param scene Defines the scene it belongs to
  115075. */
  115076. constructor(scene: Scene);
  115077. /**
  115078. * Register the component to one instance of a scene.
  115079. */
  115080. register(): void;
  115081. /**
  115082. * Rebuilds the elements related to this component in case of
  115083. * context lost for instance.
  115084. */
  115085. rebuild(): void;
  115086. /**
  115087. * Disposes the component and the associated ressources.
  115088. */
  115089. dispose(): void;
  115090. /**
  115091. * Renders the outline in the canvas.
  115092. * @param subMesh Defines the sumesh to render
  115093. * @param batch Defines the batch of meshes in case of instances
  115094. * @param useOverlay Defines if the rendering is for the overlay or the outline
  115095. */
  115096. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  115097. /**
  115098. * Returns whether or not the outline renderer is ready for a given submesh.
  115099. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  115100. * @param subMesh Defines the submesh to check readyness for
  115101. * @param useInstances Defines wheter wee are trying to render instances or not
  115102. * @returns true if ready otherwise false
  115103. */
  115104. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115105. private _beforeRenderingMesh;
  115106. private _afterRenderingMesh;
  115107. }
  115108. }
  115109. declare module BABYLON {
  115110. /**
  115111. * Defines the list of states available for a task inside a AssetsManager
  115112. */
  115113. export enum AssetTaskState {
  115114. /**
  115115. * Initialization
  115116. */
  115117. INIT = 0,
  115118. /**
  115119. * Running
  115120. */
  115121. RUNNING = 1,
  115122. /**
  115123. * Done
  115124. */
  115125. DONE = 2,
  115126. /**
  115127. * Error
  115128. */
  115129. ERROR = 3
  115130. }
  115131. /**
  115132. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  115133. */
  115134. export abstract class AbstractAssetTask {
  115135. /**
  115136. * Task name
  115137. */ name: string;
  115138. /**
  115139. * Callback called when the task is successful
  115140. */
  115141. onSuccess: (task: any) => void;
  115142. /**
  115143. * Callback called when the task is not successful
  115144. */
  115145. onError: (task: any, message?: string, exception?: any) => void;
  115146. /**
  115147. * Creates a new AssetsManager
  115148. * @param name defines the name of the task
  115149. */
  115150. constructor(
  115151. /**
  115152. * Task name
  115153. */ name: string);
  115154. private _isCompleted;
  115155. private _taskState;
  115156. private _errorObject;
  115157. /**
  115158. * Get if the task is completed
  115159. */
  115160. readonly isCompleted: boolean;
  115161. /**
  115162. * Gets the current state of the task
  115163. */
  115164. readonly taskState: AssetTaskState;
  115165. /**
  115166. * Gets the current error object (if task is in error)
  115167. */
  115168. readonly errorObject: {
  115169. message?: string;
  115170. exception?: any;
  115171. };
  115172. /**
  115173. * Internal only
  115174. * @hidden
  115175. */
  115176. _setErrorObject(message?: string, exception?: any): void;
  115177. /**
  115178. * Execute the current task
  115179. * @param scene defines the scene where you want your assets to be loaded
  115180. * @param onSuccess is a callback called when the task is successfully executed
  115181. * @param onError is a callback called if an error occurs
  115182. */
  115183. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115184. /**
  115185. * Execute the current task
  115186. * @param scene defines the scene where you want your assets to be loaded
  115187. * @param onSuccess is a callback called when the task is successfully executed
  115188. * @param onError is a callback called if an error occurs
  115189. */
  115190. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115191. /**
  115192. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  115193. * This can be used with failed tasks that have the reason for failure fixed.
  115194. */
  115195. reset(): void;
  115196. private onErrorCallback;
  115197. private onDoneCallback;
  115198. }
  115199. /**
  115200. * Define the interface used by progress events raised during assets loading
  115201. */
  115202. export interface IAssetsProgressEvent {
  115203. /**
  115204. * Defines the number of remaining tasks to process
  115205. */
  115206. remainingCount: number;
  115207. /**
  115208. * Defines the total number of tasks
  115209. */
  115210. totalCount: number;
  115211. /**
  115212. * Defines the task that was just processed
  115213. */
  115214. task: AbstractAssetTask;
  115215. }
  115216. /**
  115217. * Class used to share progress information about assets loading
  115218. */
  115219. export class AssetsProgressEvent implements IAssetsProgressEvent {
  115220. /**
  115221. * Defines the number of remaining tasks to process
  115222. */
  115223. remainingCount: number;
  115224. /**
  115225. * Defines the total number of tasks
  115226. */
  115227. totalCount: number;
  115228. /**
  115229. * Defines the task that was just processed
  115230. */
  115231. task: AbstractAssetTask;
  115232. /**
  115233. * Creates a AssetsProgressEvent
  115234. * @param remainingCount defines the number of remaining tasks to process
  115235. * @param totalCount defines the total number of tasks
  115236. * @param task defines the task that was just processed
  115237. */
  115238. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  115239. }
  115240. /**
  115241. * Define a task used by AssetsManager to load meshes
  115242. */
  115243. export class MeshAssetTask extends AbstractAssetTask {
  115244. /**
  115245. * Defines the name of the task
  115246. */
  115247. name: string;
  115248. /**
  115249. * Defines the list of mesh's names you want to load
  115250. */
  115251. meshesNames: any;
  115252. /**
  115253. * Defines the root url to use as a base to load your meshes and associated resources
  115254. */
  115255. rootUrl: string;
  115256. /**
  115257. * Defines the filename of the scene to load from
  115258. */
  115259. sceneFilename: string;
  115260. /**
  115261. * Gets the list of loaded meshes
  115262. */
  115263. loadedMeshes: Array<AbstractMesh>;
  115264. /**
  115265. * Gets the list of loaded particle systems
  115266. */
  115267. loadedParticleSystems: Array<IParticleSystem>;
  115268. /**
  115269. * Gets the list of loaded skeletons
  115270. */
  115271. loadedSkeletons: Array<Skeleton>;
  115272. /**
  115273. * Gets the list of loaded animation groups
  115274. */
  115275. loadedAnimationGroups: Array<AnimationGroup>;
  115276. /**
  115277. * Callback called when the task is successful
  115278. */
  115279. onSuccess: (task: MeshAssetTask) => void;
  115280. /**
  115281. * Callback called when the task is successful
  115282. */
  115283. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  115284. /**
  115285. * Creates a new MeshAssetTask
  115286. * @param name defines the name of the task
  115287. * @param meshesNames defines the list of mesh's names you want to load
  115288. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  115289. * @param sceneFilename defines the filename of the scene to load from
  115290. */
  115291. constructor(
  115292. /**
  115293. * Defines the name of the task
  115294. */
  115295. name: string,
  115296. /**
  115297. * Defines the list of mesh's names you want to load
  115298. */
  115299. meshesNames: any,
  115300. /**
  115301. * Defines the root url to use as a base to load your meshes and associated resources
  115302. */
  115303. rootUrl: string,
  115304. /**
  115305. * Defines the filename of the scene to load from
  115306. */
  115307. sceneFilename: string);
  115308. /**
  115309. * Execute the current task
  115310. * @param scene defines the scene where you want your assets to be loaded
  115311. * @param onSuccess is a callback called when the task is successfully executed
  115312. * @param onError is a callback called if an error occurs
  115313. */
  115314. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115315. }
  115316. /**
  115317. * Define a task used by AssetsManager to load text content
  115318. */
  115319. export class TextFileAssetTask extends AbstractAssetTask {
  115320. /**
  115321. * Defines the name of the task
  115322. */
  115323. name: string;
  115324. /**
  115325. * Defines the location of the file to load
  115326. */
  115327. url: string;
  115328. /**
  115329. * Gets the loaded text string
  115330. */
  115331. text: string;
  115332. /**
  115333. * Callback called when the task is successful
  115334. */
  115335. onSuccess: (task: TextFileAssetTask) => void;
  115336. /**
  115337. * Callback called when the task is successful
  115338. */
  115339. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  115340. /**
  115341. * Creates a new TextFileAssetTask object
  115342. * @param name defines the name of the task
  115343. * @param url defines the location of the file to load
  115344. */
  115345. constructor(
  115346. /**
  115347. * Defines the name of the task
  115348. */
  115349. name: string,
  115350. /**
  115351. * Defines the location of the file to load
  115352. */
  115353. url: string);
  115354. /**
  115355. * Execute the current task
  115356. * @param scene defines the scene where you want your assets to be loaded
  115357. * @param onSuccess is a callback called when the task is successfully executed
  115358. * @param onError is a callback called if an error occurs
  115359. */
  115360. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115361. }
  115362. /**
  115363. * Define a task used by AssetsManager to load binary data
  115364. */
  115365. export class BinaryFileAssetTask extends AbstractAssetTask {
  115366. /**
  115367. * Defines the name of the task
  115368. */
  115369. name: string;
  115370. /**
  115371. * Defines the location of the file to load
  115372. */
  115373. url: string;
  115374. /**
  115375. * Gets the lodaded data (as an array buffer)
  115376. */
  115377. data: ArrayBuffer;
  115378. /**
  115379. * Callback called when the task is successful
  115380. */
  115381. onSuccess: (task: BinaryFileAssetTask) => void;
  115382. /**
  115383. * Callback called when the task is successful
  115384. */
  115385. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  115386. /**
  115387. * Creates a new BinaryFileAssetTask object
  115388. * @param name defines the name of the new task
  115389. * @param url defines the location of the file to load
  115390. */
  115391. constructor(
  115392. /**
  115393. * Defines the name of the task
  115394. */
  115395. name: string,
  115396. /**
  115397. * Defines the location of the file to load
  115398. */
  115399. url: string);
  115400. /**
  115401. * Execute the current task
  115402. * @param scene defines the scene where you want your assets to be loaded
  115403. * @param onSuccess is a callback called when the task is successfully executed
  115404. * @param onError is a callback called if an error occurs
  115405. */
  115406. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115407. }
  115408. /**
  115409. * Define a task used by AssetsManager to load images
  115410. */
  115411. export class ImageAssetTask extends AbstractAssetTask {
  115412. /**
  115413. * Defines the name of the task
  115414. */
  115415. name: string;
  115416. /**
  115417. * Defines the location of the image to load
  115418. */
  115419. url: string;
  115420. /**
  115421. * Gets the loaded images
  115422. */
  115423. image: HTMLImageElement;
  115424. /**
  115425. * Callback called when the task is successful
  115426. */
  115427. onSuccess: (task: ImageAssetTask) => void;
  115428. /**
  115429. * Callback called when the task is successful
  115430. */
  115431. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  115432. /**
  115433. * Creates a new ImageAssetTask
  115434. * @param name defines the name of the task
  115435. * @param url defines the location of the image to load
  115436. */
  115437. constructor(
  115438. /**
  115439. * Defines the name of the task
  115440. */
  115441. name: string,
  115442. /**
  115443. * Defines the location of the image to load
  115444. */
  115445. url: string);
  115446. /**
  115447. * Execute the current task
  115448. * @param scene defines the scene where you want your assets to be loaded
  115449. * @param onSuccess is a callback called when the task is successfully executed
  115450. * @param onError is a callback called if an error occurs
  115451. */
  115452. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115453. }
  115454. /**
  115455. * Defines the interface used by texture loading tasks
  115456. */
  115457. export interface ITextureAssetTask<TEX extends BaseTexture> {
  115458. /**
  115459. * Gets the loaded texture
  115460. */
  115461. texture: TEX;
  115462. }
  115463. /**
  115464. * Define a task used by AssetsManager to load 2D textures
  115465. */
  115466. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  115467. /**
  115468. * Defines the name of the task
  115469. */
  115470. name: string;
  115471. /**
  115472. * Defines the location of the file to load
  115473. */
  115474. url: string;
  115475. /**
  115476. * Defines if mipmap should not be generated (default is false)
  115477. */
  115478. noMipmap?: boolean | undefined;
  115479. /**
  115480. * Defines if texture must be inverted on Y axis (default is false)
  115481. */
  115482. invertY?: boolean | undefined;
  115483. /**
  115484. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115485. */
  115486. samplingMode: number;
  115487. /**
  115488. * Gets the loaded texture
  115489. */
  115490. texture: Texture;
  115491. /**
  115492. * Callback called when the task is successful
  115493. */
  115494. onSuccess: (task: TextureAssetTask) => void;
  115495. /**
  115496. * Callback called when the task is successful
  115497. */
  115498. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  115499. /**
  115500. * Creates a new TextureAssetTask object
  115501. * @param name defines the name of the task
  115502. * @param url defines the location of the file to load
  115503. * @param noMipmap defines if mipmap should not be generated (default is false)
  115504. * @param invertY defines if texture must be inverted on Y axis (default is false)
  115505. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115506. */
  115507. constructor(
  115508. /**
  115509. * Defines the name of the task
  115510. */
  115511. name: string,
  115512. /**
  115513. * Defines the location of the file to load
  115514. */
  115515. url: string,
  115516. /**
  115517. * Defines if mipmap should not be generated (default is false)
  115518. */
  115519. noMipmap?: boolean | undefined,
  115520. /**
  115521. * Defines if texture must be inverted on Y axis (default is false)
  115522. */
  115523. invertY?: boolean | undefined,
  115524. /**
  115525. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115526. */
  115527. samplingMode?: number);
  115528. /**
  115529. * Execute the current task
  115530. * @param scene defines the scene where you want your assets to be loaded
  115531. * @param onSuccess is a callback called when the task is successfully executed
  115532. * @param onError is a callback called if an error occurs
  115533. */
  115534. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115535. }
  115536. /**
  115537. * Define a task used by AssetsManager to load cube textures
  115538. */
  115539. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  115540. /**
  115541. * Defines the name of the task
  115542. */
  115543. name: string;
  115544. /**
  115545. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115546. */
  115547. url: string;
  115548. /**
  115549. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115550. */
  115551. extensions?: string[] | undefined;
  115552. /**
  115553. * Defines if mipmaps should not be generated (default is false)
  115554. */
  115555. noMipmap?: boolean | undefined;
  115556. /**
  115557. * Defines the explicit list of files (undefined by default)
  115558. */
  115559. files?: string[] | undefined;
  115560. /**
  115561. * Gets the loaded texture
  115562. */
  115563. texture: CubeTexture;
  115564. /**
  115565. * Callback called when the task is successful
  115566. */
  115567. onSuccess: (task: CubeTextureAssetTask) => void;
  115568. /**
  115569. * Callback called when the task is successful
  115570. */
  115571. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  115572. /**
  115573. * Creates a new CubeTextureAssetTask
  115574. * @param name defines the name of the task
  115575. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115576. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115577. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115578. * @param files defines the explicit list of files (undefined by default)
  115579. */
  115580. constructor(
  115581. /**
  115582. * Defines the name of the task
  115583. */
  115584. name: string,
  115585. /**
  115586. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115587. */
  115588. url: string,
  115589. /**
  115590. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115591. */
  115592. extensions?: string[] | undefined,
  115593. /**
  115594. * Defines if mipmaps should not be generated (default is false)
  115595. */
  115596. noMipmap?: boolean | undefined,
  115597. /**
  115598. * Defines the explicit list of files (undefined by default)
  115599. */
  115600. files?: string[] | undefined);
  115601. /**
  115602. * Execute the current task
  115603. * @param scene defines the scene where you want your assets to be loaded
  115604. * @param onSuccess is a callback called when the task is successfully executed
  115605. * @param onError is a callback called if an error occurs
  115606. */
  115607. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115608. }
  115609. /**
  115610. * Define a task used by AssetsManager to load HDR cube textures
  115611. */
  115612. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  115613. /**
  115614. * Defines the name of the task
  115615. */
  115616. name: string;
  115617. /**
  115618. * Defines the location of the file to load
  115619. */
  115620. url: string;
  115621. /**
  115622. * Defines the desired size (the more it increases the longer the generation will be)
  115623. */
  115624. size: number;
  115625. /**
  115626. * Defines if mipmaps should not be generated (default is false)
  115627. */
  115628. noMipmap: boolean;
  115629. /**
  115630. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115631. */
  115632. generateHarmonics: boolean;
  115633. /**
  115634. * 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)
  115635. */
  115636. gammaSpace: boolean;
  115637. /**
  115638. * Internal Use Only
  115639. */
  115640. reserved: boolean;
  115641. /**
  115642. * Gets the loaded texture
  115643. */
  115644. texture: HDRCubeTexture;
  115645. /**
  115646. * Callback called when the task is successful
  115647. */
  115648. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  115649. /**
  115650. * Callback called when the task is successful
  115651. */
  115652. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  115653. /**
  115654. * Creates a new HDRCubeTextureAssetTask object
  115655. * @param name defines the name of the task
  115656. * @param url defines the location of the file to load
  115657. * @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.
  115658. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115659. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115660. * @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)
  115661. * @param reserved Internal use only
  115662. */
  115663. constructor(
  115664. /**
  115665. * Defines the name of the task
  115666. */
  115667. name: string,
  115668. /**
  115669. * Defines the location of the file to load
  115670. */
  115671. url: string,
  115672. /**
  115673. * Defines the desired size (the more it increases the longer the generation will be)
  115674. */
  115675. size: number,
  115676. /**
  115677. * Defines if mipmaps should not be generated (default is false)
  115678. */
  115679. noMipmap?: boolean,
  115680. /**
  115681. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115682. */
  115683. generateHarmonics?: boolean,
  115684. /**
  115685. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  115686. */
  115687. gammaSpace?: boolean,
  115688. /**
  115689. * Internal Use Only
  115690. */
  115691. reserved?: boolean);
  115692. /**
  115693. * Execute the current task
  115694. * @param scene defines the scene where you want your assets to be loaded
  115695. * @param onSuccess is a callback called when the task is successfully executed
  115696. * @param onError is a callback called if an error occurs
  115697. */
  115698. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115699. }
  115700. /**
  115701. * Define a task used by AssetsManager to load Equirectangular cube textures
  115702. */
  115703. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  115704. /**
  115705. * Defines the name of the task
  115706. */
  115707. name: string;
  115708. /**
  115709. * Defines the location of the file to load
  115710. */
  115711. url: string;
  115712. /**
  115713. * Defines the desired size (the more it increases the longer the generation will be)
  115714. */
  115715. size: number;
  115716. /**
  115717. * Defines if mipmaps should not be generated (default is false)
  115718. */
  115719. noMipmap: boolean;
  115720. /**
  115721. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115722. * but the standard material would require them in Gamma space) (default is true)
  115723. */
  115724. gammaSpace: boolean;
  115725. /**
  115726. * Gets the loaded texture
  115727. */
  115728. texture: EquiRectangularCubeTexture;
  115729. /**
  115730. * Callback called when the task is successful
  115731. */
  115732. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  115733. /**
  115734. * Callback called when the task is successful
  115735. */
  115736. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  115737. /**
  115738. * Creates a new EquiRectangularCubeTextureAssetTask object
  115739. * @param name defines the name of the task
  115740. * @param url defines the location of the file to load
  115741. * @param size defines the desired size (the more it increases the longer the generation will be)
  115742. * If the size is omitted this implies you are using a preprocessed cubemap.
  115743. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115744. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  115745. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  115746. * (default is true)
  115747. */
  115748. constructor(
  115749. /**
  115750. * Defines the name of the task
  115751. */
  115752. name: string,
  115753. /**
  115754. * Defines the location of the file to load
  115755. */
  115756. url: string,
  115757. /**
  115758. * Defines the desired size (the more it increases the longer the generation will be)
  115759. */
  115760. size: number,
  115761. /**
  115762. * Defines if mipmaps should not be generated (default is false)
  115763. */
  115764. noMipmap?: boolean,
  115765. /**
  115766. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115767. * but the standard material would require them in Gamma space) (default is true)
  115768. */
  115769. gammaSpace?: boolean);
  115770. /**
  115771. * Execute the current task
  115772. * @param scene defines the scene where you want your assets to be loaded
  115773. * @param onSuccess is a callback called when the task is successfully executed
  115774. * @param onError is a callback called if an error occurs
  115775. */
  115776. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115777. }
  115778. /**
  115779. * This class can be used to easily import assets into a scene
  115780. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  115781. */
  115782. export class AssetsManager {
  115783. private _scene;
  115784. private _isLoading;
  115785. protected _tasks: AbstractAssetTask[];
  115786. protected _waitingTasksCount: number;
  115787. protected _totalTasksCount: number;
  115788. /**
  115789. * Callback called when all tasks are processed
  115790. */
  115791. onFinish: (tasks: AbstractAssetTask[]) => void;
  115792. /**
  115793. * Callback called when a task is successful
  115794. */
  115795. onTaskSuccess: (task: AbstractAssetTask) => void;
  115796. /**
  115797. * Callback called when a task had an error
  115798. */
  115799. onTaskError: (task: AbstractAssetTask) => void;
  115800. /**
  115801. * Callback called when a task is done (whatever the result is)
  115802. */
  115803. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  115804. /**
  115805. * Observable called when all tasks are processed
  115806. */
  115807. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  115808. /**
  115809. * Observable called when a task had an error
  115810. */
  115811. onTaskErrorObservable: Observable<AbstractAssetTask>;
  115812. /**
  115813. * Observable called when all tasks were executed
  115814. */
  115815. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  115816. /**
  115817. * Observable called when a task is done (whatever the result is)
  115818. */
  115819. onProgressObservable: Observable<IAssetsProgressEvent>;
  115820. /**
  115821. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  115822. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115823. */
  115824. useDefaultLoadingScreen: boolean;
  115825. /**
  115826. * Creates a new AssetsManager
  115827. * @param scene defines the scene to work on
  115828. */
  115829. constructor(scene: Scene);
  115830. /**
  115831. * Add a MeshAssetTask to the list of active tasks
  115832. * @param taskName defines the name of the new task
  115833. * @param meshesNames defines the name of meshes to load
  115834. * @param rootUrl defines the root url to use to locate files
  115835. * @param sceneFilename defines the filename of the scene file
  115836. * @returns a new MeshAssetTask object
  115837. */
  115838. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  115839. /**
  115840. * Add a TextFileAssetTask to the list of active tasks
  115841. * @param taskName defines the name of the new task
  115842. * @param url defines the url of the file to load
  115843. * @returns a new TextFileAssetTask object
  115844. */
  115845. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  115846. /**
  115847. * Add a BinaryFileAssetTask to the list of active tasks
  115848. * @param taskName defines the name of the new task
  115849. * @param url defines the url of the file to load
  115850. * @returns a new BinaryFileAssetTask object
  115851. */
  115852. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  115853. /**
  115854. * Add a ImageAssetTask to the list of active tasks
  115855. * @param taskName defines the name of the new task
  115856. * @param url defines the url of the file to load
  115857. * @returns a new ImageAssetTask object
  115858. */
  115859. addImageTask(taskName: string, url: string): ImageAssetTask;
  115860. /**
  115861. * Add a TextureAssetTask to the list of active tasks
  115862. * @param taskName defines the name of the new task
  115863. * @param url defines the url of the file to load
  115864. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115865. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  115866. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115867. * @returns a new TextureAssetTask object
  115868. */
  115869. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  115870. /**
  115871. * Add a CubeTextureAssetTask to the list of active tasks
  115872. * @param taskName defines the name of the new task
  115873. * @param url defines the url of the file to load
  115874. * @param extensions defines the extension to use to load the cube map (can be null)
  115875. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115876. * @param files defines the list of files to load (can be null)
  115877. * @returns a new CubeTextureAssetTask object
  115878. */
  115879. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  115880. /**
  115881. *
  115882. * Add a HDRCubeTextureAssetTask to the list of active tasks
  115883. * @param taskName defines the name of the new task
  115884. * @param url defines the url of the file to load
  115885. * @param size defines the size you want for the cubemap (can be null)
  115886. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115887. * @param generateHarmonics defines if you want to automatically generate (true by default)
  115888. * @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)
  115889. * @param reserved Internal use only
  115890. * @returns a new HDRCubeTextureAssetTask object
  115891. */
  115892. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  115893. /**
  115894. *
  115895. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  115896. * @param taskName defines the name of the new task
  115897. * @param url defines the url of the file to load
  115898. * @param size defines the size you want for the cubemap (can be null)
  115899. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115900. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115901. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115902. * @returns a new EquiRectangularCubeTextureAssetTask object
  115903. */
  115904. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  115905. /**
  115906. * Remove a task from the assets manager.
  115907. * @param task the task to remove
  115908. */
  115909. removeTask(task: AbstractAssetTask): void;
  115910. private _decreaseWaitingTasksCount;
  115911. private _runTask;
  115912. /**
  115913. * Reset the AssetsManager and remove all tasks
  115914. * @return the current instance of the AssetsManager
  115915. */
  115916. reset(): AssetsManager;
  115917. /**
  115918. * Start the loading process
  115919. * @return the current instance of the AssetsManager
  115920. */
  115921. load(): AssetsManager;
  115922. /**
  115923. * Start the loading process as an async operation
  115924. * @return a promise returning the list of failed tasks
  115925. */
  115926. loadAsync(): Promise<void>;
  115927. }
  115928. }
  115929. declare module BABYLON {
  115930. /**
  115931. * Wrapper class for promise with external resolve and reject.
  115932. */
  115933. export class Deferred<T> {
  115934. /**
  115935. * The promise associated with this deferred object.
  115936. */
  115937. readonly promise: Promise<T>;
  115938. private _resolve;
  115939. private _reject;
  115940. /**
  115941. * The resolve method of the promise associated with this deferred object.
  115942. */
  115943. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  115944. /**
  115945. * The reject method of the promise associated with this deferred object.
  115946. */
  115947. readonly reject: (reason?: any) => void;
  115948. /**
  115949. * Constructor for this deferred object.
  115950. */
  115951. constructor();
  115952. }
  115953. }
  115954. declare module BABYLON {
  115955. /**
  115956. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  115957. */
  115958. export class MeshExploder {
  115959. private _centerMesh;
  115960. private _meshes;
  115961. private _meshesOrigins;
  115962. private _toCenterVectors;
  115963. private _scaledDirection;
  115964. private _newPosition;
  115965. private _centerPosition;
  115966. /**
  115967. * Explodes meshes from a center mesh.
  115968. * @param meshes The meshes to explode.
  115969. * @param centerMesh The mesh to be center of explosion.
  115970. */
  115971. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  115972. private _setCenterMesh;
  115973. /**
  115974. * Get class name
  115975. * @returns "MeshExploder"
  115976. */
  115977. getClassName(): string;
  115978. /**
  115979. * "Exploded meshes"
  115980. * @returns Array of meshes with the centerMesh at index 0.
  115981. */
  115982. getMeshes(): Array<Mesh>;
  115983. /**
  115984. * Explodes meshes giving a specific direction
  115985. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  115986. */
  115987. explode(direction?: number): void;
  115988. }
  115989. }
  115990. declare module BABYLON {
  115991. /**
  115992. * Class used to help managing file picking and drag'n'drop
  115993. */
  115994. export class FilesInput {
  115995. /**
  115996. * List of files ready to be loaded
  115997. */
  115998. static readonly FilesToLoad: {
  115999. [key: string]: File;
  116000. };
  116001. /**
  116002. * Callback called when a file is processed
  116003. */
  116004. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  116005. private _engine;
  116006. private _currentScene;
  116007. private _sceneLoadedCallback;
  116008. private _progressCallback;
  116009. private _additionalRenderLoopLogicCallback;
  116010. private _textureLoadingCallback;
  116011. private _startingProcessingFilesCallback;
  116012. private _onReloadCallback;
  116013. private _errorCallback;
  116014. private _elementToMonitor;
  116015. private _sceneFileToLoad;
  116016. private _filesToLoad;
  116017. /**
  116018. * Creates a new FilesInput
  116019. * @param engine defines the rendering engine
  116020. * @param scene defines the hosting scene
  116021. * @param sceneLoadedCallback callback called when scene is loaded
  116022. * @param progressCallback callback called to track progress
  116023. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  116024. * @param textureLoadingCallback callback called when a texture is loading
  116025. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  116026. * @param onReloadCallback callback called when a reload is requested
  116027. * @param errorCallback callback call if an error occurs
  116028. */
  116029. 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);
  116030. private _dragEnterHandler;
  116031. private _dragOverHandler;
  116032. private _dropHandler;
  116033. /**
  116034. * Calls this function to listen to drag'n'drop events on a specific DOM element
  116035. * @param elementToMonitor defines the DOM element to track
  116036. */
  116037. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  116038. /**
  116039. * Release all associated resources
  116040. */
  116041. dispose(): void;
  116042. private renderFunction;
  116043. private drag;
  116044. private drop;
  116045. private _traverseFolder;
  116046. private _processFiles;
  116047. /**
  116048. * Load files from a drop event
  116049. * @param event defines the drop event to use as source
  116050. */
  116051. loadFiles(event: any): void;
  116052. private _processReload;
  116053. /**
  116054. * Reload the current scene from the loaded files
  116055. */
  116056. reload(): void;
  116057. }
  116058. }
  116059. declare module BABYLON {
  116060. /**
  116061. * Defines the root class used to create scene optimization to use with SceneOptimizer
  116062. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116063. */
  116064. export class SceneOptimization {
  116065. /**
  116066. * Defines the priority of this optimization (0 by default which means first in the list)
  116067. */
  116068. priority: number;
  116069. /**
  116070. * Gets a string describing the action executed by the current optimization
  116071. * @returns description string
  116072. */
  116073. getDescription(): string;
  116074. /**
  116075. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116076. * @param scene defines the current scene where to apply this optimization
  116077. * @param optimizer defines the current optimizer
  116078. * @returns true if everything that can be done was applied
  116079. */
  116080. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116081. /**
  116082. * Creates the SceneOptimization object
  116083. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  116084. * @param desc defines the description associated with the optimization
  116085. */
  116086. constructor(
  116087. /**
  116088. * Defines the priority of this optimization (0 by default which means first in the list)
  116089. */
  116090. priority?: number);
  116091. }
  116092. /**
  116093. * Defines an optimization used to reduce the size of render target textures
  116094. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116095. */
  116096. export class TextureOptimization extends SceneOptimization {
  116097. /**
  116098. * Defines the priority of this optimization (0 by default which means first in the list)
  116099. */
  116100. priority: number;
  116101. /**
  116102. * 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
  116103. */
  116104. maximumSize: number;
  116105. /**
  116106. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  116107. */
  116108. step: number;
  116109. /**
  116110. * Gets a string describing the action executed by the current optimization
  116111. * @returns description string
  116112. */
  116113. getDescription(): string;
  116114. /**
  116115. * Creates the TextureOptimization object
  116116. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  116117. * @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
  116118. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  116119. */
  116120. constructor(
  116121. /**
  116122. * Defines the priority of this optimization (0 by default which means first in the list)
  116123. */
  116124. priority?: number,
  116125. /**
  116126. * 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
  116127. */
  116128. maximumSize?: number,
  116129. /**
  116130. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  116131. */
  116132. step?: number);
  116133. /**
  116134. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116135. * @param scene defines the current scene where to apply this optimization
  116136. * @param optimizer defines the current optimizer
  116137. * @returns true if everything that can be done was applied
  116138. */
  116139. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116140. }
  116141. /**
  116142. * Defines an optimization used to increase or decrease the rendering resolution
  116143. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116144. */
  116145. export class HardwareScalingOptimization extends SceneOptimization {
  116146. /**
  116147. * Defines the priority of this optimization (0 by default which means first in the list)
  116148. */
  116149. priority: number;
  116150. /**
  116151. * Defines the maximum scale to use (2 by default)
  116152. */
  116153. maximumScale: number;
  116154. /**
  116155. * Defines the step to use between two passes (0.5 by default)
  116156. */
  116157. step: number;
  116158. private _currentScale;
  116159. private _directionOffset;
  116160. /**
  116161. * Gets a string describing the action executed by the current optimization
  116162. * @return description string
  116163. */
  116164. getDescription(): string;
  116165. /**
  116166. * Creates the HardwareScalingOptimization object
  116167. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  116168. * @param maximumScale defines the maximum scale to use (2 by default)
  116169. * @param step defines the step to use between two passes (0.5 by default)
  116170. */
  116171. constructor(
  116172. /**
  116173. * Defines the priority of this optimization (0 by default which means first in the list)
  116174. */
  116175. priority?: number,
  116176. /**
  116177. * Defines the maximum scale to use (2 by default)
  116178. */
  116179. maximumScale?: number,
  116180. /**
  116181. * Defines the step to use between two passes (0.5 by default)
  116182. */
  116183. step?: number);
  116184. /**
  116185. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116186. * @param scene defines the current scene where to apply this optimization
  116187. * @param optimizer defines the current optimizer
  116188. * @returns true if everything that can be done was applied
  116189. */
  116190. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116191. }
  116192. /**
  116193. * Defines an optimization used to remove shadows
  116194. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116195. */
  116196. export class ShadowsOptimization extends SceneOptimization {
  116197. /**
  116198. * Gets a string describing the action executed by the current optimization
  116199. * @return description string
  116200. */
  116201. getDescription(): string;
  116202. /**
  116203. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116204. * @param scene defines the current scene where to apply this optimization
  116205. * @param optimizer defines the current optimizer
  116206. * @returns true if everything that can be done was applied
  116207. */
  116208. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116209. }
  116210. /**
  116211. * Defines an optimization used to turn post-processes off
  116212. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116213. */
  116214. export class PostProcessesOptimization extends SceneOptimization {
  116215. /**
  116216. * Gets a string describing the action executed by the current optimization
  116217. * @return description string
  116218. */
  116219. getDescription(): string;
  116220. /**
  116221. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116222. * @param scene defines the current scene where to apply this optimization
  116223. * @param optimizer defines the current optimizer
  116224. * @returns true if everything that can be done was applied
  116225. */
  116226. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116227. }
  116228. /**
  116229. * Defines an optimization used to turn lens flares off
  116230. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116231. */
  116232. export class LensFlaresOptimization extends SceneOptimization {
  116233. /**
  116234. * Gets a string describing the action executed by the current optimization
  116235. * @return description string
  116236. */
  116237. getDescription(): string;
  116238. /**
  116239. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116240. * @param scene defines the current scene where to apply this optimization
  116241. * @param optimizer defines the current optimizer
  116242. * @returns true if everything that can be done was applied
  116243. */
  116244. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116245. }
  116246. /**
  116247. * Defines an optimization based on user defined callback.
  116248. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116249. */
  116250. export class CustomOptimization extends SceneOptimization {
  116251. /**
  116252. * Callback called to apply the custom optimization.
  116253. */
  116254. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  116255. /**
  116256. * Callback called to get custom description
  116257. */
  116258. onGetDescription: () => string;
  116259. /**
  116260. * Gets a string describing the action executed by the current optimization
  116261. * @returns description string
  116262. */
  116263. getDescription(): string;
  116264. /**
  116265. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116266. * @param scene defines the current scene where to apply this optimization
  116267. * @param optimizer defines the current optimizer
  116268. * @returns true if everything that can be done was applied
  116269. */
  116270. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116271. }
  116272. /**
  116273. * Defines an optimization used to turn particles off
  116274. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116275. */
  116276. export class ParticlesOptimization extends SceneOptimization {
  116277. /**
  116278. * Gets a string describing the action executed by the current optimization
  116279. * @return description string
  116280. */
  116281. getDescription(): string;
  116282. /**
  116283. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116284. * @param scene defines the current scene where to apply this optimization
  116285. * @param optimizer defines the current optimizer
  116286. * @returns true if everything that can be done was applied
  116287. */
  116288. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116289. }
  116290. /**
  116291. * Defines an optimization used to turn render targets off
  116292. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116293. */
  116294. export class RenderTargetsOptimization extends SceneOptimization {
  116295. /**
  116296. * Gets a string describing the action executed by the current optimization
  116297. * @return description string
  116298. */
  116299. getDescription(): string;
  116300. /**
  116301. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116302. * @param scene defines the current scene where to apply this optimization
  116303. * @param optimizer defines the current optimizer
  116304. * @returns true if everything that can be done was applied
  116305. */
  116306. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116307. }
  116308. /**
  116309. * Defines an optimization used to merge meshes with compatible materials
  116310. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116311. */
  116312. export class MergeMeshesOptimization extends SceneOptimization {
  116313. private static _UpdateSelectionTree;
  116314. /**
  116315. * Gets or sets a boolean which defines if optimization octree has to be updated
  116316. */
  116317. /**
  116318. * Gets or sets a boolean which defines if optimization octree has to be updated
  116319. */
  116320. static UpdateSelectionTree: boolean;
  116321. /**
  116322. * Gets a string describing the action executed by the current optimization
  116323. * @return description string
  116324. */
  116325. getDescription(): string;
  116326. private _canBeMerged;
  116327. /**
  116328. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116329. * @param scene defines the current scene where to apply this optimization
  116330. * @param optimizer defines the current optimizer
  116331. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  116332. * @returns true if everything that can be done was applied
  116333. */
  116334. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  116335. }
  116336. /**
  116337. * Defines a list of options used by SceneOptimizer
  116338. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116339. */
  116340. export class SceneOptimizerOptions {
  116341. /**
  116342. * Defines the target frame rate to reach (60 by default)
  116343. */
  116344. targetFrameRate: number;
  116345. /**
  116346. * Defines the interval between two checkes (2000ms by default)
  116347. */
  116348. trackerDuration: number;
  116349. /**
  116350. * Gets the list of optimizations to apply
  116351. */
  116352. optimizations: SceneOptimization[];
  116353. /**
  116354. * Creates a new list of options used by SceneOptimizer
  116355. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  116356. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  116357. */
  116358. constructor(
  116359. /**
  116360. * Defines the target frame rate to reach (60 by default)
  116361. */
  116362. targetFrameRate?: number,
  116363. /**
  116364. * Defines the interval between two checkes (2000ms by default)
  116365. */
  116366. trackerDuration?: number);
  116367. /**
  116368. * Add a new optimization
  116369. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  116370. * @returns the current SceneOptimizerOptions
  116371. */
  116372. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  116373. /**
  116374. * Add a new custom optimization
  116375. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  116376. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  116377. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  116378. * @returns the current SceneOptimizerOptions
  116379. */
  116380. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  116381. /**
  116382. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  116383. * @param targetFrameRate defines the target frame rate (60 by default)
  116384. * @returns a SceneOptimizerOptions object
  116385. */
  116386. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116387. /**
  116388. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  116389. * @param targetFrameRate defines the target frame rate (60 by default)
  116390. * @returns a SceneOptimizerOptions object
  116391. */
  116392. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116393. /**
  116394. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  116395. * @param targetFrameRate defines the target frame rate (60 by default)
  116396. * @returns a SceneOptimizerOptions object
  116397. */
  116398. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116399. }
  116400. /**
  116401. * Class used to run optimizations in order to reach a target frame rate
  116402. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116403. */
  116404. export class SceneOptimizer implements IDisposable {
  116405. private _isRunning;
  116406. private _options;
  116407. private _scene;
  116408. private _currentPriorityLevel;
  116409. private _targetFrameRate;
  116410. private _trackerDuration;
  116411. private _currentFrameRate;
  116412. private _sceneDisposeObserver;
  116413. private _improvementMode;
  116414. /**
  116415. * Defines an observable called when the optimizer reaches the target frame rate
  116416. */
  116417. onSuccessObservable: Observable<SceneOptimizer>;
  116418. /**
  116419. * Defines an observable called when the optimizer enables an optimization
  116420. */
  116421. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  116422. /**
  116423. * Defines an observable called when the optimizer is not able to reach the target frame rate
  116424. */
  116425. onFailureObservable: Observable<SceneOptimizer>;
  116426. /**
  116427. * Gets a boolean indicating if the optimizer is in improvement mode
  116428. */
  116429. readonly isInImprovementMode: boolean;
  116430. /**
  116431. * Gets the current priority level (0 at start)
  116432. */
  116433. readonly currentPriorityLevel: number;
  116434. /**
  116435. * Gets the current frame rate checked by the SceneOptimizer
  116436. */
  116437. readonly currentFrameRate: number;
  116438. /**
  116439. * Gets or sets the current target frame rate (60 by default)
  116440. */
  116441. /**
  116442. * Gets or sets the current target frame rate (60 by default)
  116443. */
  116444. targetFrameRate: number;
  116445. /**
  116446. * Gets or sets the current interval between two checks (every 2000ms by default)
  116447. */
  116448. /**
  116449. * Gets or sets the current interval between two checks (every 2000ms by default)
  116450. */
  116451. trackerDuration: number;
  116452. /**
  116453. * Gets the list of active optimizations
  116454. */
  116455. readonly optimizations: SceneOptimization[];
  116456. /**
  116457. * Creates a new SceneOptimizer
  116458. * @param scene defines the scene to work on
  116459. * @param options defines the options to use with the SceneOptimizer
  116460. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  116461. * @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)
  116462. */
  116463. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  116464. /**
  116465. * Stops the current optimizer
  116466. */
  116467. stop(): void;
  116468. /**
  116469. * Reset the optimizer to initial step (current priority level = 0)
  116470. */
  116471. reset(): void;
  116472. /**
  116473. * Start the optimizer. By default it will try to reach a specific framerate
  116474. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  116475. */
  116476. start(): void;
  116477. private _checkCurrentState;
  116478. /**
  116479. * Release all resources
  116480. */
  116481. dispose(): void;
  116482. /**
  116483. * Helper function to create a SceneOptimizer with one single line of code
  116484. * @param scene defines the scene to work on
  116485. * @param options defines the options to use with the SceneOptimizer
  116486. * @param onSuccess defines a callback to call on success
  116487. * @param onFailure defines a callback to call on failure
  116488. * @returns the new SceneOptimizer object
  116489. */
  116490. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  116491. }
  116492. }
  116493. declare module BABYLON {
  116494. /**
  116495. * Class used to serialize a scene into a string
  116496. */
  116497. export class SceneSerializer {
  116498. /**
  116499. * Clear cache used by a previous serialization
  116500. */
  116501. static ClearCache(): void;
  116502. /**
  116503. * Serialize a scene into a JSON compatible object
  116504. * @param scene defines the scene to serialize
  116505. * @returns a JSON compatible object
  116506. */
  116507. static Serialize(scene: Scene): any;
  116508. /**
  116509. * Serialize a mesh into a JSON compatible object
  116510. * @param toSerialize defines the mesh to serialize
  116511. * @param withParents defines if parents must be serialized as well
  116512. * @param withChildren defines if children must be serialized as well
  116513. * @returns a JSON compatible object
  116514. */
  116515. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  116516. }
  116517. }
  116518. declare module BABYLON {
  116519. /**
  116520. * Class used to host texture specific utilities
  116521. */
  116522. export class TextureTools {
  116523. /**
  116524. * Uses the GPU to create a copy texture rescaled at a given size
  116525. * @param texture Texture to copy from
  116526. * @param width defines the desired width
  116527. * @param height defines the desired height
  116528. * @param useBilinearMode defines if bilinear mode has to be used
  116529. * @return the generated texture
  116530. */
  116531. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  116532. }
  116533. }
  116534. declare module BABYLON {
  116535. /**
  116536. * This represents the different options avilable for the video capture.
  116537. */
  116538. export interface VideoRecorderOptions {
  116539. /** Defines the mime type of the video */
  116540. mimeType: string;
  116541. /** Defines the video the video should be recorded at */
  116542. fps: number;
  116543. /** Defines the chunk size for the recording data */
  116544. recordChunckSize: number;
  116545. /** The audio tracks to attach to the record */
  116546. audioTracks?: MediaStreamTrack[];
  116547. }
  116548. /**
  116549. * This can helps recording videos from BabylonJS.
  116550. * This is based on the available WebRTC functionalities of the browser.
  116551. *
  116552. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  116553. */
  116554. export class VideoRecorder {
  116555. private static readonly _defaultOptions;
  116556. /**
  116557. * Returns wehther or not the VideoRecorder is available in your browser.
  116558. * @param engine Defines the Babylon Engine to check the support for
  116559. * @returns true if supported otherwise false
  116560. */
  116561. static IsSupported(engine: Engine): boolean;
  116562. private readonly _options;
  116563. private _canvas;
  116564. private _mediaRecorder;
  116565. private _recordedChunks;
  116566. private _fileName;
  116567. private _resolve;
  116568. private _reject;
  116569. /**
  116570. * True wether a recording is already in progress.
  116571. */
  116572. readonly isRecording: boolean;
  116573. /**
  116574. * Create a new VideoCapture object which can help converting what you see in Babylon to
  116575. * a video file.
  116576. * @param engine Defines the BabylonJS Engine you wish to record
  116577. * @param options Defines options that can be used to customized the capture
  116578. */
  116579. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  116580. /**
  116581. * Stops the current recording before the default capture timeout passed in the startRecording
  116582. * functions.
  116583. */
  116584. stopRecording(): void;
  116585. /**
  116586. * Starts recording the canvas for a max duration specified in parameters.
  116587. * @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.
  116588. * @param maxDuration Defines the maximum recording time in seconds.
  116589. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  116590. * @return a promise callback at the end of the recording with the video data in Blob.
  116591. */
  116592. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  116593. /**
  116594. * Releases internal resources used during the recording.
  116595. */
  116596. dispose(): void;
  116597. private _handleDataAvailable;
  116598. private _handleError;
  116599. private _handleStop;
  116600. }
  116601. }
  116602. declare module BABYLON {
  116603. /**
  116604. * Class containing a set of static utilities functions for screenshots
  116605. */
  116606. export class ScreenshotTools {
  116607. /**
  116608. * Captures a screenshot of the current rendering
  116609. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116610. * @param engine defines the rendering engine
  116611. * @param camera defines the source camera
  116612. * @param size This parameter can be set to a single number or to an object with the
  116613. * following (optional) properties: precision, width, height. If a single number is passed,
  116614. * it will be used for both width and height. If an object is passed, the screenshot size
  116615. * will be derived from the parameters. The precision property is a multiplier allowing
  116616. * rendering at a higher or lower resolution
  116617. * @param successCallback defines the callback receives a single parameter which contains the
  116618. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116619. * src parameter of an <img> to display it
  116620. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  116621. * Check your browser for supported MIME types
  116622. */
  116623. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  116624. /**
  116625. * Generates an image screenshot from the specified camera.
  116626. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116627. * @param engine The engine to use for rendering
  116628. * @param camera The camera to use for rendering
  116629. * @param size This parameter can be set to a single number or to an object with the
  116630. * following (optional) properties: precision, width, height. If a single number is passed,
  116631. * it will be used for both width and height. If an object is passed, the screenshot size
  116632. * will be derived from the parameters. The precision property is a multiplier allowing
  116633. * rendering at a higher or lower resolution
  116634. * @param successCallback The callback receives a single parameter which contains the
  116635. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116636. * src parameter of an <img> to display it
  116637. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116638. * Check your browser for supported MIME types
  116639. * @param samples Texture samples (default: 1)
  116640. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116641. * @param fileName A name for for the downloaded file.
  116642. */
  116643. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  116644. }
  116645. }
  116646. declare module BABYLON {
  116647. /**
  116648. * A cursor which tracks a point on a path
  116649. */
  116650. export class PathCursor {
  116651. private path;
  116652. /**
  116653. * Stores path cursor callbacks for when an onchange event is triggered
  116654. */
  116655. private _onchange;
  116656. /**
  116657. * The value of the path cursor
  116658. */
  116659. value: number;
  116660. /**
  116661. * The animation array of the path cursor
  116662. */
  116663. animations: Animation[];
  116664. /**
  116665. * Initializes the path cursor
  116666. * @param path The path to track
  116667. */
  116668. constructor(path: Path2);
  116669. /**
  116670. * Gets the cursor point on the path
  116671. * @returns A point on the path cursor at the cursor location
  116672. */
  116673. getPoint(): Vector3;
  116674. /**
  116675. * Moves the cursor ahead by the step amount
  116676. * @param step The amount to move the cursor forward
  116677. * @returns This path cursor
  116678. */
  116679. moveAhead(step?: number): PathCursor;
  116680. /**
  116681. * Moves the cursor behind by the step amount
  116682. * @param step The amount to move the cursor back
  116683. * @returns This path cursor
  116684. */
  116685. moveBack(step?: number): PathCursor;
  116686. /**
  116687. * Moves the cursor by the step amount
  116688. * If the step amount is greater than one, an exception is thrown
  116689. * @param step The amount to move the cursor
  116690. * @returns This path cursor
  116691. */
  116692. move(step: number): PathCursor;
  116693. /**
  116694. * Ensures that the value is limited between zero and one
  116695. * @returns This path cursor
  116696. */
  116697. private ensureLimits;
  116698. /**
  116699. * Runs onchange callbacks on change (used by the animation engine)
  116700. * @returns This path cursor
  116701. */
  116702. private raiseOnChange;
  116703. /**
  116704. * Executes a function on change
  116705. * @param f A path cursor onchange callback
  116706. * @returns This path cursor
  116707. */
  116708. onchange(f: (cursor: PathCursor) => void): PathCursor;
  116709. }
  116710. }
  116711. declare module BABYLON {
  116712. /** @hidden */
  116713. export var blurPixelShader: {
  116714. name: string;
  116715. shader: string;
  116716. };
  116717. }
  116718. declare module BABYLON {
  116719. /** @hidden */
  116720. export var bones300Declaration: {
  116721. name: string;
  116722. shader: string;
  116723. };
  116724. }
  116725. declare module BABYLON {
  116726. /** @hidden */
  116727. export var instances300Declaration: {
  116728. name: string;
  116729. shader: string;
  116730. };
  116731. }
  116732. declare module BABYLON {
  116733. /** @hidden */
  116734. export var pointCloudVertexDeclaration: {
  116735. name: string;
  116736. shader: string;
  116737. };
  116738. }
  116739. // Mixins
  116740. interface Window {
  116741. mozIndexedDB: IDBFactory;
  116742. webkitIndexedDB: IDBFactory;
  116743. msIndexedDB: IDBFactory;
  116744. webkitURL: typeof URL;
  116745. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  116746. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  116747. WebGLRenderingContext: WebGLRenderingContext;
  116748. MSGesture: MSGesture;
  116749. CANNON: any;
  116750. AudioContext: AudioContext;
  116751. webkitAudioContext: AudioContext;
  116752. PointerEvent: any;
  116753. Math: Math;
  116754. Uint8Array: Uint8ArrayConstructor;
  116755. Float32Array: Float32ArrayConstructor;
  116756. mozURL: typeof URL;
  116757. msURL: typeof URL;
  116758. VRFrameData: any; // WebVR, from specs 1.1
  116759. DracoDecoderModule: any;
  116760. setImmediate(handler: (...args: any[]) => void): number;
  116761. }
  116762. interface HTMLCanvasElement {
  116763. requestPointerLock(): void;
  116764. msRequestPointerLock?(): void;
  116765. mozRequestPointerLock?(): void;
  116766. webkitRequestPointerLock?(): void;
  116767. /** Track wether a record is in progress */
  116768. isRecording: boolean;
  116769. /** Capture Stream method defined by some browsers */
  116770. captureStream(fps?: number): MediaStream;
  116771. }
  116772. interface CanvasRenderingContext2D {
  116773. msImageSmoothingEnabled: boolean;
  116774. }
  116775. interface MouseEvent {
  116776. mozMovementX: number;
  116777. mozMovementY: number;
  116778. webkitMovementX: number;
  116779. webkitMovementY: number;
  116780. msMovementX: number;
  116781. msMovementY: number;
  116782. }
  116783. interface Navigator {
  116784. mozGetVRDevices: (any: any) => any;
  116785. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116786. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116787. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116788. webkitGetGamepads(): Gamepad[];
  116789. msGetGamepads(): Gamepad[];
  116790. webkitGamepads(): Gamepad[];
  116791. }
  116792. interface HTMLVideoElement {
  116793. mozSrcObject: any;
  116794. }
  116795. interface Math {
  116796. fround(x: number): number;
  116797. imul(a: number, b: number): number;
  116798. }
  116799. interface WebGLRenderingContext {
  116800. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  116801. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  116802. vertexAttribDivisor(index: number, divisor: number): void;
  116803. createVertexArray(): any;
  116804. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  116805. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  116806. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  116807. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  116808. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  116809. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  116810. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  116811. // Queries
  116812. createQuery(): WebGLQuery;
  116813. deleteQuery(query: WebGLQuery): void;
  116814. beginQuery(target: number, query: WebGLQuery): void;
  116815. endQuery(target: number): void;
  116816. getQueryParameter(query: WebGLQuery, pname: number): any;
  116817. getQuery(target: number, pname: number): any;
  116818. MAX_SAMPLES: number;
  116819. RGBA8: number;
  116820. READ_FRAMEBUFFER: number;
  116821. DRAW_FRAMEBUFFER: number;
  116822. UNIFORM_BUFFER: number;
  116823. HALF_FLOAT_OES: number;
  116824. RGBA16F: number;
  116825. RGBA32F: number;
  116826. R32F: number;
  116827. RG32F: number;
  116828. RGB32F: number;
  116829. R16F: number;
  116830. RG16F: number;
  116831. RGB16F: number;
  116832. RED: number;
  116833. RG: number;
  116834. R8: number;
  116835. RG8: number;
  116836. UNSIGNED_INT_24_8: number;
  116837. DEPTH24_STENCIL8: number;
  116838. /* Multiple Render Targets */
  116839. drawBuffers(buffers: number[]): void;
  116840. readBuffer(src: number): void;
  116841. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  116842. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  116843. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  116844. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  116845. // Occlusion Query
  116846. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  116847. ANY_SAMPLES_PASSED: number;
  116848. QUERY_RESULT_AVAILABLE: number;
  116849. QUERY_RESULT: number;
  116850. }
  116851. interface WebGLProgram {
  116852. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  116853. }
  116854. interface EXT_disjoint_timer_query {
  116855. QUERY_COUNTER_BITS_EXT: number;
  116856. TIME_ELAPSED_EXT: number;
  116857. TIMESTAMP_EXT: number;
  116858. GPU_DISJOINT_EXT: number;
  116859. QUERY_RESULT_EXT: number;
  116860. QUERY_RESULT_AVAILABLE_EXT: number;
  116861. queryCounterEXT(query: WebGLQuery, target: number): void;
  116862. createQueryEXT(): WebGLQuery;
  116863. beginQueryEXT(target: number, query: WebGLQuery): void;
  116864. endQueryEXT(target: number): void;
  116865. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  116866. deleteQueryEXT(query: WebGLQuery): void;
  116867. }
  116868. interface WebGLUniformLocation {
  116869. _currentState: any;
  116870. }
  116871. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  116872. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  116873. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  116874. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116875. interface WebGLRenderingContext {
  116876. readonly RASTERIZER_DISCARD: number;
  116877. readonly DEPTH_COMPONENT24: number;
  116878. readonly TEXTURE_3D: number;
  116879. readonly TEXTURE_2D_ARRAY: number;
  116880. readonly TEXTURE_COMPARE_FUNC: number;
  116881. readonly TEXTURE_COMPARE_MODE: number;
  116882. readonly COMPARE_REF_TO_TEXTURE: number;
  116883. readonly TEXTURE_WRAP_R: number;
  116884. readonly HALF_FLOAT: number;
  116885. readonly RGB8: number;
  116886. readonly RED_INTEGER: number;
  116887. readonly RG_INTEGER: number;
  116888. readonly RGB_INTEGER: number;
  116889. readonly RGBA_INTEGER: number;
  116890. readonly R8_SNORM: number;
  116891. readonly RG8_SNORM: number;
  116892. readonly RGB8_SNORM: number;
  116893. readonly RGBA8_SNORM: number;
  116894. readonly R8I: number;
  116895. readonly RG8I: number;
  116896. readonly RGB8I: number;
  116897. readonly RGBA8I: number;
  116898. readonly R8UI: number;
  116899. readonly RG8UI: number;
  116900. readonly RGB8UI: number;
  116901. readonly RGBA8UI: number;
  116902. readonly R16I: number;
  116903. readonly RG16I: number;
  116904. readonly RGB16I: number;
  116905. readonly RGBA16I: number;
  116906. readonly R16UI: number;
  116907. readonly RG16UI: number;
  116908. readonly RGB16UI: number;
  116909. readonly RGBA16UI: number;
  116910. readonly R32I: number;
  116911. readonly RG32I: number;
  116912. readonly RGB32I: number;
  116913. readonly RGBA32I: number;
  116914. readonly R32UI: number;
  116915. readonly RG32UI: number;
  116916. readonly RGB32UI: number;
  116917. readonly RGBA32UI: number;
  116918. readonly RGB10_A2UI: number;
  116919. readonly R11F_G11F_B10F: number;
  116920. readonly RGB9_E5: number;
  116921. readonly RGB10_A2: number;
  116922. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  116923. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  116924. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  116925. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116926. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  116927. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  116928. 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;
  116929. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  116930. readonly TRANSFORM_FEEDBACK: number;
  116931. readonly INTERLEAVED_ATTRIBS: number;
  116932. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  116933. createTransformFeedback(): WebGLTransformFeedback;
  116934. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  116935. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  116936. beginTransformFeedback(primitiveMode: number): void;
  116937. endTransformFeedback(): void;
  116938. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  116939. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116940. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116941. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116942. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  116943. }
  116944. interface ImageBitmap {
  116945. readonly width: number;
  116946. readonly height: number;
  116947. close(): void;
  116948. }
  116949. interface WebGLQuery extends WebGLObject {
  116950. }
  116951. declare var WebGLQuery: {
  116952. prototype: WebGLQuery;
  116953. new(): WebGLQuery;
  116954. };
  116955. interface WebGLSampler extends WebGLObject {
  116956. }
  116957. declare var WebGLSampler: {
  116958. prototype: WebGLSampler;
  116959. new(): WebGLSampler;
  116960. };
  116961. interface WebGLSync extends WebGLObject {
  116962. }
  116963. declare var WebGLSync: {
  116964. prototype: WebGLSync;
  116965. new(): WebGLSync;
  116966. };
  116967. interface WebGLTransformFeedback extends WebGLObject {
  116968. }
  116969. declare var WebGLTransformFeedback: {
  116970. prototype: WebGLTransformFeedback;
  116971. new(): WebGLTransformFeedback;
  116972. };
  116973. interface WebGLVertexArrayObject extends WebGLObject {
  116974. }
  116975. declare var WebGLVertexArrayObject: {
  116976. prototype: WebGLVertexArrayObject;
  116977. new(): WebGLVertexArrayObject;
  116978. };
  116979. // Type definitions for WebVR API
  116980. // Project: https://w3c.github.io/webvr/
  116981. // Definitions by: six a <https://github.com/lostfictions>
  116982. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116983. interface VRDisplay extends EventTarget {
  116984. /**
  116985. * Dictionary of capabilities describing the VRDisplay.
  116986. */
  116987. readonly capabilities: VRDisplayCapabilities;
  116988. /**
  116989. * z-depth defining the far plane of the eye view frustum
  116990. * enables mapping of values in the render target depth
  116991. * attachment to scene coordinates. Initially set to 10000.0.
  116992. */
  116993. depthFar: number;
  116994. /**
  116995. * z-depth defining the near plane of the eye view frustum
  116996. * enables mapping of values in the render target depth
  116997. * attachment to scene coordinates. Initially set to 0.01.
  116998. */
  116999. depthNear: number;
  117000. /**
  117001. * An identifier for this distinct VRDisplay. Used as an
  117002. * association point in the Gamepad API.
  117003. */
  117004. readonly displayId: number;
  117005. /**
  117006. * A display name, a user-readable name identifying it.
  117007. */
  117008. readonly displayName: string;
  117009. readonly isConnected: boolean;
  117010. readonly isPresenting: boolean;
  117011. /**
  117012. * If this VRDisplay supports room-scale experiences, the optional
  117013. * stage attribute contains details on the room-scale parameters.
  117014. */
  117015. readonly stageParameters: VRStageParameters | null;
  117016. /**
  117017. * Passing the value returned by `requestAnimationFrame` to
  117018. * `cancelAnimationFrame` will unregister the callback.
  117019. * @param handle Define the hanle of the request to cancel
  117020. */
  117021. cancelAnimationFrame(handle: number): void;
  117022. /**
  117023. * Stops presenting to the VRDisplay.
  117024. * @returns a promise to know when it stopped
  117025. */
  117026. exitPresent(): Promise<void>;
  117027. /**
  117028. * Return the current VREyeParameters for the given eye.
  117029. * @param whichEye Define the eye we want the parameter for
  117030. * @returns the eye parameters
  117031. */
  117032. getEyeParameters(whichEye: string): VREyeParameters;
  117033. /**
  117034. * Populates the passed VRFrameData with the information required to render
  117035. * the current frame.
  117036. * @param frameData Define the data structure to populate
  117037. * @returns true if ok otherwise false
  117038. */
  117039. getFrameData(frameData: VRFrameData): boolean;
  117040. /**
  117041. * Get the layers currently being presented.
  117042. * @returns the list of VR layers
  117043. */
  117044. getLayers(): VRLayer[];
  117045. /**
  117046. * Return a VRPose containing the future predicted pose of the VRDisplay
  117047. * when the current frame will be presented. The value returned will not
  117048. * change until JavaScript has returned control to the browser.
  117049. *
  117050. * The VRPose will contain the position, orientation, velocity,
  117051. * and acceleration of each of these properties.
  117052. * @returns the pose object
  117053. */
  117054. getPose(): VRPose;
  117055. /**
  117056. * Return the current instantaneous pose of the VRDisplay, with no
  117057. * prediction applied.
  117058. * @returns the current instantaneous pose
  117059. */
  117060. getImmediatePose(): VRPose;
  117061. /**
  117062. * The callback passed to `requestAnimationFrame` will be called
  117063. * any time a new frame should be rendered. When the VRDisplay is
  117064. * presenting the callback will be called at the native refresh
  117065. * rate of the HMD. When not presenting this function acts
  117066. * identically to how window.requestAnimationFrame acts. Content should
  117067. * make no assumptions of frame rate or vsync behavior as the HMD runs
  117068. * asynchronously from other displays and at differing refresh rates.
  117069. * @param callback Define the eaction to run next frame
  117070. * @returns the request handle it
  117071. */
  117072. requestAnimationFrame(callback: FrameRequestCallback): number;
  117073. /**
  117074. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  117075. * Repeat calls while already presenting will update the VRLayers being displayed.
  117076. * @param layers Define the list of layer to present
  117077. * @returns a promise to know when the request has been fulfilled
  117078. */
  117079. requestPresent(layers: VRLayer[]): Promise<void>;
  117080. /**
  117081. * Reset the pose for this display, treating its current position and
  117082. * orientation as the "origin/zero" values. VRPose.position,
  117083. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  117084. * updated when calling resetPose(). This should be called in only
  117085. * sitting-space experiences.
  117086. */
  117087. resetPose(): void;
  117088. /**
  117089. * The VRLayer provided to the VRDisplay will be captured and presented
  117090. * in the HMD. Calling this function has the same effect on the source
  117091. * canvas as any other operation that uses its source image, and canvases
  117092. * created without preserveDrawingBuffer set to true will be cleared.
  117093. * @param pose Define the pose to submit
  117094. */
  117095. submitFrame(pose?: VRPose): void;
  117096. }
  117097. declare var VRDisplay: {
  117098. prototype: VRDisplay;
  117099. new(): VRDisplay;
  117100. };
  117101. interface VRLayer {
  117102. leftBounds?: number[] | Float32Array | null;
  117103. rightBounds?: number[] | Float32Array | null;
  117104. source?: HTMLCanvasElement | null;
  117105. }
  117106. interface VRDisplayCapabilities {
  117107. readonly canPresent: boolean;
  117108. readonly hasExternalDisplay: boolean;
  117109. readonly hasOrientation: boolean;
  117110. readonly hasPosition: boolean;
  117111. readonly maxLayers: number;
  117112. }
  117113. interface VREyeParameters {
  117114. /** @deprecated */
  117115. readonly fieldOfView: VRFieldOfView;
  117116. readonly offset: Float32Array;
  117117. readonly renderHeight: number;
  117118. readonly renderWidth: number;
  117119. }
  117120. interface VRFieldOfView {
  117121. readonly downDegrees: number;
  117122. readonly leftDegrees: number;
  117123. readonly rightDegrees: number;
  117124. readonly upDegrees: number;
  117125. }
  117126. interface VRFrameData {
  117127. readonly leftProjectionMatrix: Float32Array;
  117128. readonly leftViewMatrix: Float32Array;
  117129. readonly pose: VRPose;
  117130. readonly rightProjectionMatrix: Float32Array;
  117131. readonly rightViewMatrix: Float32Array;
  117132. readonly timestamp: number;
  117133. }
  117134. interface VRPose {
  117135. readonly angularAcceleration: Float32Array | null;
  117136. readonly angularVelocity: Float32Array | null;
  117137. readonly linearAcceleration: Float32Array | null;
  117138. readonly linearVelocity: Float32Array | null;
  117139. readonly orientation: Float32Array | null;
  117140. readonly position: Float32Array | null;
  117141. readonly timestamp: number;
  117142. }
  117143. interface VRStageParameters {
  117144. sittingToStandingTransform?: Float32Array;
  117145. sizeX?: number;
  117146. sizeY?: number;
  117147. }
  117148. interface Navigator {
  117149. getVRDisplays(): Promise<VRDisplay[]>;
  117150. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  117151. }
  117152. interface Window {
  117153. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  117154. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  117155. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  117156. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  117157. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  117158. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  117159. }
  117160. interface Gamepad {
  117161. readonly displayId: number;
  117162. }
  117163. interface XRDevice {
  117164. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  117165. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  117166. }
  117167. interface XRSession {
  117168. getInputSources(): Array<any>;
  117169. baseLayer: XRWebGLLayer;
  117170. requestFrameOfReference(type: string): Promise<void>;
  117171. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  117172. end(): Promise<void>;
  117173. requestAnimationFrame: Function;
  117174. addEventListener: Function;
  117175. }
  117176. interface XRSessionCreationOptions {
  117177. outputContext?: WebGLRenderingContext | null;
  117178. immersive?: boolean;
  117179. environmentIntegration?: boolean;
  117180. }
  117181. interface XRLayer {
  117182. getViewport: Function;
  117183. framebufferWidth: number;
  117184. framebufferHeight: number;
  117185. }
  117186. interface XRView {
  117187. projectionMatrix: Float32Array;
  117188. }
  117189. interface XRFrame {
  117190. getDevicePose: Function;
  117191. getInputPose: Function;
  117192. views: Array<XRView>;
  117193. baseLayer: XRLayer;
  117194. }
  117195. interface XRFrameOfReference {
  117196. }
  117197. interface XRWebGLLayer extends XRLayer {
  117198. framebuffer: WebGLFramebuffer;
  117199. }
  117200. declare var XRWebGLLayer: {
  117201. prototype: XRWebGLLayer;
  117202. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  117203. };